{"id":22853,"url":"https://patchwork.libcamera.org/api/patches/22853/?format=json","web_url":"https://patchwork.libcamera.org/patch/22853/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20250224220438.21512-2-laurent.pinchart@ideasonboard.com>","date":"2025-02-24T22:04:37","name":"[1/2] libipa: awb: Fix non-virtual destructor warning in AwbStats","commit_ref":"005d19a73fb5d9813e924c26f010e0117fc47568","pull_url":null,"state":"accepted","archived":false,"hash":"119eb73f382fcb42688ca040dd6cb117a7d91220","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22853/mbox/","series":[{"id":5017,"url":"https://patchwork.libcamera.org/api/series/5017/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5017","date":"2025-02-24T22:04:36","name":"libcamera: Fix -Wnon-virtual-dtor warning","version":1,"mbox":"https://patchwork.libcamera.org/series/5017/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22853/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22853/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 9A5F3BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Feb 2025 22:05:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 41C7868715;\n\tMon, 24 Feb 2025 23:05:03 +0100 (CET)","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 4AA8961856\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Feb 2025 23:05:00 +0100 (CET)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 561BC7EA;\n\tMon, 24 Feb 2025 23:03:33 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"R2UBwaxH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1740434613;\n\tbh=qx9j7jLD3g7183ifumkfwGC3vlB8/dtEvKxWiPdysRc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=R2UBwaxHt7Xlu3VRgSoZ7Tch0MmRhy2z8b1GOsFPx7Thc6mHjSrgIuLTCryIXbNyH\n\taJObqisxYxVtLCUzGmJo13hN38Amyo3U1byKAW07tKs4u/bTn7YSL299MnvUAhy2Fv\n\tZb18QnVB2svD/TfftIRyzD1puRiWht9inTSypIpc=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tMilan Zamazal <mzamazal@redhat.com>","Subject":"[PATCH 1/2] libipa: awb: Fix non-virtual destructor warning in\n\tAwbStats","Date":"Tue, 25 Feb 2025 00:04:37 +0200","Message-ID":"<20250224220438.21512-2-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.45.3","In-Reply-To":"<20250224220438.21512-1-laurent.pinchart@ideasonboard.com>","References":"<20250224220438.21512-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>"},"content":"The AwbStats structure has virtual functions but a publicly accessible\nnon-virtual destructors. This can cause undefined behaviour if deleting\na derived class instance through a pointer to the base AwbStats class.\n\nThe problem is theoretical only as no code in libcamera is expected to\nperform such deletion, but compilers can't know that and will emit a\nwarning if the -Wnon-virtual-dtor option is enabled.\n\nFixing this can be done by declaring a virtual public destructor in the\nAwbStats class. A more efficient alternative is to declare a protected\nnon-virtual destructor, ensuring that instances can't be deleted through\na pointer to the base class. Do so, and mark the derived RkISP1AwbStats\nas final to avoid the same warning.\n\nFixes: 6f663990a0f7 (\"libipa: Add AWB algorithm base class\")\nReported-by: Milan Zamazal <mzamazal@redhat.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/libipa/awb.h              | 3 +++\n src/ipa/rkisp1/algorithms/awb.cpp | 2 +-\n 2 files changed, 4 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/libipa/awb.h b/src/ipa/libipa/awb.h\nindex a86581adf43e..4bab7a451ce5 100644\n--- a/src/ipa/libipa/awb.h\n+++ b/src/ipa/libipa/awb.h\n@@ -27,6 +27,9 @@ struct AwbResult {\n struct AwbStats {\n \tvirtual double computeColourError(const RGB<double> &gains) const = 0;\n \tvirtual RGB<double> rgbMeans() const = 0;\n+\n+protected:\n+\t~AwbStats() = default;\n };\n \n class AwbAlgorithm\ndiff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\nindex 6f9d454eb88f..eafe93081bb1 100644\n--- a/src/ipa/rkisp1/algorithms/awb.cpp\n+++ b/src/ipa/rkisp1/algorithms/awb.cpp\n@@ -42,7 +42,7 @@ constexpr int32_t kDefaultColourTemperature = 5000;\n /* Minimum mean value below which AWB can't operate. */\n constexpr double kMeanMinThreshold = 2.0;\n \n-class RkISP1AwbStats : public AwbStats\n+class RkISP1AwbStats final : public AwbStats\n {\n public:\n \tRkISP1AwbStats(const RGB<double> &rgbMeans)\n","prefixes":["1/2"]}