Re: AW: [PATCH] soc: aspeed: fix a ternary sign expansion bug

From: Sergey Organov
Date: Fri Apr 23 2021 - 10:47:52 EST


Walter Harms <wharms@xxxxxx> writes:

> as indepentent observer,
> i would go for Dans solution:
>
> ret = kfifo_to_user();
> /* if an error occurs just return */
> if (ret)
> return ret;
>
> /* otherwise return the copied number of bytes */
>
> return copied;
>
> there is no need for any deeper language knowledge,

Yep, but this is not idiomatic C, so one looking at this code would
tend to convert it back to ternary, and the actual problem here is that
the type of 'copied' does not match the return type of the function.

-- Sergey Organov