Skip to contentSkip to conversation

Fix crash at startup

PATCH In review Lionel Landwerlin 2 participants 2 messages Jan 19, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix crash at startup

Fix crash at startup

---
 exec.c |   3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
exec.c +0 -0
index faa6333..7c9d7dc 100644
@@ -2066,2 +2066,2 @@ void page_dump(FILE *f)
     int i, j, prot, prot1;
     PageDesc *p;

+ if (!f)
+ return;
+

     fprintf(f, "%-8s %-8s %-8s %s\n",
             "start", "end", "size", "prot");
     start = -1;

--
1.5.6.5

#1 lore raw
Quoted 12 lines · Lionel Landwerlin

Fix crash at startup

---
 exec.c |   3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
exec.c +0 -0
index faa6333..7c9d7dc 100644

exec.c void page_dump(FILE *f)

Quoted 6 lines
exec.c +3 -0
@@ -2066,2 +2066,2 @@ void page_dump(FILE *f)
    int i, j, prot, prot1;
    PageDesc *p;
 
+    if (!f)
+        return;
+

I would prefer a slightly different approach like the attached patch, but that's just personal taste :-)

Laurent

qemu-log.h +4 -2
Index: qemu-log.h
===================================================================
@@ -63,10 +63,12 @@
         disas(logfile, (start), (len))
 
 /* page_dump() output to the log file: */
-#define log_page_dump() page_dump(logfile)
+#define log_page_dump() do {     \
+        if (logfile)             \
+            page_dump(logfile);  \
+    } while (0)
 
 
-
 /* Maintenance: */
 
 /* fflush() the log file */