diff options
author | Rob Landley <rob@landley.net> | 2012-11-13 17:14:08 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2012-11-13 17:14:08 -0600 |
commit | 7aa651a6a4496d848f86de9b1e6b3a003256a01f (patch) | |
tree | 6995fb4b7cc2e90a6706b0239ebaf95d9dbab530 /toys/other/lsmod.c | |
parent | 571b0706cce45716126776d0ad0f6ac65f4586e3 (diff) | |
download | toybox-7aa651a6a4496d848f86de9b1e6b3a003256a01f.tar.gz |
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
Diffstat (limited to 'toys/other/lsmod.c')
-rw-r--r-- | toys/other/lsmod.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/toys/other/lsmod.c b/toys/other/lsmod.c index 821243b8..b8f5d820 100644 --- a/toys/other/lsmod.c +++ b/toys/other/lsmod.c @@ -1,40 +1,36 @@ -/* vi: set sw=4 ts=4: - * - * lsmod.c - Show the status of modules in the kernel +/* lsmod.c - Show the status of modules in the kernel * * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com> USE_LSMOD(NEWTOY(lsmod, NULL, TOYFLAG_BIN)) config LSMOD - bool "lsmod" - default y - help - usage: lsmod + bool "lsmod" + default y + help + usage: lsmod - Display the currently loaded modules, their sizes and their - dependencies. + Display the currently loaded modules, their sizes and their dependencies. */ #include "toys.h" void lsmod_main(void) { - char *modfile = "/proc/modules"; - FILE * file = xfopen(modfile, "r"); - - xprintf("%-23s Size Used by\n", "Module"); - - while (fgets(toybuf, sizeof(toybuf), file)) { - char *name = strtok(toybuf, " "), *size = strtok(NULL, " "), - *refcnt = strtok(NULL, " "), *users = strtok(NULL, " "); - - if(users) { - int len = strlen(users)-1; - if (users[len] == ',' || users[len] == '-') - users[len] = 0; - xprintf("%-19s %8s %s %s\n", name, size, refcnt, users); - } else perror_exit("bad %s", modfile); - } - fclose(file); + char *modfile = "/proc/modules"; + FILE * file = xfopen(modfile, "r"); + + xprintf("%-23s Size Used by\n", "Module"); + + while (fgets(toybuf, sizeof(toybuf), file)) { + char *name = strtok(toybuf, " "), *size = strtok(NULL, " "), + *refcnt = strtok(NULL, " "), *users = strtok(NULL, " "); + + if(users) { + int len = strlen(users)-1; + if (users[len] == ',' || users[len] == '-') users[len] = 0; + xprintf("%-19s %8s %s %s\n", name, size, refcnt, users); + } else perror_exit("bad %s", modfile); + } + fclose(file); } |