[{"id":30119,"web_url":"https://patchwork.libcamera.org/comment/30119/","msgid":"<nr5u7vvcnwuublv5wcmpgid2qqtuh3t3l5hgmsth5ax2y6hcxx@ys3sxc42ne73>","date":"2024-06-28T10:08:37","subject":"Re: [PATCH v2] libcamera: Fix maybe-uninitialized error","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Stefan\n\nOn Fri, Jun 28, 2024 at 11:36:02AM GMT, Stefan Klug wrote:\n> The gcc used in my current buildroot (Version 12.3) errors out with\n> -Wmaybe-uninitialized. Fix that.\n>\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\n\n> ---\n> Changes in v2:\n> - Changed the error handling in AwbConfg::read as proposed by Naushir\n> - Removed unnecessary rewrapping of a comment\n>\n>  src/ipa/libipa/exposure_mode_helper.cpp   | 9 +++------\n>  src/ipa/rpi/controller/rpi/awb.cpp        | 2 +-\n>  src/libcamera/device_enumerator_sysfs.cpp | 2 +-\n>  src/libcamera/pipeline/rpi/vc4/vc4.cpp    | 2 +-\n>  4 files changed, 6 insertions(+), 9 deletions(-)\n>\n> diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp\n> index 683a564a01c8..7703becc4766 100644\n> --- a/src/ipa/libipa/exposure_mode_helper.cpp\n> +++ b/src/ipa/libipa/exposure_mode_helper.cpp\n> @@ -166,7 +166,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>  \t\treturn { minShutter_, minGain_, exposure / (minShutter_ * minGain_) };\n>\n>  \tutils::Duration shutter;\n> -\tdouble stageGain;\n> +\tdouble stageGain = 1.0;\n>  \tdouble gain;\n>\n>  \tfor (unsigned int stage = 0; stage < gains_.size(); stage++) {\n> @@ -201,12 +201,9 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const\n>  \t * From here on all we can do is max out the shutter time, followed by\n>  \t * the analogue gain. If we still haven't achieved the target we send\n>  \t * the rest of the exposure time to digital gain. If we were given no\n> -\t * stages to use then set stageGain to 1.0 so that shutter time is maxed\n> -\t * before gain touched at all.\n> +\t * stages to use then the default stageGain of 1.0 is used so that\n> +\t * shutter time is maxed before gain is touched at all.\n>  \t */\n> -\tif (gains_.empty())\n> -\t\tstageGain = 1.0;\n> -\n>  \tshutter = clampShutter(exposure / clampGain(stageGain));\n>  \tgain = clampGain(exposure / shutter);\n>\n> diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp\n> index 003c8fa137f3..f45525bce2d1 100644\n> --- a/src/ipa/rpi/controller/rpi/awb.cpp\n> +++ b/src/ipa/rpi/controller/rpi/awb.cpp\n> @@ -122,7 +122,7 @@ int AwbConfig::read(const libcamera::YamlObject &params)\n>  \t\t}\n>  \t\tif (priors.empty()) {\n>  \t\t\tLOG(RPiAwb, Error) << \"AwbConfig: no AWB priors configured\";\n> -\t\t\treturn ret;\n> +\t\t\treturn -EINVAL;\n>  \t\t}\n>  \t}\n>  \tif (params.contains(\"modes\")) {\n> diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp\n> index fc33ba52b813..7866885c0f73 100644\n> --- a/src/libcamera/device_enumerator_sysfs.cpp\n> +++ b/src/libcamera/device_enumerator_sysfs.cpp\n> @@ -33,7 +33,7 @@ int DeviceEnumeratorSysfs::init()\n>  int DeviceEnumeratorSysfs::enumerate()\n>  {\n>  \tstruct dirent *ent;\n> -\tDIR *dir;\n> +\tDIR *dir = nullptr;\n>\n>  \tstatic const char * const sysfs_dirs[] = {\n>  \t\t\"/sys/subsystem/media/devices\",\n> diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> index 4a89e35f5d7b..e5b6ef2b37cd 100644\n> --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> @@ -802,7 +802,7 @@ void Vc4CameraData::ispInputDequeue(FrameBuffer *buffer)\n>  void Vc4CameraData::ispOutputDequeue(FrameBuffer *buffer)\n>  {\n>  \tRPi::Stream *stream = nullptr;\n> -\tunsigned int index;\n> +\tunsigned int index = 0;\n>\n>  \tif (!isRunning())\n>  \t\treturn;\n> --\n> 2.43.0\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 5CB17BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 28 Jun 2024 10:08:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7F8E262C9B;\n\tFri, 28 Jun 2024 12:08:42 +0200 (CEST)","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 8D1C4619E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Jun 2024 12:08:40 +0200 (CEST)","from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C3F76735;\n\tFri, 28 Jun 2024 12:08:15 +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=\"OXGSWvmf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1719569295;\n\tbh=HOnmoiMcBSy62wGQbDw3F3c5j+zsTtl0wjlUTWqxvTk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OXGSWvmfXk9rBFNcXC+e51J2waqOX2sLKWhaWPr6Xb2sx2R6URmmjsw02VNDZeL/n\n\tAdcj73PAcZxX5BPhFBoYTsfkE0ALRzDSMtrfTzUGFfpO7c9nfL6GkYbAAsWTyX2ABl\n\tMEs4HlXoza17rJIO+qs2Y/EK5yGcIgymuEWodsTI=","Date":"Fri, 28 Jun 2024 12:08:37 +0200","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"Re: [PATCH v2] libcamera: Fix maybe-uninitialized error","Message-ID":"<nr5u7vvcnwuublv5wcmpgid2qqtuh3t3l5hgmsth5ax2y6hcxx@ys3sxc42ne73>","References":"<20240628093643.2896445-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240628093643.2896445-1-stefan.klug@ideasonboard.com>","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>"}}]