Re: [PATCH 2/5] tracing_bprintk: don't increment @pos in t_start()

From: Li Zefan
Date: Sun Jun 21 2009 - 20:40:20 EST


Wang Liming wrote:
> Hi,
>
> Li Zefan wrote:
>> It's wrong to increment @pos in t_start(), otherwise we'll lose
>> some entries when reading printk_formats, if the output is large
>> than PAGE_SIZE.
>>
>> [ Impact: fix missing entries when reading printk_formats ]
>>
>> Reported-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
>> Signed-off-by: Li Zefan <lizf@xxxxxxxxxxxxxx>
>> ---
>> kernel/trace/trace_printk.c | 26 ++++++--------------------
>> 1 files changed, 6 insertions(+), 20 deletions(-)
>>
>> diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
>> index 9bece96..7b62781 100644
>> --- a/kernel/trace/trace_printk.c
>> +++ b/kernel/trace/trace_printk.c
>> @@ -155,25 +155,19 @@ int __ftrace_vprintk(unsigned long ip, const
>> char *fmt, va_list ap)
>> EXPORT_SYMBOL_GPL(__ftrace_vprintk);
>>
>> static void *
>> -t_next(struct seq_file *m, void *v, loff_t *pos)
>> +t_start(struct seq_file *m, loff_t *pos)
>> {
>> - const char **fmt = m->private;
>> - const char **next = fmt;
>> -
>> - (*pos)++;
>> + const char **fmt = __start___trace_bprintk_fmt + *pos;
>>
>> if ((unsigned long)fmt >= (unsigned long)__stop___trace_bprintk_fmt)
>> return NULL;
>> -
>> - next = fmt;
>> - m->private = ++next;
>> -
>> return fmt;
>> }
>>
>> -static void *t_start(struct seq_file *m, loff_t *pos)
>> +static void *t_next(struct seq_file *m, void * v, loff_t *pos)
>> {
>> - return t_next(m, NULL, pos);
>> + (*pos)++;
>> + return t_start(m, pos);
>> }
>>
> I prefer to .start to call .next, so I rewrite it to following:
>

Thanks for the comment, but I don't think .next calls .start is bad,
and I'm not the only one doing this. Grep c_start() to see some of
them.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/