From patchwork Tue Mar 25 14:07:45 2025 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: 23012 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 8B2EAC3213 for ; Tue, 25 Mar 2025 14:07:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5E4EF68952; Tue, 25 Mar 2025 15:07:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WYx8mR+p"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 66B6B600EB for ; Tue, 25 Mar 2025 15:07:49 +0100 (CET) Received: from pb-laptop.local (185.221.143.221.nat.pool.zt.hu [185.221.143.221]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0FCD982E for ; Tue, 25 Mar 2025 15:06:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1742911562; bh=FhF7CCKEyiPE47i1r/Ns328oGIRuQyZ9stLEE8a9JZQ=; h=From:To:Subject:Date:From; b=WYx8mR+p+UtEYiVp0KknUk4IhTV/iOnvqLww+1FOC5SdlmvNLx9GnmgaVIF6GePUa cz7xT15IXPhy76LjpB5oK0cXZ4ZV9G9MZx+tVq4PW0voBwslJ53D4XSvF1c2EjYhxL n8zipHcNuzQemx/htBBPs+fugpYzg2MmcpoxxgCM= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1] pipeline: rpi: Fix potential empty optional read Date: Tue, 25 Mar 2025 15:07:45 +0100 Message-ID: <20250325140745.1400058-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.49.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" If `!target`, then `*target` is undefined behaviour, so check if the optional is empty when printing the error message. Simplify the check as well. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.49.0 diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index fd8d84b14..fe910bdf2 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -510,9 +510,9 @@ int Vc4CameraData::platformPipelineConfigure(const std::unique_ptr & } std::optional target = (*root)["target"].get(); - if (!target || *target != "bcm2835") { + if (target != "bcm2835") { LOG(RPI, Error) << "Unexpected target reported: expected \"bcm2835\", got " - << *target; + << (target ? target->c_str() : "(unknown)"); return -EINVAL; }