]> git.proxmox.com Git - mirror_qemu.git/commitdiff
device tree: simplify dumpdtb code
authorAlexander Graf <agraf@suse.de>
Sun, 23 Sep 2012 21:27:37 +0000 (23:27 +0200)
committerAlexander Graf <agraf@suse.de>
Fri, 5 Oct 2012 00:35:11 +0000 (02:35 +0200)
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 <agraf@suse.de>
device_tree.c

index 69ca953b4ab3a1364d5fac0ab4afe9fcc228b904..a9236133c7fa957b8967f9883730d61b2f2d8970 100644 (file)
@@ -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);
         }
     }