[{"id":33882,"web_url":"https://patchwork.libcamera.org/comment/33882/","msgid":"<CAEmqJPqfFEzFCZBNQsov+th6rhfuuBfJ-Sjc=NaEhs6bdYOw+A@mail.gmail.com>","date":"2025-04-02T09:04:32","subject":"Re: [PATCH v2] pipeline: rpi: Fix potential empty optional read","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Barnabás,\n\nThank you for this fix\n\nOn Tue, 1 Apr 2025 at 14:11, Barnabás Pőcze\n<barnabas.pocze@ideasonboard.com> wrote:\n>\n> If `!target`, then `*target` is undefined behaviour, so check if the optional\n> is empty when printing the error message. Simplify the check as well.\n>\n> Fixes: 6c71ee1f153051 (\"pipeline: raspberrypi: Introduce PipelineHandlerBase class\")\n> Fixes: 841ef2b4bb08ba (\"pipeline: rpi: Add support for Raspberry Pi 5\")\n> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n> Changes in v2:\n>   * fix the same issue in pisp as well\n> ---\n>  src/libcamera/pipeline/rpi/pisp/pisp.cpp | 4 ++--\n>  src/libcamera/pipeline/rpi/vc4/vc4.cpp   | 4 ++--\n>  2 files changed, 4 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> index 42ca7c80b..91e7f4c94 100644\n> --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> @@ -1350,9 +1350,9 @@ int PiSPCameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject>\n>         }\n>\n>         std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n> -       if (!target || *target != \"pisp\") {\n> +       if (target != \"pisp\") {\n\nI'm a bit curious about this change.\n\nShould we keep the if (!target || ...) test?  If \"target\" key is not\npresent in the yaml, the optional will be a nullopt, and we then deref\nfor the string comparison.  Does this work out correctly by compiler\nmagic, or is it undefined behavior?  Ditto for the change below.\n\nRegards,\nNaush\n\n\n>                 LOG(RPI, Error) << \"Unexpected target reported: expected \\\"pisp\\\", got \"\n> -                               << *target;\n> +                               << (target ? target->c_str() : \"(unknown)\");\n>                 return -EINVAL;\n>         }\n>\n> diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> index fd8d84b14..fe910bdf2 100644\n> --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> @@ -510,9 +510,9 @@ int Vc4CameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject> &\n>         }\n>\n>         std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n> -       if (!target || *target != \"bcm2835\") {\n> +       if (target != \"bcm2835\") {\n>                 LOG(RPI, Error) << \"Unexpected target reported: expected \\\"bcm2835\\\", got \"\n> -                               << *target;\n> +                               << (target ? target->c_str() : \"(unknown)\");\n>                 return -EINVAL;\n>         }\n>\n> --\n> 2.49.0","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 4D6EAC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Apr 2025 09:05:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A589A6897A;\n\tWed,  2 Apr 2025 11:05:11 +0200 (CEST)","from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com\n\t[IPv6:2607:f8b0:4864:20::b2b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6966D68979\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Apr 2025 11:05:09 +0200 (CEST)","by mail-yb1-xb2b.google.com with SMTP id\n\t3f1490d57ef6-e6b78b80393so679112276.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 02 Apr 2025 02:05:09 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"avyDO/u7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1743584708; x=1744189508;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=LaiZCUEml18h+0ylswrd7L+yGh7eQx+oMVlVxuOAz/0=;\n\tb=avyDO/u7W/4uEKKLdsJwRv1VRKpIi55leRK0WGqmcEs6TAX39sNZzmy2GtfLNbe4p4\n\tK0H8pnVEGr45VSwXGPw1fQJrO8PLZ+LbOL4CRfdZUlUATumpmUM31oIJTZyNjrjsaXqx\n\tajycSK1N4vqVkBzDnnb8CojeWXEh7bn6r/XYvjpF+PIsBLuz1d6LRaQTBwz5Ct3I7l5R\n\tOPNGkD8oELS0BP1i9O98vm6WWCB+aCMN9QcTSktup7R/ts4bJ4HAStXHkZbRu8yZcq2a\n\tpPEKYZnZwH+/x5a0CWMkc7ewSdGA5KiFhqHnFodNJhbpKON7YEK7VrCyURP91cMHDSjM\n\tkbqA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1743584708; x=1744189508;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=LaiZCUEml18h+0ylswrd7L+yGh7eQx+oMVlVxuOAz/0=;\n\tb=gFjCwZKaZCyyWnLp3CKO9dwwuSLyngZg0X6LGQ43GQwD1DxCJ4nRVEl0Etf2CXb2WS\n\tXqZWcBJK6boGl/iAIgQRGkBl8ZqZdrKiMhOumna9SrLwGriS+LV/blczTtSYOZruyvN+\n\tyLTEugAXqNF76//leBGZGshj3Ju0zZ2VCAljl5CQq4aGXB1Tz8Mh1ryMXXyCQdAwD7Zy\n\t+7sFNZuQyQ2W7Zauc8bHWdcVj70LqbhMDAm5wE+5WI5tILm52JqK5rjCR4xLrPADCMTo\n\tW9eOls5A7/b54jnOdx+9O9AYutS5xtMzzsOzfwbdIBMj388796tip7xon66Ay1N6c56A\n\tV41w==","X-Gm-Message-State":"AOJu0Yw3k2DdTroBAre2MUQLu+jhQKFdRrenQE1KFzVsHL3TZTgfnQmQ\n\tCnh3YXL03IKTx22DXoa57WOxLN+BmPougavO+pGQvaBY3ZbQ3XiGMqRTwKCF2oBI2WbQ3CiuPk9\n\tsc0KcgGpUigu5uEhR/X7jafaZjEvKlai1Mh2cP+UoRygcVNC4xAU=","X-Gm-Gg":"ASbGncvoyPKe2CEfvcQtYBfhLXrDGbjqTHy8ZWGS6WspbXE/o0n0+1jlHWW/44uqAkd\n\t5yWwedVi+auSDfCfB/iMtInhCgADutvVdchDSsOA5JxAkM+ORJGWoG/Sk6B5T/68HI6hVhkzqcW\n\tzpbCHhj0tSzfJF6agrk5pD7pXLDg==","X-Google-Smtp-Source":"AGHT+IE7/jSzvDpMbWUo0QG8XBj9LKc1609IsIc5pi5XKclkPqqHfw1xxHhZmN4l9+3DFAC+pDzs1HTyyxBgFeRmsy4=","X-Received":"by 2002:a05:690c:c:b0:6ef:5c7c:839a with SMTP id\n\t00721157ae682-702570f1295mr94429797b3.3.1743584708047;\n\tWed, 02 Apr 2025 02:05:08 -0700 (PDT)","MIME-Version":"1.0","References":"<20250401131105.748536-1-barnabas.pocze@ideasonboard.com>","In-Reply-To":"<20250401131105.748536-1-barnabas.pocze@ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 2 Apr 2025 10:04:32 +0100","X-Gm-Features":"AQ5f1Jo-VqInGMNVtpqGChfjxaPCJ4dz5fSjEuoB2qTy38NLxjF_aXnA_UfM6bY","Message-ID":"<CAEmqJPqfFEzFCZBNQsov+th6rhfuuBfJ-Sjc=NaEhs6bdYOw+A@mail.gmail.com>","Subject":"Re: [PATCH v2] pipeline: rpi: Fix potential empty optional read","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","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>"}},{"id":33884,"web_url":"https://patchwork.libcamera.org/comment/33884/","msgid":"<a164cc81-b502-46a0-af88-611afea6a83b@ideasonboard.com>","date":"2025-04-02T09:12:46","subject":"Re: [PATCH v2] pipeline: rpi: Fix potential empty optional read","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n\n2025. 04. 02. 11:04 keltezéssel, Naushir Patuck írta:\n> Hi Barnabás,\n> \n> Thank you for this fix\n> \n> On Tue, 1 Apr 2025 at 14:11, Barnabás Pőcze\n> <barnabas.pocze@ideasonboard.com> wrote:\n>>\n>> If `!target`, then `*target` is undefined behaviour, so check if the optional\n>> is empty when printing the error message. Simplify the check as well.\n>>\n>> Fixes: 6c71ee1f153051 (\"pipeline: raspberrypi: Introduce PipelineHandlerBase class\")\n>> Fixes: 841ef2b4bb08ba (\"pipeline: rpi: Add support for Raspberry Pi 5\")\n>> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>> ---\n>> Changes in v2:\n>>    * fix the same issue in pisp as well\n>> ---\n>>   src/libcamera/pipeline/rpi/pisp/pisp.cpp | 4 ++--\n>>   src/libcamera/pipeline/rpi/vc4/vc4.cpp   | 4 ++--\n>>   2 files changed, 4 insertions(+), 4 deletions(-)\n>>\n>> diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n>> index 42ca7c80b..91e7f4c94 100644\n>> --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n>> +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n>> @@ -1350,9 +1350,9 @@ int PiSPCameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject>\n>>          }\n>>\n>>          std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n>> -       if (!target || *target != \"pisp\") {\n>> +       if (target != \"pisp\") {\n> \n> I'm a bit curious about this change.\n> \n> Should we keep the if (!target || ...) test?  If \"target\" key is not\n> present in the yaml, the optional will be a nullopt, and we then deref\n> for the string comparison.  Does this work out correctly by compiler\n> magic, or is it undefined behavior?  Ditto for the change below.\n\nRelational operators are all well-defined for `std::optional` in every state.\nSo `==`, `!=`, `<`, etc. can be safely used on an empty optional. Naturally,\nan empty optional only compares equal to another empty optional, so if `target`\nis empty, then `target != \"pisp\"` is true.\n\nSee https://en.cppreference.com/w/cpp/utility/optional/operator_cmp:\n\n\"\"\"\ntemplate< class T, class U >\nconstexpr bool operator!=( const optional<T>& opt, const U& value );\t(23) \t(since C++17)\n\n[...]\n\n21-33) Compares `opt` with a value. The values are compared (using the corresponding operator of T)\n        only if `opt` contains a value. Otherwise, `opt` is considered less than `value`.\n\"\"\"\n\nRegards,\nBarnabás Pőcze\n\n> \n> Regards,\n> Naush\n> \n> \n>>                  LOG(RPI, Error) << \"Unexpected target reported: expected \\\"pisp\\\", got \"\n>> -                               << *target;\n>> +                               << (target ? target->c_str() : \"(unknown)\");\n>>                  return -EINVAL;\n>>          }\n>>\n>> diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n>> index fd8d84b14..fe910bdf2 100644\n>> --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n>> +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n>> @@ -510,9 +510,9 @@ int Vc4CameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject> &\n>>          }\n>>\n>>          std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n>> -       if (!target || *target != \"bcm2835\") {\n>> +       if (target != \"bcm2835\") {\n>>                  LOG(RPI, Error) << \"Unexpected target reported: expected \\\"bcm2835\\\", got \"\n>> -                               << *target;\n>> +                               << (target ? target->c_str() : \"(unknown)\");\n>>                  return -EINVAL;\n>>          }\n>>\n>> --\n>> 2.49.0","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 59B32C3213\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Apr 2025 09:12:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 610AC6897A;\n\tWed,  2 Apr 2025 11:12:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA0BB68979\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Apr 2025 11:12:50 +0200 (CEST)","from [192.168.33.20] (185.221.143.221.nat.pool.zt.hu\n\t[185.221.143.221])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A2D276A2;\n\tWed,  2 Apr 2025 11:10:57 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"J03dJQbU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1743585057;\n\tbh=3Vuep811R5xor4XYF+pvAbzuQNijy2u+6L+QPsV9xHg=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=J03dJQbU0UvYF/79xHPgMfGniyLwB3nADbLom7x4EGnoHib+uuvw6ZP0NqTIhBj73\n\tegW6mH/Hoe+ZBxo0EAdkTwT52VTiNPOOC3KV9nP81lU1qeTtDXe4VL81Pvr9c+iPBA\n\tyZ5YA+x+MukNIcv5rPCSYIguhXe+KvcqhNR2kvqw=","Message-ID":"<a164cc81-b502-46a0-af88-611afea6a83b@ideasonboard.com>","Date":"Wed, 2 Apr 2025 11:12:46 +0200","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2] pipeline: rpi: Fix potential empty optional read","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20250401131105.748536-1-barnabas.pocze@ideasonboard.com>\n\t<CAEmqJPqfFEzFCZBNQsov+th6rhfuuBfJ-Sjc=NaEhs6bdYOw+A@mail.gmail.com>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<CAEmqJPqfFEzFCZBNQsov+th6rhfuuBfJ-Sjc=NaEhs6bdYOw+A@mail.gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","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>"}},{"id":33885,"web_url":"https://patchwork.libcamera.org/comment/33885/","msgid":"<CAEmqJPqny50P9DHfJPUzTSXhQxKih9PMu0LL1z7S0YJ6tJ8rKg@mail.gmail.com>","date":"2025-04-02T09:16:01","subject":"Re: [PATCH v2] pipeline: rpi: Fix potential empty optional read","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"On Wed, 2 Apr 2025 at 10:12, Barnabás Pőcze\n<barnabas.pocze@ideasonboard.com> wrote:\n>\n> Hi\n>\n>\n> 2025. 04. 02. 11:04 keltezéssel, Naushir Patuck írta:\n> > Hi Barnabás,\n> >\n> > Thank you for this fix\n> >\n> > On Tue, 1 Apr 2025 at 14:11, Barnabás Pőcze\n> > <barnabas.pocze@ideasonboard.com> wrote:\n> >>\n> >> If `!target`, then `*target` is undefined behaviour, so check if the optional\n> >> is empty when printing the error message. Simplify the check as well.\n> >>\n> >> Fixes: 6c71ee1f153051 (\"pipeline: raspberrypi: Introduce PipelineHandlerBase class\")\n> >> Fixes: 841ef2b4bb08ba (\"pipeline: rpi: Add support for Raspberry Pi 5\")\n> >> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> >> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >> ---\n> >> Changes in v2:\n> >>    * fix the same issue in pisp as well\n> >> ---\n> >>   src/libcamera/pipeline/rpi/pisp/pisp.cpp | 4 ++--\n> >>   src/libcamera/pipeline/rpi/vc4/vc4.cpp   | 4 ++--\n> >>   2 files changed, 4 insertions(+), 4 deletions(-)\n> >>\n> >> diff --git a/src/libcamera/pipeline/rpi/pisp/pisp.cpp b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> >> index 42ca7c80b..91e7f4c94 100644\n> >> --- a/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> >> +++ b/src/libcamera/pipeline/rpi/pisp/pisp.cpp\n> >> @@ -1350,9 +1350,9 @@ int PiSPCameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject>\n> >>          }\n> >>\n> >>          std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n> >> -       if (!target || *target != \"pisp\") {\n> >> +       if (target != \"pisp\") {\n> >\n> > I'm a bit curious about this change.\n> >\n> > Should we keep the if (!target || ...) test?  If \"target\" key is not\n> > present in the yaml, the optional will be a nullopt, and we then deref\n> > for the string comparison.  Does this work out correctly by compiler\n> > magic, or is it undefined behavior?  Ditto for the change below.\n>\n> Relational operators are all well-defined for `std::optional` in every state.\n> So `==`, `!=`, `<`, etc. can be safely used on an empty optional. Naturally,\n> an empty optional only compares equal to another empty optional, so if `target`\n> is empty, then `target != \"pisp\"` is true.\n>\n> See https://en.cppreference.com/w/cpp/utility/optional/operator_cmp:\n>\n> \"\"\"\n> template< class T, class U >\n> constexpr bool operator!=( const optional<T>& opt, const U& value );    (23)    (since C++17)\n>\n> [...]\n>\n> 21-33) Compares `opt` with a value. The values are compared (using the corresponding operator of T)\n>         only if `opt` contains a value. Otherwise, `opt` is considered less than `value`.\n> \"\"\"\n\nThanks for clarifying!  Change looks good to me:\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n>\n> Regards,\n> Barnabás Pőcze\n>\n> >\n> > Regards,\n> > Naush\n> >\n> >\n> >>                  LOG(RPI, Error) << \"Unexpected target reported: expected \\\"pisp\\\", got \"\n> >> -                               << *target;\n> >> +                               << (target ? target->c_str() : \"(unknown)\");\n> >>                  return -EINVAL;\n> >>          }\n> >>\n> >> diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> >> index fd8d84b14..fe910bdf2 100644\n> >> --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> >> +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp\n> >> @@ -510,9 +510,9 @@ int Vc4CameraData::platformPipelineConfigure(const std::unique_ptr<YamlObject> &\n> >>          }\n> >>\n> >>          std::optional<std::string> target = (*root)[\"target\"].get<std::string>();\n> >> -       if (!target || *target != \"bcm2835\") {\n> >> +       if (target != \"bcm2835\") {\n> >>                  LOG(RPI, Error) << \"Unexpected target reported: expected \\\"bcm2835\\\", got \"\n> >> -                               << *target;\n> >> +                               << (target ? target->c_str() : \"(unknown)\");\n> >>                  return -EINVAL;\n> >>          }\n> >>\n> >> --\n> >> 2.49.0\n>","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 67881C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  2 Apr 2025 09:16:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8D4D768979;\n\tWed,  2 Apr 2025 11:16:40 +0200 (CEST)","from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com\n\t[IPv6:2607:f8b0:4864:20::b34])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C59EE68979\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  2 Apr 2025 11:16:38 +0200 (CEST)","by mail-yb1-xb34.google.com with SMTP id\n\t3f1490d57ef6-e636630da89so868295276.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 02 Apr 2025 02:16:38 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"kz903yUc\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1743585397; x=1744190197;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=gloVjPj1MbRqf+7Tjg64RKrCRtI/UK4TSVCB9STTO7A=;\n\tb=kz903yUc+xY76E5qOBBMXISz8BxifSt4hmXEJWTeDKikD2z13bBlv43Li56q/EbBAv\n\tB2hd+2XHqHfld7NUgMnNjOSaGvnsufk4/rF5DgFec4AffqS0Jyz475F3rlGuiYleeJ5A\n\tCqTHNgfka3nWoGta6KrTW8QYOAwe3QkVd+rGvAI3p0Xd/AVSy+GE6FiIlAaBX922/Aml\n\tzGE8nWb+Ijx3oX7D3L1O82ccU7psbd7FA9rjZ9hFYixcOp1pYjkRkdwiKGFBtjyiZT3D\n\tzpXdIOUu8YdzrXwC5eUb0/nVBX9WzVcNHKlzBqIHZcF03jrmGXhXODT8/kOEVHBc6EBu\n\te9NA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1743585397; x=1744190197;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=gloVjPj1MbRqf+7Tjg64RKrCRtI/UK4TSVCB9STTO7A=;\n\tb=t2xmnO4DBsXCjhj/JI8+Ej8pVUIoRWSsf8+WX0dTx9THdsxiC6AS6Ybj2dSZaM/vgT\n\tGLZnAck37uTeUjEaRd3GCkZhMQ5ctDaIzZytFRqrUFi5GDfeYSumMdP/ye4RbEA9TV0K\n\tCgpGAZR8x8+9p3Fo/7VKIp7F79QXiuqd8eXokq0vpakVxY0BW2BZK28p9mAqy/kt/+Bv\n\tl9OkTxhPHxaww6pn4tgSo5AbB8VjP4iZhm2duvSVtklkJDpXVNfYFhpFq7w+EKl9I31p\n\tC90hwv0PU1ZF5VsP8X7Ac50ovN8ExrURvWIkQ3ociJjeMtU1bjEEyrxk0jYVRiiY5812\n\tTW9g==","X-Gm-Message-State":"AOJu0Yy1OE9pVvWJJbP0KsjXcI3zzXlZ0X2KQCG9SkwQOQN309PTwUz0\n\t/a8yGdOBwXHE+A5qwZ9vOJ0KNhh4N4tav3UeLrOkqyk8w0wevl8XHG9q6piIwRv9aI0jKpj84Aw\n\tdAPa4KruiHFJmoJwfeijnd1LDcrdEfAaQ3dlnhtn0XowHrqvmtQk=","X-Gm-Gg":"ASbGnctraxRgv0AIiz19YdPzCAlQxXhICy0+6KcuSbtpci9gmywXVhYDn69kg1+6ufe\n\tLteAvCwHjaaXT6p2/x53/54Q4lIrqGhf3RUw+so2K1ZmaiJWLK0xbsBm4qCPFdWmRF6vD/jZF5+\n\tQRYEgXlOYvYeNCljz3dXqyoirNWw==","X-Google-Smtp-Source":"AGHT+IHJhv92I7r+m5t0F1Vosg3FlFaW5kBH32rcIbz+Jx15hduuIvYKANTnvS54KAhf37xzaSP6TB6nZgD60jKF8IE=","X-Received":"by 2002:a05:690c:f86:b0:6f5:be28:632c with SMTP id\n\t00721157ae682-703a727a8bamr35479107b3.2.1743585397601;\n\tWed, 02 Apr 2025 02:16:37 -0700 (PDT)","MIME-Version":"1.0","References":"<20250401131105.748536-1-barnabas.pocze@ideasonboard.com>\n\t<CAEmqJPqfFEzFCZBNQsov+th6rhfuuBfJ-Sjc=NaEhs6bdYOw+A@mail.gmail.com>\n\t<a164cc81-b502-46a0-af88-611afea6a83b@ideasonboard.com>","In-Reply-To":"<a164cc81-b502-46a0-af88-611afea6a83b@ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 2 Apr 2025 10:16:01 +0100","X-Gm-Features":"AQ5f1JrWG6VeaOScEoZlzTl7arkYkWfw1BX1IVGpxzquE7z7qU9sJyIch9Ja6tI","Message-ID":"<CAEmqJPqny50P9DHfJPUzTSXhQxKih9PMu0LL1z7S0YJ6tJ8rKg@mail.gmail.com>","Subject":"Re: [PATCH v2] pipeline: rpi: Fix potential empty optional read","To":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","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>"}}]