[lib] reset multipath field widths before printing topology
authorChristophe Varoqui <christophe.varoqui@free.fr>
Wed, 19 Nov 2008 21:17:50 +0000 (22:17 +0100)
committerChristophe Varoqui <christophe.varoqui@free.fr>
Wed, 19 Nov 2008 21:17:50 +0000 (22:17 +0100)
Doing a "show topo" after "show maps" gave different output than "show topo"
on a freshly started multipathd or than "multipath -ll". This is due to
"show map" doing a get_multipath_layout(), which result is persistent, and
affects all subsequent users of the snprint_*() functions.

This patch ensures a predictable output format by reseting the multipath
field widths in snprint_multipath_topology().

libmultipath/print.c

index 9243cfa..461e707 100644 (file)
@@ -489,6 +489,15 @@ get_path_layout (vector pathvec, int header)
        }
 }
 
+static void
+reset_multipath_layout (void)
+{
+       int i;
+
+       for (i = 0; mpd[i].header; i++)
+               mpd[i].width = 0;
+}
+
 void
 get_multipath_layout (vector mpvec, int header)
 {
@@ -745,6 +754,8 @@ snprint_multipath_topology (char * buff, int len, struct multipath * mpp,
        if (verbosity <= 0)
                return fwd;
 
+       reset_multipath_layout();
+
        if (verbosity == 1)
                return snprint_multipath(buff, len, "%n", mpp);