qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v1] device_tree: load_device_tree(): Allow NULL sizep
@ 2012-06-21  4:51 Peter A. G. Crosthwaite
  2012-06-22  9:15 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
  2012-06-22 13:17 ` [Qemu-devel] " Peter Crosthwaite
  0 siblings, 2 replies; 8+ messages in thread
From: Peter A. G. Crosthwaite @ 2012-06-21  4:51 UTC (permalink / raw)
  To: qemu-devel, edgar.iglesias, qemu-trivial; +Cc: peter.crosthwaite, john.williams

The sizep arg is populated with the size of the loaded device tree. Since this
is one of those informational "please populate" type arguments it should be
optional. Guarded writes to *sizep against NULL accordingly.

Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwaite@petalogix.com>
---
 device_tree.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/device_tree.c b/device_tree.c
index 86a694c..0ed0256 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -32,7 +32,9 @@ void *load_device_tree(const char *filename_path, int *sizep)
     int ret;
     void *fdt = NULL;
 
-    *sizep = 0;
+    if (sizep) {
+        *sizep = 0;
+    }
     dt_size = get_image_size(filename_path);
     if (dt_size < 0) {
         printf("Unable to get size of device tree file '%s'\n",
@@ -65,7 +67,9 @@ void *load_device_tree(const char *filename_path, int *sizep)
             filename_path);
         goto fail;
     }
-    *sizep = dt_size;
+    if (sizep) {
+        *sizep = dt_size;
+    }
     return fdt;
 
 fail:
-- 
1.7.3.2

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

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

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-21  4:51 [Qemu-devel] [PATCH v1] device_tree: load_device_tree(): Allow NULL sizep Peter A. G. Crosthwaite
2012-06-22  9:15 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
2012-06-22 10:24   ` Peter Crosthwaite
2012-06-22 12:28     ` Stefan Hajnoczi
2012-06-22 13:17 ` [Qemu-devel] " Peter Crosthwaite
2012-06-22 21:14   ` Alexander Graf
2012-06-23  0:45     ` Peter Crosthwaite
2012-06-23 10:01       ` Alexander Graf

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).