[{"id":3524,"web_url":"https://patchwork.libcamera.org/comment/3524/","msgid":"<20200120110917.pzgijb4e6dqk2wcc@uno.localdomain>","date":"2020-01-20T11:09:17","subject":"Re: [libcamera-devel] [PATCH 01/19] test: buffer_import: Propagate\n\tstatus code from buffer allocation","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Mon, Jan 20, 2020 at 02:24:19AM +0200, Laurent Pinchart wrote:\n> The BufferSource::allocate() return value isn't propagated correctly,\n> resulting in a test failure when the test should be skipped due to a\n> missing vivid device. Fix it.\n>\n> While at it, return valid status codes from BufferSource::allocate() in\n> all error cases, with proper diagnostic messages.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  test/camera/buffer_import.cpp | 18 +++++++++++++-----\n>  1 file changed, 13 insertions(+), 5 deletions(-)\n>\n> diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> index e7048335e031..16bfca9beeea 100644\n> --- a/test/camera/buffer_import.cpp\n> +++ b/test/camera/buffer_import.cpp\n> @@ -89,15 +89,23 @@ public:\n>  \t\tret = video_->getFormat(&format);\n>  \t\tif (ret) {\n>  \t\t\tstd::cout << \"Failed to get format on output device\" << std::endl;\n> -\t\t\treturn ret;\n> +\t\t\treturn TestFail;\n\nNitpicking, but we now have 2 occurrences of\n\n                ret = video->doSomething()\n                if (ret) {\n\n                }\n\nWhere the value of ret is actually later ignored.\n\n>  \t\t}\n>\n>  \t\tformat.size = config.size;\n>  \t\tformat.fourcc = V4L2VideoDevice::toV4L2Fourcc(config.pixelFormat, false);\n> -\t\tif (video_->setFormat(&format))\n> +\t\tif (video_->setFormat(&format)) {\n\nI would unify all three calls here to this format\n\n                if (video_->doSomething()) {\n\n                }\nand remove ret\n\nWith or without this considered\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n> +\t\t\tstd::cout << \"Failed to set format on output device\" << std::endl;\n>  \t\t\treturn TestFail;\n> +\t\t}\n>\n> -\t\treturn video_->exportBuffers(config.bufferCount, &buffers_);\n> +\t\tret = video_->exportBuffers(config.bufferCount, &buffers_);\n> +\t\tif (ret < 0) {\n> +\t\t\tstd::cout << \"Failed to export buffers\" << std::endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n>  \t}\n>\n>  \tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers()\n> @@ -178,8 +186,8 @@ protected:\n>\n>  \t\tBufferSource source;\n>  \t\tint ret = source.allocate(cfg);\n> -\t\tif (ret < 0)\n> -\t\t\treturn TestFail;\n> +\t\tif (ret != TestPass)\n> +\t\t\treturn ret;\n>\n>  \t\tstd::vector<Request *> requests;\n>  \t\tfor (const std::unique_ptr<FrameBuffer> &buffer : source.buffers()) {\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 74795600F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 12:06:46 +0100 (CET)","from uno.localdomain (93-34-114-233.ip49.fastwebnet.it\n\t[93.34.114.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id F246C10000C;\n\tMon, 20 Jan 2020 11:06:45 +0000 (UTC)"],"Date":"Mon, 20 Jan 2020 12:09:17 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200120110917.pzgijb4e6dqk2wcc@uno.localdomain>","References":"<20200120002437.6633-1-laurent.pinchart@ideasonboard.com>\n\t<20200120002437.6633-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"zwoegkakteyssyei\"","Content-Disposition":"inline","In-Reply-To":"<20200120002437.6633-2-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 01/19] test: buffer_import: Propagate\n\tstatus code from buffer allocation","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>","X-List-Received-Date":"Mon, 20 Jan 2020 11:06:46 -0000"}},{"id":3527,"web_url":"https://patchwork.libcamera.org/comment/3527/","msgid":"<20200120112424.GC20122@pendragon.ideasonboard.com>","date":"2020-01-20T11:24:24","subject":"Re: [libcamera-devel] [PATCH 01/19] test: buffer_import: Propagate\n\tstatus code from buffer allocation","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Mon, Jan 20, 2020 at 12:09:17PM +0100, Jacopo Mondi wrote:\n> On Mon, Jan 20, 2020 at 02:24:19AM +0200, Laurent Pinchart wrote:\n> > The BufferSource::allocate() return value isn't propagated correctly,\n> > resulting in a test failure when the test should be skipped due to a\n> > missing vivid device. Fix it.\n> >\n> > While at it, return valid status codes from BufferSource::allocate() in\n> > all error cases, with proper diagnostic messages.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  test/camera/buffer_import.cpp | 18 +++++++++++++-----\n> >  1 file changed, 13 insertions(+), 5 deletions(-)\n> >\n> > diff --git a/test/camera/buffer_import.cpp b/test/camera/buffer_import.cpp\n> > index e7048335e031..16bfca9beeea 100644\n> > --- a/test/camera/buffer_import.cpp\n> > +++ b/test/camera/buffer_import.cpp\n> > @@ -89,15 +89,23 @@ public:\n> >  \t\tret = video_->getFormat(&format);\n> >  \t\tif (ret) {\n> >  \t\t\tstd::cout << \"Failed to get format on output device\" << std::endl;\n> > -\t\t\treturn ret;\n> > +\t\t\treturn TestFail;\n> \n> Nitpicking, but we now have 2 occurrences of\n> \n>                 ret = video->doSomething()\n>                 if (ret) {\n> \n>                 }\n> \n> Where the value of ret is actually later ignored.\n> \n> >  \t\t}\n> >\n> >  \t\tformat.size = config.size;\n> >  \t\tformat.fourcc = V4L2VideoDevice::toV4L2Fourcc(config.pixelFormat, false);\n> > -\t\tif (video_->setFormat(&format))\n> > +\t\tif (video_->setFormat(&format)) {\n> \n> I would unify all three calls here to this format\n> \n>                 if (video_->doSomething()) {\n> \n>                 }\n> and remove ret\n\nOK I'll change that.\n\n> With or without this considered\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> > +\t\t\tstd::cout << \"Failed to set format on output device\" << std::endl;\n> >  \t\t\treturn TestFail;\n> > +\t\t}\n> >\n> > -\t\treturn video_->exportBuffers(config.bufferCount, &buffers_);\n> > +\t\tret = video_->exportBuffers(config.bufferCount, &buffers_);\n> > +\t\tif (ret < 0) {\n> > +\t\t\tstd::cout << \"Failed to export buffers\" << std::endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\treturn TestPass;\n> >  \t}\n> >\n> >  \tconst std::vector<std::unique_ptr<FrameBuffer>> &buffers()\n> > @@ -178,8 +186,8 @@ protected:\n> >\n> >  \t\tBufferSource source;\n> >  \t\tint ret = source.allocate(cfg);\n> > -\t\tif (ret < 0)\n> > -\t\t\treturn TestFail;\n> > +\t\tif (ret != TestPass)\n> > +\t\t\treturn ret;\n> >\n> >  \t\tstd::vector<Request *> requests;\n> >  \t\tfor (const std::unique_ptr<FrameBuffer> &buffer : source.buffers()) {","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8075F600F5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Jan 2020 12:24:25 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F31A9A62;\n\tMon, 20 Jan 2020 12:24:24 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579519465;\n\tbh=bz+z8RoM1YrCdoq6PvAT37Z8gue33RoB9n1Qbje53zY=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=EKg3bXoZb6tiNcuvi7bbStFuvH0weC3sSKLgMYnRIR+zKrLCLfJgdbp+elv+mIzp2\n\t52qG8ixMJFMLKyA/RcvuX9S3cM4hkhZrsq0dtbgmuwLCWIg6iKCsRerT6TN9NC0RHh\n\tqlOWgMpvkFGRLA6ewFfVHXt74cKgygtmOwaod8jI=","Date":"Mon, 20 Jan 2020 13:24:24 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200120112424.GC20122@pendragon.ideasonboard.com>","References":"<20200120002437.6633-1-laurent.pinchart@ideasonboard.com>\n\t<20200120002437.6633-2-laurent.pinchart@ideasonboard.com>\n\t<20200120110917.pzgijb4e6dqk2wcc@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200120110917.pzgijb4e6dqk2wcc@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 01/19] test: buffer_import: Propagate\n\tstatus code from buffer allocation","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>","X-List-Received-Date":"Mon, 20 Jan 2020 11:24:25 -0000"}}]