Do not print empty multipaths section
authorHannes Reinecke <hare@suse.de>
Tue, 12 Aug 2014 08:09:59 +0000 (10:09 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Sun, 29 Mar 2015 16:07:32 +0000 (18:07 +0200)
The CLI command 'show config' or the 'multipath -t' command
should not print an empty 'multipaths' section.

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipath/main.c
multipathd/cli_handlers.c

index c46a9f6..ebca4dc 100644 (file)
@@ -436,10 +436,13 @@ dump_config (void)
                        reply = REALLOC(reply, maxlen *= 2);
                        continue;
                }
-               c += snprint_mptable(c, reply + maxlen - c, conf->mptable);
-               again = ((c - reply) == maxlen);
-               if (again)
-                       reply = REALLOC(reply, maxlen *= 2);
+               if (VECTOR_SIZE(conf->mptable) > 0) {
+                       c += snprint_mptable(c, reply + maxlen - c,
+                                            conf->mptable);
+                       again = ((c - reply) == maxlen);
+                       if (again)
+                               reply = REALLOC(reply, maxlen *= 2);
+               }
        }
 
        printf("%s", reply);
index 772531e..dc96c45 100644 (file)
@@ -229,9 +229,12 @@ show_config (char ** r, int * len)
                        maxlen *= 2;
                        continue;
                }
-               c += snprint_mptable(c, reply + maxlen - c, conf->mptable);
-               again = ((c - reply) == maxlen);
-               REALLOC_REPLY(reply, again, maxlen);
+               if (VECTOR_SIZE(conf->mptable) > 0) {
+                       c += snprint_mptable(c, reply + maxlen - c,
+                                            conf->mptable);
+                       again = ((c - reply) == maxlen);
+                       REALLOC_REPLY(reply, again, maxlen);
+               }
        }
        *r = reply;
        *len = (int)(c - reply + 1);