[klibc] [PATCH] Fixes bug which strips every other digit in klibc-utils dmesg output
maximilian attems
max at stro.at
Tue May 27 14:44:56 PDT 2008
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
More information about the klibc
mailing list