]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
Fix spurious spaces in lsmod output
authorSantiago Vila <sanvila@unex.es>
Thu, 16 Apr 2015 11:44:22 +0000 (08:44 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 16 Apr 2015 11:46:43 +0000 (08:46 -0300)
While using "localyesconfig" to build a custom kernel I noticed that
lsmod output now has trailing spaces when the list of "Used by" modules
is empty.

The following patch just delays the space to the point where we are sure
that there are more things to print.

tools/lsmod.c

index e953c7e55c3f0a9e6a1f70cc067159b2c51ec9b6..d9a27f2d797def9b8af694cb6352e44e851cce58 100644 (file)
@@ -64,15 +64,17 @@ static int do_lsmod(int argc, char *argv[])
                struct kmod_list *holders, *hitr;
                int first = 1;
 
-               printf("%-19s %8ld  %d ", name, size, use_count);
+               printf("%-19s %8ld  %d", name, size, use_count);
                holders = kmod_module_get_holders(mod);
                kmod_list_foreach(hitr, holders) {
                        struct kmod_module *hm = kmod_module_get_module(hitr);
 
-                       if (!first)
+                       if (!first) {
                                putchar(',');
-                       else
+                       } else {
+                               putchar(' ');
                                first = 0;
+                       }
 
                        fputs(kmod_module_get_name(hm), stdout);
                        kmod_module_unref(hm);