On 2020-06-25, Petr Mladek <[email protected]> wrote:
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>> @@ -594,22 +473,26 @@ static u32 msg_used_size(u16 text_len, u16 dict_len, 
>> u32 *pad_len)
>>  #define MAX_LOG_TAKE_PART 4
>>  static const char trunc_msg[] = "<truncated>";
>>  
>> -static u32 truncate_msg(u16 *text_len, u16 *trunc_msg_len,
>> -                    u16 *dict_len, u32 *pad_len)
>> +static void truncate_msg(u16 *text_len, u16 *trunc_msg_len, u16 *dict_len)
>>  {
>>      /*
>>       * The message should not take the whole buffer. Otherwise, it might
>>       * get removed too soon.
>>       */
>>      u32 max_text_len = log_buf_len / MAX_LOG_TAKE_PART;
>> +
>>      if (*text_len > max_text_len)
>>              *text_len = max_text_len;
>> -    /* enable the warning message */
>> +
>> +    /* enable the warning message (if there is room) */
>>      *trunc_msg_len = strlen(trunc_msg);
>> +    if (*text_len >= *trunc_msg_len)
>> +            *text_len -= *trunc_msg_len;
>> +    else
>> +            *trunc_msg_len = 0;
>> +
>>      /* disable the "dict" completely */
>>      *dict_len = 0;
>
> The dictionary does not longer need to be removed at this point.
> It is stored in a separate buffer. It is ignored by prb_reserve()
> when there is not enough space for it.

Agreed. @dict_len argument will also be dropped from the function.

John Ogness

Reply via email to