device tree: simplify dumpdtb code
PATCH 1/1 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 <[email protected]>
---
This patch applies on top of the generic dumpdtb remodeling patch.
--- device_tree.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)
device_tree.c +1 -8
@@ -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 ); } }
Signature · 1 line
1.6.0.2
Quoted 23 lines · Alexander Graf
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 <[email protected]>---
This patch applies on top of the generic dumpdtb remodeling patch.
--- device_tree.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-)device_tree.c +0
-2@@ -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;
device_tree.c void qemu_devtree_dumpdtb(void *fdt, int size) · line 320
Quoted 10 lines
device_tree.c +1
-6- 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 <[email protected]>
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net