Re: [PATCH] lib/lz4: smatch warning in LZ4_decompress_generic()

From: Gao Xiang
Date: Sat Jun 06 2020 - 10:37:10 EST


(I'm not sure whether my email was finally sent out since
I haven't seen it in lore yet. Resend with my another email...)

On Sat, Jun 06, 2020 at 04:28:02PM +0300, Vasily Averin wrote:
> Found by smatch:
> lib/lz4/lz4_decompress.c:150 LZ4_decompress_generic() warn: maybe use && instead of &
> It was realy incorrectly copied from
> https://github.com/lz4/lz4/commit/45f8603aae389d34c689d3ff7427b314071ccd2c
> line 1431

Simply no.

>
> Fixes: 2209fda323e2 ("lib/lz4: update LZ4 decompressor module")
> Signed-off-by: Vasily Averin <vvs@xxxxxxxxxxxxx>
> ---
> lib/lz4/lz4_decompress.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c
> index 0c9d3ad..f7f7dca 100644
> --- a/lib/lz4/lz4_decompress.c
> +++ b/lib/lz4/lz4_decompress.c
> @@ -147,7 +147,7 @@ static FORCE_INLINE int LZ4_decompress_generic(
> * strictly "less than" on input, to re-enter
> * the loop with at least one byte
> */
> - && likely((endOnInput ? ip < shortiend : 1) &
> + && likely((endOnInput ? ip < shortiend : 1) &&

I'd like to say, this is not my mistake (even not an issue).
If you notice the latest LZ4 upstream
https://github.com/lz4/lz4/blob/dev/lib/lz4.c#L1865

Or some related change, the lz4 author Cyan did it on purpose.
https://github.com/lz4/lz4/commit/1a191b3f8d26b50a7c1d41590b529ec308d768cd

I think we could follow the latest LZ4 upstream in order to
avoid further maintainence overhead. That's my own thought
anyway.

Thanks,
Gao Xiang