Re: [PATCH] kcsan: Use min() to fix Coccinelle warning

From: Thorsten Blum
Date: Mon Jun 24 2024 - 04:00:36 EST


On 24. Jun 2024, at 00:02, Marco Elver <elver@xxxxxxxxxx> wrote:
> On Mon, 24 Jun 2024 at 00:08, Thorsten Blum <thorsten.blum@xxxxxxxxxx> wrote:
>>
>> Fixes the following Coccinelle/coccicheck warning reported by
>> minmax.cocci:
>>
>> WARNING opportunity for min()
>>
>> Use size_t instead of int for the result of min().
>>
>> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxxx>
>
> Reviewed-by: Marco Elver <elver@xxxxxxxxxx>
>
> Thanks for polishing (but see below). Please compile-test with
> CONFIG_KCSAN=y if you haven't.

Yes, I compile-tested it with CONFIG_KCSAN=y, but forgot to mention it.

> While we're here polishing things this could be:
>
> const size_t read_len = min(count, sizeof(kbuf) - 1);
>
> ( +const, remove redundant () )

Should I submit a v2 or are you adding this already?

Thanks,
Thorsten