[dm-devel] [PATCH 47/78] Do not print empty multipaths section
Hannes Reinecke
hare at suse.de
Mon Mar 16 12:36:34 UTC 2015
The CLI command 'show config' or the 'multipath -t' command
should not print an empty 'multipaths' section.
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
multipath/main.c | 11 +++++++----
multipathd/cli_handlers.c | 9 ++++++---
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/multipath/main.c b/multipath/main.c
index c46a9f6..ebca4dc 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -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);
diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index 772531e..dc96c45 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -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);
--
1.8.4.5
More information about the dm-devel
mailing list