[{"id":23391,"web_url":"https://patchwork.libcamera.org/comment/23391/","msgid":"<20220613041240.GF2369877@pyrite.rasen.tech>","date":"2022-06-13T04:12:40","subject":"Re: [libcamera-devel] [RFC PATCH v2 04/14] test: yaml-parser: Use\n\twrite() instead of fwrite()","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Laurent,\n\nOn Sat, Jun 04, 2022 at 09:59:29PM +0300, Laurent Pinchart via libcamera-devel wrote:\n> There's no point in wrapping a fd into a FILE to then only call fwrite()\n> and fclose(). Use write() and close() directly.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  test/yaml-parser.cpp | 7 ++++---\n>  1 file changed, 4 insertions(+), 3 deletions(-)\n> \n> diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\n> index e75f8fe8f642..5ff4c3236dbf 100644\n> --- a/test/yaml-parser.cpp\n> +++ b/test/yaml-parser.cpp\n> @@ -49,10 +49,11 @@ protected:\n>  \t\tif (fd == -1)\n>  \t\t\treturn false;\n>  \n> -\t\tFILE *fh = fdopen(fd, \"w\");\n> -\t\tfputs(content.c_str(), fh);\n> +\t\tint ret = write(fd, content.c_str(), content.size());\n> +\t\tclose(fd);\n>  \n> -\t\tfclose(fh);\n> +\t\tif (ret != static_cast<int>(content.size()))\n> +\t\t\treturn false;\n>  \n>  \t\treturn true;\n>  \t}\n> -- \n> Regards,\n> \n> Laurent Pinchart\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 CB311BD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jun 2022 04:12:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8379D65631;\n\tMon, 13 Jun 2022 06:12: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 CD96F600F0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jun 2022 06:12:47 +0200 (CEST)","from pyrite.rasen.tech (softbank036240126034.bbtec.net\n\t[36.240.126.34])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5AB92440;\n\tMon, 13 Jun 2022 06:12:46 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655093569;\n\tbh=o7wUWDT5tkzqd+t92ohOt820Xw0V27YTM6Ircii4p8g=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=LxnfRLCA7gUHY5HsLCjvj3w33Qh0S1GIAKqGeHeX7jIe7T0T7mhAbHWzwoiE0v5+t\n\tXzD/fodE2Uz1+CLJxyqYqHCX7N6VxFjk4akVhRIRnzD0OL4PrJm4fScoDaz+6sSqk8\n\tu4I5arO/duk8h3og5SrfrRfPxehIBkyepRI2BMZk4eLSHzW8d3e8VyS1JhoCh/HWk4\n\txy7mQplerECbkXGAV/X2kCAnRthlUsYiJ1e7kPYni80/5f8rtNV7D5WNJy+rXc2MQL\n\tWJjxeOCBk+7LmzEo7RjqsufwCTTPVK+vcmn76vlG6VoQKJdKVlNVfEhDDLnczTtJu9\n\tf29k3Tp2r3aBA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655093567;\n\tbh=o7wUWDT5tkzqd+t92ohOt820Xw0V27YTM6Ircii4p8g=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FH5Uz4fvxxwBxwT5/hXopKiouwE6hm4oauRrT/gvfjVCSE/j17+fZW5suagGIRrs3\n\ty7IwTXGjCEs9WO0QE9jH13J/KaLC6iUxFwIaPIj7JMrd0x2OUZY82SUcW1eg+zWaEi\n\tRJrRD7hfbL05xtxooEv2B3eJFLpP6HgtrwUZSeNI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"FH5Uz4fv\"; dkim-atps=neutral","Date":"Mon, 13 Jun 2022 13:12:40 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220613041240.GF2369877@pyrite.rasen.tech>","References":"<20220604185939.29163-1-laurent.pinchart@ideasonboard.com>\n\t<20220604185939.29163-5-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20220604185939.29163-5-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH v2 04/14] test: yaml-parser: Use\n\twrite() instead of fwrite()","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]