Anthony Fok
2008-May-27 21:00 UTC
[klibc] [PATCH] Fixes bug which strips every other digit in klibc-utils dmesg output
There is a bug in the way which klibc/usr/utils/dmesg.c tries to strip
the initial <[0-7]> from kernel messages. The bug causes every other
numerical digit to be stripped from the output. Fixed.
A bug report with lots of details has been filed for Debian and Ubuntu:
* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=483186
* https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/235282
Signed-off-by: Anthony Fok <anthony.fok at thizgroup.com>
---
diff -Nur -x '*.orig' -x '*~' klibc-1.5.9/usr/utils/dmesg.c
klibc-1.5.9.new/usr/utils/dmesg.c
--- klibc-1.5.9/usr/utils/dmesg.c 2008-03-29 04:25:36.000000000 +0800
+++ klibc-1.5.9.new/usr/utils/dmesg.c 2008-05-27 07:07:36.000000000 +0800
@@ -50,20 +50,14 @@
exit(1);
}
- while (buf[i] && i < len)
- switch (buf[i]) {
- case '<':
- if (i == 0 || buf[i-1] == '\n')
- i++;
- case '0' ... '9':
- if (i > 0 && buf[i-1] == '<')
- i++;
- case '>':
- if (i > 0 && isdigit(buf[i-1]))
- i++;
- default:
- putchar(buf[i++]);
- }
+ while (buf[i] && i < len) {
+ if (i == 0 || buf[i-1] == '\n')
+ if (buf[i] == '<')
+ if (isdigit(buf[++i]))
+ if (buf[++i] == '>')
+ i++;
+ putchar(buf[i++]);
+ }
if (buf[i-1] != '\n')
putchar('\n');
maximilian attems
2008-May-27 21:44 UTC
[klibc] [PATCH] Fixes bug which strips every other digit in klibc-utils dmesg output
On Wed, May 28, 2008 at 05:00:23AM +0800, Anthony Fok wrote:> There is a bug in the way which klibc/usr/utils/dmesg.c tries to strip > the initial <[0-7]> from kernel messages. The bug causes every other > numerical digit to be stripped from the output. Fixed. > > A bug report with lots of details has been filed for Debian and Ubuntu: > * http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=483186 > * https://bugs.launchpad.net/ubuntu/+source/klibc/+bug/235282 > > Signed-off-by: Anthony Fok <anthony.fok at thizgroup.com> > --- > diff -Nur -x '*.orig' -x '*~' klibc-1.5.9/usr/utils/dmesg.c > klibc-1.5.9.new/usr/utils/dmesg.c > --- klibc-1.5.9/usr/utils/dmesg.c 2008-03-29 04:25:36.000000000 +0800 > +++ klibc-1.5.9.new/usr/utils/dmesg.c 2008-05-27 07:07:36.000000000 +0800 > @@ -50,20 +50,14 @@ > exit(1); > } > > - while (buf[i] && i < len) > - switch (buf[i]) { > - case '<': > - if (i == 0 || buf[i-1] == '\n') > - i++; > - case '0' ... '9': > - if (i > 0 && buf[i-1] == '<') > - i++; > - case '>': > - if (i > 0 && isdigit(buf[i-1])) > - i++; > - default: > - putchar(buf[i++]); > - } > + while (buf[i] && i < len) { > + if (i == 0 || buf[i-1] == '\n') > + if (buf[i] == '<') > + if (isdigit(buf[++i])) > + if (buf[++i] == '>') > + i++; > + putchar(buf[i++]); > + } > > if (buf[i-1] != '\n') > putchar('\n');nack on the coding style, please don't remove the readable switch to an if spagetti code. you are obfuscating the problem. thanks -- maks
H. Peter Anvin
2008-May-27 21:56 UTC
[klibc] [PATCH] Fixes bug which strips every other digit in klibc-utils dmesg output
[maks: removed you from the Cc: list because stro.at doesn't resolve at the moment... I know you're on the klibc list.] maximilian attems wrote:> > nack on the coding style, > please don't remove the readable switch to an if spagetti code. > > you are obfuscating the problem. >Here is a more state-machine-like approach to the problem. You may want to try it out. -hpa -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: diff Url: http://www.zytor.com/pipermail/klibc/attachments/20080527/58c28326/attachment.ksh