[{"id":1078,"web_url":"https://patchwork.libcamera.org/comment/1078/","msgid":"<20190321082859.GB4615@pendragon.ideasonboard.com>","date":"2019-03-21T08:28:59","subject":"Re: [libcamera-devel] [PATCH] libcamera: media_device: Initialise\n\tlocal variable","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nI'd rename the subject to \"Fix uninitialized variable warning\" or\nsomething similar.\n\nOn Tue, Mar 19, 2019 at 11:35:32AM +0000, Kieran Bingham wrote:\n> The local variable ifaceId generates a compiler warning that it is used\n> without initialisation.\n\nCould you specify the compiler version ?\n\n> The loop, and check against the loop iterator, and the\n> topology.num_interfaces actually ensures that this isn't the case, and\n> that ifaceId can only be used when set to a valid ID.\n> \n> The media_v2_interface.id field documents the ID as simply \"Unique ID\n> for the interface\" but does not specify if zero is a valid ID or not. As\n> such we don't further check the pre-initialised ID for validity and keep\n> the existing check on the iterator count to determine if the ID had been\n> discovered successfully.\n\nI think we could still change that as the kernel ensures that entity IDs\nstart at 1, but I'll leave that up to you.\n\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nWith the above fixed,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/media_device.cpp | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp\n> index ea4608932834..1e9024bf9721 100644\n> --- a/src/libcamera/media_device.cpp\n> +++ b/src/libcamera/media_device.cpp\n> @@ -516,7 +516,7 @@ struct media_v2_interface *MediaDevice::findInterface(const struct media_v2_topo\n>  {\n>  \tstruct media_v2_link *links = reinterpret_cast<struct media_v2_link *>\n>  \t\t\t\t\t\t      (topology.ptr_links);\n> -\tunsigned int ifaceId;\n> +\tunsigned int ifaceId = 0;\n>  \tunsigned int i;\n>  \n>  \tfor (i = 0; i < topology.num_links; ++i) {","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 08BE4600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Mar 2019 09:29:12 +0100 (CET)","from pendragon.ideasonboard.com (30.net042126252.t-com.ne.jp\n\t[42.126.252.30])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A72E423A;\n\tThu, 21 Mar 2019 09:29:10 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1553156951;\n\tbh=ltpAyU9kE1dDORU5RAOy4VQYno6X1e9oztJByvVck+8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ig4cveojGfZ4b2M9/od3Shfk9GmT2RdV/L5Ck9CYKU4DN+VDDO5rfx9/+C4jjBKrA\n\tf2JuEbmqDynopvN4mW6/lvzuJUB7MR3/YQQjUi0iI2GWeTHqW4kiHQK7IvKGk/B+5s\n\tlN3W9QorfhpO3+kQHFICBAl7+4g0uaBiasrqmKzM=","Date":"Thu, 21 Mar 2019 10:28:59 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20190321082859.GB4615@pendragon.ideasonboard.com>","References":"<20190319113532.18400-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190319113532.18400-1-kieran.bingham@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] libcamera: media_device: Initialise\n\tlocal variable","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 21 Mar 2019 08:29:12 -0000"}}]