From patchwork Tue May 24 22:58:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 16030 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 637BAC3256 for ; Tue, 24 May 2022 22:58:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 13BBB6566D; Wed, 25 May 2022 00:58:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653433112; bh=DRsGWBWMLH4h9Mk+gTUka3k+HceDdjisBlEHmLN1iX0=; 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=0hPOfgsVBBYK6E2gipdpQQfjfV++kmo9mP0sDr9B+wmdbKDCu4AA6zn0POjYTAFRe izwdaQ64C8PtfSx98d76vC7PgPPXaAJztcpEuolr1SEpqyui2HfKHHDQervhw867qG Eb511JYcK97h+6zDur5JsR6mmgiKNxNMFw1QBklckMKyzRYE5ZT3FClzRr3joxy1ja nNypCj00KfnTkuCbss/RMgkYkjBITOtfNazinxEWBtiDP/7bVuI4fU2zxDTXy8tfxF M55JpM3FLWWWe2Uj4DglQbX2iIQ5HxZmnifn0qGgpdIF4bs4zIfMwbn71xkAPBrcQU fBjRsFy7L8VmA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DE95F65668 for ; Wed, 25 May 2022 00:58:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pSOQkHnk"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (ip-109-40-241-133.web.vodafone.de [109.40.241.133]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 52A349DA; Wed, 25 May 2022 00:58:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653433106; bh=DRsGWBWMLH4h9Mk+gTUka3k+HceDdjisBlEHmLN1iX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pSOQkHnkMKs5lwttEiOBQOT48ZBeItkDoklXMsHfb0vp1hL3XVDFMwzA52nMRQj9X mVp41rqShCpvu5r8NCSFOMdzCdJiIUS43H1uzDtB1YFR/rxQOmurr51Oskphn8qhR5 MZO5q6z30LQspyNsUDHMlB8f5p3OTx4AE/Bi1ujE= To: libcamera-devel@lists.libcamera.org Date: Wed, 25 May 2022 01:58:08 +0300 Message-Id: <20220524225816.6830-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220524225816.6830-1-laurent.pinchart@ideasonboard.com> References: <20220524225816.6830-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 04/12] 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 --- 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 959a657478fa..944b564bbe22 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -48,10 +48,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; }