[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Avoid passing NULL to printf %s specifier



# HG changeset patch
# User john levon sun com
# Date 1231985011 28800
# Node ID 2766ee91dd5ea8e99dac27ce730af0dc46a1d107
# Parent  082e0f7d5de236e69bea177c8d4c4204350144c1
Avoid passing NULL to printf %s specifier

This is non-portable.

Signed-off-by: John Levon <john levon sun com>

diff --git a/src/internal.h b/src/internal.h
--- a/src/internal.h
+++ b/src/internal.h
@@ -115,6 +115,8 @@
 #define ATTRIBUTE_RETURN_CHECK
 #endif				/* __GNUC__ */
 
+#define NULLSTR(a) ((a) ? (a) : "(null)")
+
 /**
  * TODO:
  *
diff --git a/src/libvirt.c b/src/libvirt.c
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -874,10 +874,10 @@ do_open (const char *name,
               "  port %d\n"
               "  path %s\n",
               name,
-              ret->uri->scheme, ret->uri->opaque,
-              ret->uri->authority, ret->uri->server,
-              ret->uri->user, ret->uri->port,
-              ret->uri->path);
+              NULLSTR(ret->uri->scheme), NULLSTR(ret->uri->opaque),
+              NULLSTR(ret->uri->authority), NULLSTR(ret->uri->server),
+              NULLSTR(ret->uri->user), ret->uri->port,
+              NULLSTR(ret->uri->path));
     } else {
         DEBUG0("no name, allowing driver auto-select");
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]