[{"id":19021,"web_url":"https://patchwork.libcamera.org/comment/19021/","msgid":"<YSQ8V6o5vmC+pjAA@pendragon.ideasonboard.com>","date":"2021-08-24T00:24:55","subject":"Re: [libcamera-devel] [RFC PATCH v2 10/10] libcamera: framebuffer:\n\tAdd assertion to detect offset is unfilled","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Mon, Aug 23, 2021 at 10:12:21PM +0900, Hirokazu Honda wrote:\n> The offset variable is introduced to FrameBuffer::Plane. In order to\n> detect that the plane is used while the offset is not set, this adds\n> the assertion to FrameBuffer::planes(). It should be removed in the\n> future.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n> ---\n>  include/libcamera/framebuffer.h | 13 +++++++++++--\n>  src/libcamera/framebuffer.cpp   |  4 ++++\n>  2 files changed, 15 insertions(+), 2 deletions(-)\n> \n> diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h\n> index 5de3c744..d5aeff00 100644\n> --- a/include/libcamera/framebuffer.h\n> +++ b/include/libcamera/framebuffer.h\n> @@ -7,6 +7,8 @@\n>  #ifndef __LIBCAMERA_FRAMEBUFFER_H__\n>  #define __LIBCAMERA_FRAMEBUFFER_H__\n>  \n> +#include <assert.h>\n> +#include <limits>\n>  #include <stdint.h>\n>  #include <vector>\n>  \n> @@ -41,14 +43,21 @@ class FrameBuffer final : public Extensible\n>  \n>  public:\n>  \tstruct Plane {\n> +\t\tstatic constexpr unsigned int kInvalidOffset = std::numeric_limits<unsigned int>::max();\n>  \t\tFileDescriptor fd;\n> -\t\tunsigned int offset;\n> +\t\tunsigned int offset = kInvalidOffset;\n>  \t\tunsigned int length;\n>  \t};\n>  \n>  \tFrameBuffer(const std::vector<Plane> &planes, unsigned int cookie = 0);\n>  \n> -\tconst std::vector<Plane> &planes() const { return planes_; }\n> +\tconst std::vector<Plane> &planes() const\n> +\t{\n> +\t\t/* \\todo Remove the assertions after sufficient testing */\n> +\t\tfor (const auto &plane : planes_)\n> +\t\t\tassert(plane.offset != Plane::kInvalidOffset);\n> +\t\treturn planes_;\n> +\t}\n>  \n>  \tRequest *request() const;\n>  \tconst FrameMetadata &metadata() const { return metadata_; }\n> diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp\n> index e9467aa0..5f612ecd 100644\n> --- a/src/libcamera/framebuffer.cpp\n> +++ b/src/libcamera/framebuffer.cpp\n> @@ -165,6 +165,10 @@ FrameBuffer::Private::Private()\n>   * multiple dmabufs, based on the camera requirements.\n>   */\n>  \n> +/**\n> + * \\var FrameBuffer::Plane::kInvalidOffset\n> + * \\brief The invalid offset value\n\n\"Invalid offset value, to identify uninitialized planes\"\n\n> + */\n\nBlank line.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  /**\n>   * \\var FrameBuffer::Plane::fd\n>   * \\brief The dmabuf file descriptor","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 36BB8BD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 24 Aug 2021 00:25:08 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B0185688A3;\n\tTue, 24 Aug 2021 02:25:07 +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 B08E868890\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 24 Aug 2021 02:25:05 +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 2550C2A5;\n\tTue, 24 Aug 2021 02:25:05 +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=\"Ir5iKOXP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1629764705;\n\tbh=VFVUpdH40gx6R5UDTwrMzyXVpGk0ydJOxDAolmlTjp8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Ir5iKOXPEGgOEjRT/c5h0p47asniMA0blLYb2gtU2N1rFdusGrfVtKQNm/BWbnrfc\n\t1GSXixsdqvdvt20Y/fkSvwgGula33ZNQuajscffdeDJU6ciXA5E241xVGMH+RjIXe+\n\t/B1tGXOZPkpg2AiofvfLbtOu++bhaZT4iwX1WO2Q=","Date":"Tue, 24 Aug 2021 03:24:55 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YSQ8V6o5vmC+pjAA@pendragon.ideasonboard.com>","References":"<20210823131221.1034059-1-hiroh@chromium.org>\n\t<20210823131221.1034059-11-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210823131221.1034059-11-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [RFC PATCH v2 10/10] libcamera: framebuffer:\n\tAdd assertion to detect offset is unfilled","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@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]