From patchwork Sat Jun 4 18:59:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16159 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id CFC01C3275 for ; Sat, 4 Jun 2022 19:00:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 600B665640; Sat, 4 Jun 2022 21:00:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1654369204; bh=2b6Hode8CuVVoCxJIW23UGQNd3KaWgZiy3XrrRBmJ1Y=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=PstcApy2TYb9MGwM5dY3HCBeOA09uy3MdYoFrDo6RQyae3sZSRImcsQ03fMjg2RYV n8MgufFPTdXOQ6p4u1wLHoFTj3xL15DyqXNLlYw7CR7bcdCpc3yLVqiJx+CSur036I WZnurIKtFLi2cmKqUBcnymI5Ijllk7iAMD2ob0yyhD2SgVr6NbP8OXyKlqxcRwXc1o cJIj9pRTzOlRX7lHKySdEWx/A2cwL180jS7WOzIU4MqsndNZ/PARPuYfKCNjADyjuW //XT7BGBLDvFIcv53qp7Nk37fWz/Th0hK6p0jF/KUsWwDXM2XJivznQ5zU/Ou56hba ZpkuOJm8LHiyA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D952A6563A for ; Sat, 4 Jun 2022 21:00:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UTipqGIM"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (85-76-79-203-nat.elisa-mobile.fi [85.76.79.203]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A5BDEE0F; Sat, 4 Jun 2022 21:00:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1654369202; bh=2b6Hode8CuVVoCxJIW23UGQNd3KaWgZiy3XrrRBmJ1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UTipqGIMxtKUI617NRkjuI1j5EQmyQU+Ac9/6c89CSmcU82JRKGoDfsm7kCph5lx6 j1oOQRF9tA0a3eTYmOn7ZJwKjtqeyDwa3nDHcg+1TB0DesCZjYMt1zJdomIjijLObQ n/AgzRNLUFLv/G93o8YGl5xMUm1yaCU0ys7pxsAI= To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jun 2022 21:59:29 +0300 Message-Id: <20220604185939.29163-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220604185939.29163-1-laurent.pinchart@ideasonboard.com> References: <20220604185939.29163-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 04/14] test: yaml-parser: Use write() instead of fwrite() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There's no point in wrapping a fd into a FILE to then only call fwrite() and fclose(). Use write() and close() directly. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder --- test/yaml-parser.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp index e75f8fe8f642..5ff4c3236dbf 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -49,10 +49,11 @@ protected: if (fd == -1) return false; - FILE *fh = fdopen(fd, "w"); - fputs(content.c_str(), fh); + int ret = write(fd, content.c_str(), content.size()); + close(fd); - fclose(fh); + if (ret != static_cast(content.size())) + return false; return true; }