[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87r1mnei5g.fsf@jogness.linutronix.de>
Date: Thu, 14 Jan 2021 15:02:43 +0106
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] printk: ringbuffer: fix line counting
On 2021-01-14, Petr Mladek <pmladek@...e.com> wrote:
>> --- a/kernel/printk/printk_ringbuffer.c
>> +++ b/kernel/printk/printk_ringbuffer.c
>> @@ -1718,7 +1718,7 @@ static bool copy_data(struct prb_data_ring *data_ring,
>>
>> /* Caller interested in the line count? */
>> if (line_count)
>> - *line_count = count_lines(data, data_size);
>> + *line_count = count_lines(data, len);
>>
>> /* Caller interested in the data content? */
>> if (!buf || !buf_size)
>
> Another question is what line count should be returned when
> the data are copied into the buffer. In this case, the text
> might get shrunken even more.
Good point. The code could look like this:
if (!buf || !buf_size) {
data_size = len;
} else {
data_size = min_t(u16, buf_size, len);
memcpy(&buf[0], data, data_size);
}
if (line_count)
*line_count = count_lines(data, data_size);
return true;
John Ogness
Powered by blists - more mailing lists