aboutsummaryrefslogtreecommitdiff
path: root/device_tree.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2012-09-23 23:27:37 +0200
committerAlexander Graf <agraf@suse.de>2012-10-05 02:35:11 +0200
commit6641b77254d3c191ecee5a87947425f623ac9ca0 (patch)
tree74f2923944762dc3c706d8a3e09ecb361850ed6f /device_tree.c
parent711934334eb3895a89c555c1f57eb3d84ddb2906 (diff)
device tree: simplify dumpdtb code
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>
Diffstat (limited to 'device_tree.c')
-rw-r--r--device_tree.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/device_tree.c b/device_tree.c
index 69ca953b4a..a9236133c7 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);
}
}