{"id":18717,"url":"https://patchwork.libcamera.org/api/1.1/patches/18717/?format=json","web_url":"https://patchwork.libcamera.org/patch/18717/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230607100054.4576-3-naush@raspberrypi.com>","date":"2023-06-07T10:00:53","name":"[libcamera-devel,v1,2/3] ipa: rpi: agc: Use std::string instead of char arrays","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"fc42662d702c8840017a41e096b13e2a4d1e6a49","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/18717/mbox/","series":[{"id":3912,"url":"https://patchwork.libcamera.org/api/1.1/series/3912/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3912","date":"2023-06-07T10:00:51","name":"RPi: AGC error handling","version":1,"mbox":"https://patchwork.libcamera.org/series/3912/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/18717/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/18717/checks/","tags":{},"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 95DF9C31E9\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Jun 2023 10:01:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A7B0628A0;\n\tWed,  7 Jun 2023 12:01:10 +0200 (CEST)","from mail-wm1-x329.google.com (mail-wm1-x329.google.com\n\t[IPv6:2a00:1450:4864:20::329])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2374562899\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Jun 2023 12:01:07 +0200 (CEST)","by mail-wm1-x329.google.com with SMTP id\n\t5b1f17b1804b1-3f735bfcbbbso31572725e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 07 Jun 2023 03:01:07 -0700 (PDT)","from localhost.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tt7-20020a1c7707000000b003f6cf9afc25sm1556889wmi.40.2023.06.07.03.01.05\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 07 Jun 2023 03:01:05 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1686132070;\n\tbh=tu4bRmcEaQqNlcxtWPbaL9tphuQr8mmI66go/+RstpY=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=xWkYSvxTu3xG4/6aIsXkYDdaBkKDRZhnxcremSEytEPvNxs9q7g5sIX5pgpQ0GLBd\n\tEqgxAjZQ7mX68ZZaygx3SpY49tKtqv5JQFCefxy80DYBjxHNCh3rbhKNQ5imzsKh+E\n\t4OwJDisujyK3LrmaxJ7EQZpqIKYVSA3Ultfi4CLCqXv9gyRdraSPpEr11JZPCMUK+z\n\tScGi7gZqpg1a1NLdJNPG7vcRxTbkix95gAN0VV6quDrCG6Y0fo2tQe7rqYpQCniKj+\n\t9HhZZ3S3s2aHqZTngmQg8SXSTKX4rvJOsRuvQCOyNYgL1lTwWcj+UwRpzRkA5VAoid\n\t8QHRMvNdva9pg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1686132066; x=1688724066;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=fdSQojxheQYTuQ2xidXZl7R5UCmxPlHXljHGiv5RCeY=;\n\tb=QoQM82zyHkok+d0UzA9QhxSLkIinN8ILmRbne1nOFe8AWimVl5bSNpBqbAMa601bNL\n\tN/V7qTnOL/kycDQfo+tCcVwEcF4CXwLOjjqyFVftvE0X/P7cDSeMldrDVjqYKhV3vu9a\n\t+dkdrlY/sGrgGweq7u813d6zNmgJ0tMLzOPQ1+t0CNrhx28Wi9mktDuuNXBgq0H1H7m8\n\tOU4BhLr8z1kPGqFpkGKOnmzsg51OwecMLem4JpEzSa9tqDB95KK82sRvzNyw8e+gHx4Q\n\tvJnu1O6N5tiQqfBkRt6rSnwFcm1yoL4H8o1yRx00yajUZc99D1o55yD4xwXoxNcsWvrO\n\tzD6g=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"QoQM82zy\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1686132066; x=1688724066;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=fdSQojxheQYTuQ2xidXZl7R5UCmxPlHXljHGiv5RCeY=;\n\tb=l+xxvfNMKNLilIWWKq4qPU5Ygqq+t3xDXC9eAvtuGMSDx/9sBcvP70ZcAZfMhZlMbh\n\tLqbeO6OG5u1tqBtpJqu23JyxLZCZVb1dzLTT/8Sx9KDyi8lhc7d29us76H0lPqh81PSh\n\ttp/N44MRILcz3t7Hx93u62gULps7i+vnLoaUnneLI2u03uG28EfiYUqJTyCmnNtNa4gW\n\tqdQHvMyifRN7nAukwRMoI2Zp7XHnuHzPjLXapeR8DO9ul2LTbh1n0Y3nc4WlD0TjcxcH\n\tKxM0crA/thzMAtm6vES0hshvLROm5mMBQGEODJXn7cYS+LxAQcB+cil/WdD+HKql5VG6\n\tMCwA==","X-Gm-Message-State":"AC+VfDzw5FrJTmbqc8NK9wuEl9Bk6R36Azl5Cya1YWnEXvx/7F9G3WdP\n\tX3fr6/dT9SZZG+E35dOqqiwBHnDWUFDEyeUN7MaDrQ==","X-Google-Smtp-Source":"ACHHUZ67CqYgA93SCMdYrFfjcYqW/HhxFRjfefAYtvpb0+WCZ5MOR3op5tP7OMdacJw1+WFY4T/k5g==","X-Received":"by 2002:a05:600c:2257:b0:3f6:f152:1183 with SMTP id\n\ta23-20020a05600c225700b003f6f1521183mr4197229wmm.37.1686132066444; \n\tWed, 07 Jun 2023 03:01:06 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  7 Jun 2023 11:00:53 +0100","Message-Id":"<20230607100054.4576-3-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20230607100054.4576-1-naush@raspberrypi.com>","References":"<20230607100054.4576-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 2/3] ipa: rpi: agc: Use std::string\n\tinstead of char arrays","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>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Replace the char array strings in struct AgcStatus with std::string\nobjects. This simplifies the string handling in the source code.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/controller/agc_status.h |  8 +++++---\n src/ipa/rpi/controller/rpi/agc.cpp  | 23 +++++++----------------\n 2 files changed, 12 insertions(+), 19 deletions(-)","diff":"diff --git a/src/ipa/rpi/controller/agc_status.h b/src/ipa/rpi/controller/agc_status.h\nindex 6abf09d9df57..6c112e76aa12 100644\n--- a/src/ipa/rpi/controller/agc_status.h\n+++ b/src/ipa/rpi/controller/agc_status.h\n@@ -6,6 +6,8 @@\n  */\n #pragma once\n \n+#include <string>\n+\n #include <libcamera/base/utils.h>\n \n /*\n@@ -24,9 +26,9 @@ struct AgcStatus {\n \tlibcamera::utils::Duration targetExposureValue; /* (unfiltered) target total exposure AGC is aiming for */\n \tlibcamera::utils::Duration shutterTime;\n \tdouble analogueGain;\n-\tchar exposureMode[32];\n-\tchar constraintMode[32];\n-\tchar meteringMode[32];\n+\tstd::string exposureMode;\n+\tstd::string constraintMode;\n+\tstd::string meteringMode;\n \tdouble ev;\n \tlibcamera::utils::Duration flickerPeriod;\n \tint floatingRegionEnable;\ndiff --git a/src/ipa/rpi/controller/rpi/agc.cpp b/src/ipa/rpi/controller/rpi/agc.cpp\nindex e79c82e2e65b..b611157af1f0 100644\n--- a/src/ipa/rpi/controller/rpi/agc.cpp\n+++ b/src/ipa/rpi/controller/rpi/agc.cpp\n@@ -226,7 +226,7 @@ Agc::Agc(Controller *controller)\n \t * Setting status_.totalExposureValue_ to zero initially tells us\n \t * it's not been calculated yet (i.e. Process hasn't yet run).\n \t */\n-\tmemset(&status_, 0, sizeof(status_));\n+\tstatus_ = {};\n \tstatus_.ev = ev_;\n }\n \n@@ -524,12 +524,6 @@ void Agc::updateLockStatus(DeviceStatus const &deviceStatus)\n \tstatus_.locked = lockCount_ == maxLockCount;\n }\n \n-static void copyString(std::string const &s, char *d, size_t size)\n-{\n-\tsize_t length = s.copy(d, size - 1);\n-\td[length] = '\\0';\n-}\n-\n void Agc::housekeepConfig()\n {\n \t/* First fetch all the up-to-date settings, so no one else has to do it. */\n@@ -544,30 +538,27 @@ void Agc::housekeepConfig()\n \t * Make sure the \"mode\" pointers point to the up-to-date things, if\n \t * they've changed.\n \t */\n-\tif (strcmp(meteringModeName_.c_str(), status_.meteringMode)) {\n+\tif (meteringModeName_ != status_.meteringMode) {\n \t\tauto it = config_.meteringModes.find(meteringModeName_);\n \t\tif (it == config_.meteringModes.end())\n \t\t\tLOG(RPiAgc, Fatal) << \"No metering mode \" << meteringModeName_;\n \t\tmeteringMode_ = &it->second;\n-\t\tcopyString(meteringModeName_, status_.meteringMode,\n-\t\t\t   sizeof(status_.meteringMode));\n+\t\tstatus_.meteringMode = meteringModeName_;\n \t}\n-\tif (strcmp(exposureModeName_.c_str(), status_.exposureMode)) {\n+\tif (exposureModeName_ != status_.exposureMode) {\n \t\tauto it = config_.exposureModes.find(exposureModeName_);\n \t\tif (it == config_.exposureModes.end())\n \t\t\tLOG(RPiAgc, Fatal) << \"No exposure profile \" << exposureModeName_;\n \t\texposureMode_ = &it->second;\n-\t\tcopyString(exposureModeName_, status_.exposureMode,\n-\t\t\t   sizeof(status_.exposureMode));\n+\t\tstatus_.exposureMode = exposureModeName_;\n \t}\n-\tif (strcmp(constraintModeName_.c_str(), status_.constraintMode)) {\n+\tif (constraintModeName_ != status_.constraintMode) {\n \t\tauto it =\n \t\t\tconfig_.constraintModes.find(constraintModeName_);\n \t\tif (it == config_.constraintModes.end())\n \t\t\tLOG(RPiAgc, Fatal) << \"No constraint list \" << constraintModeName_;\n \t\tconstraintMode_ = &it->second;\n-\t\tcopyString(constraintModeName_, status_.constraintMode,\n-\t\t\t   sizeof(status_.constraintMode));\n+\t\tstatus_.constraintMode = constraintModeName_;\n \t}\n \tLOG(RPiAgc, Debug) << \"exposureMode \"\n \t\t\t   << exposureModeName_ << \" constraintMode \"\n","prefixes":["libcamera-devel","v1","2/3"]}