[PATCH v1] pipeline: rpi: Fix potential empty optional read

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Mar 26 03:00:19 CET 2025


Hi Barnabás,

Thank you for the patch.

On Tue, Mar 25, 2025 at 03:07:45PM +0100, Barnabás Pőcze wrote:
> 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 <barnabas.pocze at ideasonboard.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

> ---
>  src/libcamera/pipeline/rpi/vc4/vc4.cpp | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 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<YamlObject> &
>  	}
> 
>  	std::optional<std::string> target = (*root)["target"].get<std::string>();
> -	if (!target || *target != "bcm2835") {
> +	if (target != "bcm2835") {
>  		LOG(RPI, Error) << "Unexpected target reported: expected \"bcm2835\", got "
> -				<< *target;
> +				<< (target ? target->c_str() : "(unknown)");
>  		return -EINVAL;
>  	}
> 

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list