qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] device tree: simplify dumpdtb code
@ 2012-09-23 21:29 Alexander Graf
  2012-10-01 19:15 ` Aurelien Jarno
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Graf @ 2012-09-23 21:29 UTC (permalink / raw)
  To: qemu-devel qemu-devel; +Cc: Peter Maydell, qemu-ppc Mailing List

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] device tree: simplify dumpdtb code
  2012-09-23 21:29 [Qemu-devel] [PATCH] device tree: simplify dumpdtb code Alexander Graf
@ 2012-10-01 19:15 ` Aurelien Jarno
  0 siblings, 0 replies; 2+ messages in thread
From: Aurelien Jarno @ 2012-10-01 19:15 UTC (permalink / raw)
  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 <agraf@suse.de>
> 
> ---
> 
> 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@aurel32.net>


-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-01 19:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-23 21:29 [Qemu-devel] [PATCH] device tree: simplify dumpdtb code Alexander Graf
2012-10-01 19:15 ` Aurelien Jarno

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).