Minor cleanups: lsmod should USE_LSMOD() instead of USE_FREE(), use consistent tab...
authorRob Landley <rob@landley.net>
Tue, 21 Feb 2012 02:20:12 +0000 (20:20 -0600)
committerRob Landley <rob@landley.net>
Tue, 21 Feb 2012 02:20:12 +0000 (20:20 -0600)
toys/lsmod.c

index 7f588c8..41bea37 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Not in SUSv4.
 
-USE_FREE(NEWTOY(lsmod, NULL, TOYFLAG_BIN))
+USE_LSMOD(NEWTOY(lsmod, NULL, TOYFLAG_BIN))
 
 config LSMOD
        bool "lsmod"
@@ -22,28 +22,25 @@ config LSMOD
 
 void lsmod_main(void)
 {
-    FILE * file = fopen("/proc/modules", "r");
-    char *name, *size, *refcnt, *users;
-    if (!file)
-        perror_exit("cannot open /proc/moduls");
+       FILE * file = xfopen("/proc/modules", "r");
+       char *name, *size, *refcnt, *users;
 
-    xprintf("%-24s Size  Used by\n", "Module");
+       xprintf("%-24s Size  Used by\n", "Module");
 
-    while (fgets(toybuf, sizeof(toybuf), file)) {
-        int len;
-        name = strtok(toybuf, " ");
-        size = strtok(NULL, " ");
+       while (fgets(toybuf, sizeof(toybuf), file)) {
+               int len;
+
+               name = strtok(toybuf, " ");
+               size = strtok(NULL, " ");
                refcnt = strtok(NULL, " ");
                users = strtok(NULL, " ");
+
                if(name && size && refcnt && users) {
                        len = strlen(users)-1;
                        if (users[len] == ',' || users[len] == '-')
                                users[len] = 0;
                        xprintf("%-20s %8s  %s %s\n", name, size, refcnt, users);
-               } else {
-                       perror_exit("unrecognized input");
-                       break;
-               }
+               } else perror_exit("unrecognized input");
        }
        fclose(file);
 }