[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A014BA9.9020201@cn.fujitsu.com>
Date: Wed, 06 May 2009 16:34:49 +0800
From: Li Zefan <lizf@...fujitsu.com>
To: Vegard Nossum <vegard.nossum@...il.com>
CC: Lai Jiangshan <laijs@...fujitsu.com>, Ingo Molnar <mingo@...e.hu>,
Yinghai Lu <yinghai@...nel.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Jeremy Fitzhardinge <jeremy@...p.org>,
Zhaolei <zhaolei@...fujitsu.com>,
Steven Rostedt <rostedt@...dmis.org>,
Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: printk %0*X is broken.
Lai Jiangshan wrote:
> Vegard Nossum wrote:
>> 2009/5/6 Ingo Molnar <mingo@...e.hu>:
>>> Cc:-ed more folks who modified lib/vsprintf.c recently.
>>>
>>> Ingo
>>>
>>> * Yinghai Lu <yinghai@...nel.org> wrote:
>>>
>>>> it seems someone broke
>>>>
>>>> printk( "%0*X\n", width, x);
>>>>
>>>> looks like 0 is dumped.
>> After %, we look for flags. The problem is that when a flag is found, we
>> don't advance in the format string. And thus we start looking for the
>> precision, which is read as 0, because we are still at the 0. I think
>> this patch should fix it.
>>
No, we break out of the while loop when we can't find a flag,
So we are at '*' after we found '0'.
>> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
>> index 7536ace..ae7d4b2 100644
>> --- a/lib/vsprintf.c
>> +++ b/lib/vsprintf.c
>> @@ -800,14 +800,15 @@ static int format_decode(const char *fmt, struct printf_spec *spec)
>> if (fmt != start || !*fmt)
>> return fmt - start;
>>
>> + /* this skips the first '%' */
>> + ++fmt;
>> +
>> /* Process flags */
>> spec->flags = 0;
>>
>> - while (1) { /* this also skips first '%' */
>> + while (1) {
>> bool found = true;
>>
>> - ++fmt;
>> -
>> switch (*fmt) {
>> case '-': spec->flags |= LEFT; break;
>> case '+': spec->flags |= PLUS; break;
>> @@ -819,6 +820,8 @@ static int format_decode(const char *fmt, struct printf_spec *spec)
>>
>> if (!found)
>> break;
>> +
>> + ++fmt;
>> }
>>
>
> It seems that your patch does not change anything.
> The code logic is still the same as before.
>
> Lai
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists