From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:54199) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TIlSU-0005ee-Lz for qemu-devel@nongnu.org; Mon, 01 Oct 2012 15:15:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TIlST-00072x-Ar for qemu-devel@nongnu.org; Mon, 01 Oct 2012 15:15:14 -0400 Date: Mon, 1 Oct 2012 21:15:08 +0200 From: Aurelien Jarno Message-ID: <20121001191508.GF4623@ohm.aurel32.net> References: <1348435772-26553-1-git-send-email-agraf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1348435772-26553-1-git-send-email-agraf@suse.de> Subject: Re: [Qemu-devel] [PATCH] device tree: simplify dumpdtb code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Peter Maydell , qemu-ppc Mailing List , qemu-devel qemu-devel On Sun, Sep 23, 2012 at 11:29:32PM +0200, Alexander Graf wrote: > As per Peter's suggestion, we can use glib to write out a buffer in whole to > a file, simplifying the code dramatically. > > Signed-off-by: Alexander Graf > > --- > > This patch applies on top of the generic dumpdtb remodeling patch. > > --- > device_tree.c | 9 +-------- > 1 files changed, 1 insertions(+), 8 deletions(-) > > diff --git a/device_tree.c b/device_tree.c > index 69ca953..a923613 100644 > --- a/device_tree.c > +++ b/device_tree.c > @@ -314,14 +314,7 @@ void qemu_devtree_dumpdtb(void *fdt, int size) > const char *dumpdtb = qemu_opt_get(machine_opts, "dumpdtb"); > if (dumpdtb) { > /* Dump the dtb to a file and quit */ > - FILE *f = fopen(dumpdtb, "wb"); > - size_t len; > - len = fwrite(fdt, size, 1, f); > - fclose(f); > - if (len != size) { > - exit(1); > - } > - exit(0); > + exit(g_file_set_contents(dumpdtb, fdt, size, NULL) ? 0 : 1); > } > } > Reviewed-by: Aurelien Jarno -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net