[{"id":13198,"web_url":"https://patchwork.libcamera.org/comment/13198/","msgid":"<20201014122522.3lsol6a6z3h2wyik@oden.dyn.berto.se>","date":"2020-10-14T12:25:22","subject":"Re: [libcamera-devel] [PATCH 04/10] libcamera: pipeline: Prevent\n\tvariable aliasing","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Kieran,\n\nOn 2020-10-13 16:12:35 +0100, Kieran Bingham wrote:\n> Remove variable aliasing within the pipeline handler implementations.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 6 +++---\n>  src/libcamera/pipeline/simple/converter.cpp        | 8 ++++----\n>  src/libcamera/pipeline/simple/simple.cpp           | 4 ++--\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       | 4 ++--\n>  4 files changed, 11 insertions(+), 11 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 26dbd2573e04..85e0a1f26ab6 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -512,9 +512,9 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t/* Translate the V4L2PixelFormat to PixelFormat. */\n>  \t\tstd::map<PixelFormat, std::vector<SizeRange>> deviceFormats;\n>  \t\tfor (const auto &format : fmts) {\n> -\t\t\tPixelFormat pixelFormat = format.first.toPixelFormat();\n> -\t\t\tif (pixelFormat.isValid())\n> -\t\t\t\tdeviceFormats[pixelFormat] = format.second;\n> +\t\t\tPixelFormat pf = format.first.toPixelFormat();\n> +\t\t\tif (pf.isValid())\n> +\t\t\t\tdeviceFormats[pf] = format.second;\n>  \t\t}\n>  \n>  \t\t/* Add the stream format based on the device node used for the use case. */\n> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> index 75fb297ebd58..2b541cd2bb3f 100644\n> --- a/src/libcamera/pipeline/simple/converter.cpp\n> +++ b/src/libcamera/pipeline/simple/converter.cpp\n> @@ -72,11 +72,11 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n>  \t * Set the format on the input side (V4L2 output) of the converter to\n>  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> -\tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> -\tformat.size = { 1, 1 };\n> +\tV4L2DeviceFormat v4l2Format;\n> +\tv4l2Format.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> +\tv4l2Format.size = { 1, 1 };\n>  \n> -\tint ret = m2m_->output()->setFormat(&format);\n> +\tint ret = m2m_->output()->setFormat(&v4l2Format);\n>  \tif (ret < 0) {\n>  \t\tLOG(SimplePipeline, Error)\n>  \t\t\t<< \"Failed to set format: \" << strerror(-ret);\n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 7adb17e2d1db..999c44515023 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -314,8 +314,8 @@ int SimpleCameraData::init()\n>  \n>  \t\t\tconfig.outputSizes = converter->sizes(format.size);\n>  \n> -\t\t\tfor (PixelFormat format : converter->formats(pixelFormat))\n> -\t\t\t\tformats_[format] = config;\n> +\t\t\tfor (PixelFormat fmt : converter->formats(pixelFormat))\n> +\t\t\t\tformats_[fmt] = config;\n>  \t\t}\n>  \t}\n>  \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index 8ec0dac1e689..54ba1b87bb3e 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -490,8 +490,8 @@ int UVCCameraData::init(MediaDevice *media)\n>  \t/* Locate and initialise the camera data with the default video node. */\n>  \tconst std::vector<MediaEntity *> &entities = media->entities();\n>  \tauto entity = std::find_if(entities.begin(), entities.end(),\n> -\t\t\t\t   [](MediaEntity *entity) {\n> -\t\t\t\t\t   return entity->flags() & MEDIA_ENT_FL_DEFAULT;\n> +\t\t\t\t   [](MediaEntity *e) {\n> +\t\t\t\t\t   return e->flags() & MEDIA_ENT_FL_DEFAULT;\n>  \t\t\t\t   });\n>  \tif (entity == entities.end()) {\n>  \t\tLOG(UVC, Error) << \"Could not find a default video device\";\n> -- \n> 2.25.1\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 7E6A4BEEDF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 14 Oct 2020 12:25:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F1BC760E79;\n\tWed, 14 Oct 2020 14:25:24 +0200 (CEST)","from mail-lf1-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3B4AB60354\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Oct 2020 14:25:24 +0200 (CEST)","by mail-lf1-x141.google.com with SMTP id d24so3445461lfa.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Oct 2020 05:25:24 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tt5sm1145945ljc.124.2020.10.14.05.25.22\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 14 Oct 2020 05:25:22 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"LiCASr50\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=gPk0B8/0c/O92dz1EM0kcP7AljHdbgXEpzPQ2yKty+g=;\n\tb=LiCASr50VaEBzLDEgSNxgXqCe6RO8PHuaMeabxSGugF0Br6bv5x8yc1aoBiJvbM/Mb\n\tIsMAT2CEiWL6syZ7+meNcHSYpT6xSAG2+bETkFCtJQsNJcNtj35z64/G/0Xfh+A5M+zt\n\tAY/Yr4XcLzeZi59xmJL8hhVDdvPM6z1kMBDV8Jkv5MyJLlp4moo5lS2aMuVZ8YMpD7EB\n\tVe25vSjzkqJmElh61ezItgaWpJakn8lSKallKuvp4bKFHlKkJI5TqMH32iewD4ra58mV\n\tDLL4dY+1ZZlhlajGEWPJtu3Wxl7hfqoM3l7MfxPuKIQJPZSApSkw+ewjxHQncARQS1D/\n\t3BCw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=gPk0B8/0c/O92dz1EM0kcP7AljHdbgXEpzPQ2yKty+g=;\n\tb=qgUu8JFABet0UmZ/HW0jwFbxgABx7rru+FoFPo6HkwtCs3XS/gDo3p3YgPltqhS93P\n\tUB5roEALpgw85VcCdJ5wLcsDzsuqtGx3m5a4IXZ8cLtzZKEF/tzQYjkteDSeU3pACTvf\n\tdTja8uZKhhe7KJ2OQUKt58g7HIhZ04h0YtMBlBOWJWupT7oWqdb/JedGr63354tkBPUL\n\tiEt4LoP6I1uf/6mnFQN3obM41K+lExtoZCambeAdeFdQuka7gVjRYjQkBobUEtLl8WXX\n\tnJlX8Zcln8z/ny51zBTaJf8sJ4q6KdlVIe76pWYJV5QvX3cmdDWKXh7PGr3JbCklAjwy\n\tauSg==","X-Gm-Message-State":"AOAM530vbwm5//GMUyUJ0JCQ0GDVFNc0BdKK8mytYUUSga/ND8ZEnVeK\n\tdHrpV95wej3pAd9WgHSZ7hz+2ZhUJKWCdA==","X-Google-Smtp-Source":"ABdhPJxsXhip6vWha3jyN5UX4YKaszkOLKbjdM7/vGsMvcEM6rU1T2QYIyCFVMSyPfV+28xeh7i9yw==","X-Received":"by 2002:ac2:58f8:: with SMTP id\n\tv24mr1187858lfo.520.1602678323547; \n\tWed, 14 Oct 2020 05:25:23 -0700 (PDT)","Date":"Wed, 14 Oct 2020 14:25:22 +0200","From":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20201014122522.3lsol6a6z3h2wyik@oden.dyn.berto.se>","References":"<20201013151241.3557005-1-kieran.bingham@ideasonboard.com>\n\t<20201013151241.3557005-5-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201013151241.3557005-5-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 04/10] libcamera: pipeline: Prevent\n\tvariable aliasing","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":13211,"web_url":"https://patchwork.libcamera.org/comment/13211/","msgid":"<20201015132800.GB3957@pendragon.ideasonboard.com>","date":"2020-10-15T13:28:00","subject":"Re: [libcamera-devel] [PATCH 04/10] libcamera: pipeline: Prevent\n\tvariable aliasing","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Tue, Oct 13, 2020 at 04:12:35PM +0100, Kieran Bingham wrote:\n> Remove variable aliasing within the pipeline handler implementations.\n> \n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 6 +++---\n>  src/libcamera/pipeline/simple/converter.cpp        | 8 ++++----\n>  src/libcamera/pipeline/simple/simple.cpp           | 4 ++--\n>  src/libcamera/pipeline/uvcvideo/uvcvideo.cpp       | 4 ++--\n>  4 files changed, 11 insertions(+), 11 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 26dbd2573e04..85e0a1f26ab6 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -512,9 +512,9 @@ CameraConfiguration *PipelineHandlerRPi::generateConfiguration(Camera *camera,\n>  \t\t/* Translate the V4L2PixelFormat to PixelFormat. */\n>  \t\tstd::map<PixelFormat, std::vector<SizeRange>> deviceFormats;\n>  \t\tfor (const auto &format : fmts) {\n> -\t\t\tPixelFormat pixelFormat = format.first.toPixelFormat();\n> -\t\t\tif (pixelFormat.isValid())\n> -\t\t\t\tdeviceFormats[pixelFormat] = format.second;\n> +\t\t\tPixelFormat pf = format.first.toPixelFormat();\n> +\t\t\tif (pf.isValid())\n> +\t\t\t\tdeviceFormats[pf] = format.second;\n>  \t\t}\n>  \n>  \t\t/* Add the stream format based on the device node used for the use case. */\n> diff --git a/src/libcamera/pipeline/simple/converter.cpp b/src/libcamera/pipeline/simple/converter.cpp\n> index 75fb297ebd58..2b541cd2bb3f 100644\n> --- a/src/libcamera/pipeline/simple/converter.cpp\n> +++ b/src/libcamera/pipeline/simple/converter.cpp\n> @@ -72,11 +72,11 @@ std::vector<PixelFormat> SimpleConverter::formats(PixelFormat input)\n>  \t * Set the format on the input side (V4L2 output) of the converter to\n>  \t * enumerate the conversion capabilities on its output (V4L2 capture).\n>  \t */\n> -\tV4L2DeviceFormat format;\n> -\tformat.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> -\tformat.size = { 1, 1 };\n> +\tV4L2DeviceFormat v4l2Format;\n> +\tv4l2Format.fourcc = m2m_->output()->toV4L2PixelFormat(input);\n> +\tv4l2Format.size = { 1, 1 };\n>  \n> -\tint ret = m2m_->output()->setFormat(&format);\n> +\tint ret = m2m_->output()->setFormat(&v4l2Format);\n>  \tif (ret < 0) {\n>  \t\tLOG(SimplePipeline, Error)\n>  \t\t\t<< \"Failed to set format: \" << strerror(-ret);\n> diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\n> index 7adb17e2d1db..999c44515023 100644\n> --- a/src/libcamera/pipeline/simple/simple.cpp\n> +++ b/src/libcamera/pipeline/simple/simple.cpp\n> @@ -314,8 +314,8 @@ int SimpleCameraData::init()\n>  \n>  \t\t\tconfig.outputSizes = converter->sizes(format.size);\n>  \n> -\t\t\tfor (PixelFormat format : converter->formats(pixelFormat))\n> -\t\t\t\tformats_[format] = config;\n> +\t\t\tfor (PixelFormat fmt : converter->formats(pixelFormat))\n> +\t\t\t\tformats_[fmt] = config;\n>  \t\t}\n>  \t}\n>  \n> diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> index 8ec0dac1e689..54ba1b87bb3e 100644\n> --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n> @@ -490,8 +490,8 @@ int UVCCameraData::init(MediaDevice *media)\n>  \t/* Locate and initialise the camera data with the default video node. */\n>  \tconst std::vector<MediaEntity *> &entities = media->entities();\n>  \tauto entity = std::find_if(entities.begin(), entities.end(),\n> -\t\t\t\t   [](MediaEntity *entity) {\n> -\t\t\t\t\t   return entity->flags() & MEDIA_ENT_FL_DEFAULT;\n> +\t\t\t\t   [](MediaEntity *e) {\n> +\t\t\t\t\t   return e->flags() & MEDIA_ENT_FL_DEFAULT;\n>  \t\t\t\t   });\n>  \tif (entity == entities.end()) {\n>  \t\tLOG(UVC, Error) << \"Could not find a default video device\";","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 DCF7BBE174\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Oct 2020 13:28:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6447560E36;\n\tThu, 15 Oct 2020 15:28:49 +0200 (CEST)","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 A95EA605BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Oct 2020 15:28:47 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 16711556;\n\tThu, 15 Oct 2020 15:28:47 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"kGTFUCOV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1602768527;\n\tbh=scNFDsJfgoG1kmH7K8/Wk/8F7eWudvoI0ex0Ienrx6s=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=kGTFUCOV7I/1PjpoqXOpU0EfAeMpkihryAf0NuQIS2qH3cK8R8l7pUdf9mpGhu01Z\n\tiS937NLBUM6dQs89QrLn2AI3YHR4zd0ZalUvkqS04VEKOMScnTcWKPJy3E2mLwrskC\n\tZ1K2KhFtc2izBJSUuhuOT7J9IVlgij7kiakuCrdY=","Date":"Thu, 15 Oct 2020 16:28:00 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<20201015132800.GB3957@pendragon.ideasonboard.com>","References":"<20201013151241.3557005-1-kieran.bingham@ideasonboard.com>\n\t<20201013151241.3557005-5-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201013151241.3557005-5-kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 04/10] libcamera: pipeline: Prevent\n\tvariable aliasing","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]