From patchwork Mon May 27 13:24:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 20101 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 B8A6EBDE6B for ; Mon, 27 May 2024 13:24:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A711B634B1; Mon, 27 May 2024 15:24:41 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="C/GBF+bI"; dkim-atps=neutral Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 83AB6634AD for ; Mon, 27 May 2024 15:24:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1716816275; x=1717075475; bh=mHEljsZb66Gu7oxiu1pakx860w8cEqzjIJdScW4+/Co=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=C/GBF+bImkCGG0N5N3JOG6NE3KBfIubRHbf/Uxb5s+h4VVuDumwFdq8YvfbGJoPzp dK2ApN43udCit3QmGq+D7Hypo76c/8/27i3cZ8icYptIcOuPIJ7PV/Ww7GQHxvFgvF +TwwpfNBXPhRtbMr+okfSu8x+vr4ZHm6jTjsL+G2OWzIcuX9L54aP/N0aN/2FoWiA/ SswO421SG4/rmgdnuvLXUAX03vD2h80QNjGfXS1vDeQWVDuuodXNknuvTOnPWGKogz /Ro4ZC0UDV9p7AG33nR3rFGxiXcqbCoIjd0tUjT2gj8Wq2NPCuENW4Lto5jQskEmd1 HJM9ltEo14U2A== Date: Mon, 27 May 2024 13:24:29 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [PATCH v2] android: camera_capabilities: Fix GCC 14 warning Message-ID: <20240527132428.250382-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 4f9eb7676d9f55e15f43fa9ff60494d73a9d2b9f 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" GCC 14 thinks `rects` is a "possibly dangling reference to a temporary": /libcamera/src/android/camera_capabilities.cpp: In member function ‘int CameraCapabilities::initializeStaticMetadata()’: /libcamera/src/android/camera_capabilities.cpp:1084:46: error: possibly dangling reference to a temporary [-Werror=dangling-reference] 1084 | const Span& rects = | ^~~~~ /libcamera/src/android/camera_capabilities.cpp:1085:83: note: the temporary was destroyed at the end of the full expression ‘(& properties)->libcamera::ControlList::get >(libcamera::properties::PixelArrayActiveAreas).std::optional >::value_or >(libcamera::Span())’ 1085 | properties.get(properties::PixelArrayActiveAreas).value_or(Span{}); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ The return value of `value_or()` is indeed a temporary, but binding it to a reference extends its lifetime. Avoid the warning by not using a reference; this does not make much difference since `value_or()` does not return a reference. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/camera_capabilities.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6f4d48de..71043e12 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1081,7 +1081,7 @@ int CameraCapabilities::initializeStaticMetadata() } { - const Span &rects = + const Span rects = properties.get(properties::PixelArrayActiveAreas).value_or(Span{}); std::vector data{ static_cast(rects[0].x),