From patchwork Thu Jun 27 13:31:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 20429 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0B04EBDB1D for ; Thu, 27 Jun 2024 13:37:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B364B62C9D; Thu, 27 Jun 2024 15:37:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="u74kO2kx"; dkim-atps=neutral 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 8D14462C95 for ; Thu, 27 Jun 2024 15:37:56 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:6248:8b4b:42bc:2b84]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AECC0593; Thu, 27 Jun 2024 15:37:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1719495452; bh=jtOGT/tfrZE0dkn6yoPlCN87o9GtZqQGAhUroo/BD70=; h=From:To:Cc:Subject:Date:From; b=u74kO2kxuVA5wAkak8qPymz3cOyDqsTwA4DWox61YRJhxjpdqFWgEUH876a67DBgW CYl81RPRWd1CVysU3X6nAwXVFKYnNSnNqifwDM5SD8DquqqVpFV0g3WkY0Our7WPso U3OtHeN+ckw6RmK1Q7AQ/MwR1mFd3GujhCn9HP54= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , Stefan Klug Subject: [PATCH] libcamera: fix maybe-uninitialized error Date: Thu, 27 Jun 2024 15:31:00 +0200 Message-ID: <20240627133730.2554717-1-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The gcc used in my current buildroot (Version 12.3) errors out with -Wmaybe-uninitialized. Fix that. Signed-off-by: Stefan Klug Reviewed-by: Naushir Patuck --- @Naush: Could you have a look at the rpi specific changes? Specifically I'm not sure if the change in AwbConfig::read() is correct. It was unclear to me if there are cases where line 125 should return 0 even though a error got logged one line above. Regards, Stefan src/ipa/libipa/exposure_mode_helper.cpp | 15 ++++++--------- src/ipa/rpi/controller/rpi/awb.cpp | 2 +- src/libcamera/device_enumerator_sysfs.cpp | 2 +- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/ipa/libipa/exposure_mode_helper.cpp b/src/ipa/libipa/exposure_mode_helper.cpp index 683a564a01c8..9d1387636d05 100644 --- a/src/ipa/libipa/exposure_mode_helper.cpp +++ b/src/ipa/libipa/exposure_mode_helper.cpp @@ -166,7 +166,7 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const return { minShutter_, minGain_, exposure / (minShutter_ * minGain_) }; utils::Duration shutter; - double stageGain; + double stageGain = 1.0; double gain; for (unsigned int stage = 0; stage < gains_.size(); stage++) { @@ -198,15 +198,12 @@ ExposureModeHelper::splitExposure(utils::Duration exposure) const } /* - * From here on all we can do is max out the shutter time, followed by - * the analogue gain. If we still haven't achieved the target we send - * the rest of the exposure time to digital gain. If we were given no - * stages to use then set stageGain to 1.0 so that shutter time is maxed - * before gain touched at all. + * From here on all we can do is max out the shutter time, followed by the + * analogue gain. If we still haven't achieved the target we send the rest + * of the exposure time to digital gain. If we were given no stages to use + * then the default stageGain of 1.0 is used so that shutter time is maxed + * before gain is touched at all. */ - if (gains_.empty()) - stageGain = 1.0; - shutter = clampShutter(exposure / clampGain(stageGain)); gain = clampGain(exposure / shutter); diff --git a/src/ipa/rpi/controller/rpi/awb.cpp b/src/ipa/rpi/controller/rpi/awb.cpp index 003c8fa137f3..3503a5ab9218 100644 --- a/src/ipa/rpi/controller/rpi/awb.cpp +++ b/src/ipa/rpi/controller/rpi/awb.cpp @@ -91,7 +91,7 @@ static int readCtCurve(ipa::Pwl &ctR, ipa::Pwl &ctB, const libcamera::YamlObject int AwbConfig::read(const libcamera::YamlObject ¶ms) { - int ret; + int ret = 0; bayes = params["bayes"].get(1); framePeriod = params["frame_period"].get(10); diff --git a/src/libcamera/device_enumerator_sysfs.cpp b/src/libcamera/device_enumerator_sysfs.cpp index fc33ba52b813..7866885c0f73 100644 --- a/src/libcamera/device_enumerator_sysfs.cpp +++ b/src/libcamera/device_enumerator_sysfs.cpp @@ -33,7 +33,7 @@ int DeviceEnumeratorSysfs::init() int DeviceEnumeratorSysfs::enumerate() { struct dirent *ent; - DIR *dir; + DIR *dir = nullptr; static const char * const sysfs_dirs[] = { "/sys/subsystem/media/devices", diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index 4a89e35f5d7b..e5b6ef2b37cd 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -802,7 +802,7 @@ void Vc4CameraData::ispInputDequeue(FrameBuffer *buffer) void Vc4CameraData::ispOutputDequeue(FrameBuffer *buffer) { RPi::Stream *stream = nullptr; - unsigned int index; + unsigned int index = 0; if (!isRunning()) return;