aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-02-20 23:15:32 -0600
committerRob Landley <rob@landley.net>2012-02-20 23:15:32 -0600
commitf1e2e1cd4a5293d164b79bddb8a582214f7b0acf (patch)
tree8dbd24bab2472cfc45da857c1a05c46e56521652 /toys
parent5a7c16cef9dd7e351d89be06a770efc7a4c5347a (diff)
downloadtoybox-f1e2e1cd4a5293d164b79bddb8a582214f7b0acf.tar.gz
Tighten up the source code in largely cosmetic ways.
Diffstat (limited to 'toys')
-rw-r--r--toys/lsmod.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/toys/lsmod.c b/toys/lsmod.c
index 41bea371..07ef7f89 100644
--- a/toys/lsmod.c
+++ b/toys/lsmod.c
@@ -23,23 +23,18 @@ config LSMOD
void lsmod_main(void)
{
FILE * file = xfopen("/proc/modules", "r");
- char *name, *size, *refcnt, *users;
- xprintf("%-24s Size Used by\n", "Module");
+ xprintf("%-23s Size Used by\n", "Module");
while (fgets(toybuf, sizeof(toybuf), file)) {
- int len;
+ char *name = strtok(toybuf, " "), *size = strtok(NULL, " "),
+ *refcnt = strtok(NULL, " "), *users = strtok(NULL, " ");
- name = strtok(toybuf, " ");
- size = strtok(NULL, " ");
- refcnt = strtok(NULL, " ");
- users = strtok(NULL, " ");
-
- if(name && size && refcnt && users) {
- len = strlen(users)-1;
+ if(users) {
+ int len = strlen(users)-1;
if (users[len] == ',' || users[len] == '-')
users[len] = 0;
- xprintf("%-20s %8s %s %s\n", name, size, refcnt, users);
+ xprintf("%-19s %8s %s %s\n", name, size, refcnt, users);
} else perror_exit("unrecognized input");
}
fclose(file);