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>
This commit is contained in:
Alexander Graf 2012-09-23 23:27:37 +02:00
parent 711934334e
commit 6641b77254
1 changed files with 1 additions and 8 deletions

View 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);
}
}