[{"id":36229,"web_url":"https://patchwork.libcamera.org/comment/36229/","msgid":"<wn2aj7cthdiwn5ry2v42v2yk46ixpj2xm72kcye76trdthtmc3@rytoldf5olec>","date":"2025-10-13T14:35:34","subject":"Re: [PATCH] pipeline: simple: Avoid overusage of auto variables","submitter":{"id":232,"url":"https://patchwork.libcamera.org/api/people/232/","name":"Umang Jain","email":"uajain@igalia.com"},"content":"Hello,\n\nOn Mon, Oct 13, 2025 at 05:23:29PM +0300, Laurent Pinchart wrote:\n> Using auto variables for simple types reduces readability. Spell out\n> unsigned int explicitly here, and replace the <= 0 check with a zero\n> check now that the explicit type shows the value can't be negative.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Umang Jain <uajain@igalia.com>\n\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index dec9f6514f8c..7b0783cdbc32 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -1266,8 +1266,8 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n>  \t\t\tcfg.frameSize = format.planes[0].size;\n>  \t\t}\n>  \n> -\t\tconst auto bufferCount = cfg.bufferCount;\n> -\t\tif (bufferCount <= 0)\n> +\t\tconst unsigned int bufferCount = cfg.bufferCount;\n> +\t\tif (!bufferCount)\n>  \t\t\tcfg.bufferCount = kNumBuffersDefault;\n>  \t\telse if (bufferCount > kNumBuffersMax)\n>  \t\t\tcfg.bufferCount = kNumBuffersMax;\n> \n> base-commit: 05bfebed2657cc1d032c9796efd9041bfbdc881c\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 43295BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Oct 2025 14:35:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0738960523;\n\tMon, 13 Oct 2025 16:35:23 +0200 (CEST)","from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE2346031A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Oct 2025 16:35:21 +0200 (CEST)","from [49.36.127.56] (helo=uajain)\n\tby fanzine2.igalia.com with esmtpsa \n\t(Cipher TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)\n\t(Exim) id 1v8Jdw-008yHd-Ar; Mon, 13 Oct 2025 16:35:20 +0200"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=igalia.com header.i=@igalia.com\n\theader.b=\"ESsrbuwQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com;\n\ts=20170329;\n\th=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:\n\tSubject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=A9NqKK6i5sbs1zt89Y9j/JUz9Cppa4aYbRiZoKqgBp4=;\n\tb=ESsrbuwQLBnHWOL9adab+sjED3\n\t+fdGcvisZgC2sN6z5gNOTd7fpsWpu3FYRmwQzNUYr8Dt4IoYwZfXOVnAmmQI5HBwfGJfZTPrlFpHa\n\tjtlD9CZ0HgGUTzPEti57gcxKhfvOxjIIM5qQ3OIa6gbfACUATFwhUkby+XIkmAHp/NFi9T8unaPYF\n\toabuAQnkWjRf7TiDN7GY1l0VkQaiRz5wLBFfLjVsQcNBO1up0VR3v/0nWKqMaVPcpxrSaBU/4Pceh\n\tqw83ZdvfwOH2VfLXuiJNDJ1NPc3paSIunDta9+ifXnVOx1j/cRsmgyQw7yl9+lEmawVhjrRpnVZxi\n\tYVolrRsw==;","Date":"Mon, 13 Oct 2025 20:05:34 +0530","From":"Umang Jain <uajain@igalia.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tRobert Mader <robert.mader@collabora.com>","Subject":"Re: [PATCH] pipeline: simple: Avoid overusage of auto variables","Message-ID":"<wn2aj7cthdiwn5ry2v42v2yk46ixpj2xm72kcye76trdthtmc3@rytoldf5olec>","References":"<20251013142329.1386-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20251013142329.1386-1-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20250905-dirty","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":36231,"web_url":"https://patchwork.libcamera.org/comment/36231/","msgid":"<176036860122.559803.16194096897074620262@ping.linuxembedded.co.uk>","date":"2025-10-13T15:16:41","subject":"Re: [PATCH] pipeline: simple: Avoid overusage of auto variables","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2025-10-13 15:23:29)\n> Using auto variables for simple types reduces readability. Spell out\n> unsigned int explicitly here, and replace the <= 0 check with a zero\n> check now that the explicit type shows the value can't be negative.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/pipeline/simple/simple.cpp | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index dec9f6514f8c..7b0783cdbc32 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -1266,8 +1266,8 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate()\n>                         cfg.frameSize = format.planes[0].size;\n>                 }\n>  \n> -               const auto bufferCount = cfg.bufferCount;\n> -               if (bufferCount <= 0)\n> +               const unsigned int bufferCount = cfg.bufferCount;\n> +               if (!bufferCount)\n>                         cfg.bufferCount = kNumBuffersDefault;\n\nQuite sure I proposed this but it didn't make it in - so:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>                 else if (bufferCount > kNumBuffersMax)\n>                         cfg.bufferCount = kNumBuffersMax;\n> \n> base-commit: 05bfebed2657cc1d032c9796efd9041bfbdc881c\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id EA768BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Oct 2025 15:16:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5AAF26052F;\n\tMon, 13 Oct 2025 17:16:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 071D0604F4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Oct 2025 17:16:43 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 36B8AC6F;\n\tMon, 13 Oct 2025 17:15:06 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RpVUtolC\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1760368506;\n\tbh=VJGfVsEtDkZHvmL7djA+pwyljP03PEEPEzxUAPTNeC4=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=RpVUtolCOTWDW5BUrQ5aeqfrcyn1gjIgUhvAvFSCZLno+8tORPu5/WGVakg1cJtZC\n\t+ympjkuWKpdQlhA2ZlTfGvpU+IFef8Gb8QN11Msuf8Hc90YDUIE6IkudYdqFjp8t+x\n\twIGf2Uou1xoI3p3i8L+H90FROyDMS/X5q+TvrSAs=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251013142329.1386-1-laurent.pinchart@ideasonboard.com>","References":"<20251013142329.1386-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [PATCH] pipeline: simple: Avoid overusage of auto variables","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Robert Mader <robert.mader@collabora.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 13 Oct 2025 16:16:41 +0100","Message-ID":"<176036860122.559803.16194096897074620262@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]