From patchwork Tue Mar 19 11:35:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 742 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C1233600FD for ; Tue, 19 Mar 2019 12:35:36 +0100 (CET) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 352D433A; Tue, 19 Mar 2019 12:35:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1552995336; bh=ZlfK2gFlHOAIvSQDA9yqRbsUDL0bkJxQSG3SV1U2ozQ=; h=From:To:Cc:Subject:Date:From; b=Ogjho4GKhANufOsRqtQC/+H8BjVvACdrZUF7d03qM8TRUjFlUHG2WpviRijO4jBnK P63slLQTsE0UBCZMOWUOT9uEK0ZHIMzhDD2jGOuH+G5AB8tL/W4oa4hfyLjdj6w6OU fuXIQWy5Z0PY98D+CxAWJyLrAhje++da4Sq34YjM= From: Kieran Bingham To: LibCamera Devel Date: Tue, 19 Mar 2019 11:35:32 +0000 Message-Id: <20190319113532.18400-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] libcamera: media_device: Initialise local variable X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2019 11:35:37 -0000 The local variable ifaceId generates a compiler warning that it is used without initialisation. The loop, and check against the loop iterator, and the topology.num_interfaces actually ensures that this isn't the case, and that ifaceId can only be used when set to a valid ID. The media_v2_interface.id field documents the ID as simply "Unique ID for the interface" but does not specify if zero is a valid ID or not. As such we don't further check the pre-initialised ID for validity and keep the existing check on the iterator count to determine if the ID had been discovered successfully. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/media_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index ea4608932834..1e9024bf9721 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -516,7 +516,7 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo { struct media_v2_link *links = reinterpret_cast (topology.ptr_links); - unsigned int ifaceId; + unsigned int ifaceId = 0; unsigned int i; for (i = 0; i < topology.num_links; ++i) {