contrib/lvm2: Remove unnecessary space at the end of line
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 18 Nov 2015 12:04:47 +0000 (21:04 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Thu, 19 Nov 2015 12:10:09 +0000 (21:10 +0900)
Having " %s" at the end of printf format prints unnecessary
space at the end of line when dm targets have nothing to print
for dmsetup status/table.

If dm targets don't implement status/table, use printf format
without " %s", since those targets only initialize the string
with "".

(This fix doesn't exist in upstream lvm2)

contrib/lvm2/dist/tools/dmsetup.c

index d87cddd..e40e934 100644 (file)
@@ -1392,6 +1392,7 @@ static int _status(int argc, char **argv, void *data)
 
        /* Fetch targets and print 'em */
        do {
+               params = NULL;
                next = dm_get_next_target(dmt, next, &start, &length,
                                          &target_type, &params);
                /* Skip if target type doesn't match */
@@ -1422,8 +1423,14 @@ static int _status(int argc, char **argv, void *data)
                                        while (*c && *c != ' ')
                                                *c++ = '0';
                                }
-                               printf("%" PRIu64 " %" PRIu64 " %s %s",
-                                      start, length, target_type, params);
+                               if (params && strlen(params) > 0) {
+                                       printf("%" PRIu64 " %" PRIu64 " %s %s",
+                                              start, length, target_type, params);
+                               } else {
+                                       /* Not implemented by targets */
+                                       printf("%" PRIu64 " %" PRIu64 " %s",
+                                              start, length, target_type);
+                               }
                        }
                        printf("\n");
                }