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/lsb/dmesg.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/lsb/dmesg.c')
-rw-r--r-- | toys/lsb/dmesg.c | 69 |
1 files changed, 33 insertions, 36 deletions
diff --git a/toys/lsb/dmesg.c b/toys/lsb/dmesg.c index 8d73513b..10032562 100644 --- a/toys/lsb/dmesg.c +++ b/toys/lsb/dmesg.c @@ -1,6 +1,4 @@ -/* vi: set sw=4 ts=4: - * - * dmesg.c - display/control kernel ring buffer. +/* dmesg.c - display/control kernel ring buffer. * * Copyright 2006, 2007 Rob Landley <rob@landley.net> * @@ -9,16 +7,16 @@ USE_DMESG(NEWTOY(dmesg, "s#n#c", TOYFLAG_BIN)) config DMESG - bool "dmesg" - default y - help - usage: dmesg [-n level] [-s bufsize] | -c + bool "dmesg" + default y + help + usage: dmesg [-n level] [-s bufsize] | -c - Print or control the kernel ring buffer. + Print or control the kernel ring buffer. - -n Set kernel logging level (1-9). - -s Size of buffer to read (in bytes), default 16384. - -c Clear the ring buffer after printing. + -n Set kernel logging level (1-9). + -s Size of buffer to read (in bytes), default 16384. + -c Clear the ring buffer after printing. */ #define FOR_dmesg @@ -26,33 +24,32 @@ config DMESG #include <sys/klog.h> GLOBALS( - long level; - long size; + long level; + long size; ) void dmesg_main(void) { - // For -n just tell kernel to which messages to keep. - if (toys.optflags & 2) { - if (klogctl(8, NULL, TT.level)) - error_exit("klogctl"); - } else { - int size, i, last = '\n'; - char *data; - - // Figure out how much data we need, and fetch it. - size = TT.size; - if (size<2) size = 16384; - data = xmalloc(size); - size = klogctl(3 + (toys.optflags&1), data, size); - if (size < 0) error_exit("klogctl"); - - // Display data, filtering out level markers. - for (i=0; i<size; ) { - if (last=='\n' && data[i]=='<') i += 3; - else xputc(last = data[i++]); - } - if (last!='\n') xputc('\n'); - if (CFG_TOYBOX_FREE) free(data); - } + // For -n just tell kernel to which messages to keep. + if (toys.optflags & 2) { + if (klogctl(8, NULL, TT.level)) error_exit("klogctl"); + } else { + int size, i, last = '\n'; + char *data; + + // Figure out how much data we need, and fetch it. + size = TT.size; + if (size<2) size = 16384; + data = xmalloc(size); + size = klogctl(3 + (toys.optflags&1), data, size); + if (size < 0) error_exit("klogctl"); + + // Display data, filtering out level markers. + for (i=0; i<size; ) { + if (last=='\n' && data[i]=='<') i += 3; + else xputc(last = data[i++]); + } + if (last!='\n') xputc('\n'); + if (CFG_TOYBOX_FREE) free(data); + } } |