OpenCloudOS-Kernel/lib/zstd
Nathan Chancellor 0a8ea23583 lib: zstd: Add cast to silence clang's -Wbitwise-instead-of-logical
A new warning in clang warns that there is an instance where boolean
expressions are being used with bitwise operators instead of logical
ones:

lib/zstd/decompress/huf_decompress.c:890:25: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
                       (BIT_reloadDStreamFast(&bitD1) == BIT_DStream_unfinished)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

zstd does this frequently to help with performance, as logical operators
have branches whereas bitwise ones do not.

To fix this warning in other cases, the expressions were placed on
separate lines with the '&=' operator; however, this particular instance
was moved away from that so that it could be surrounded by LIKELY, which
is a macro for __builtin_expect(), to help with a performance
regression, according to upstream zstd pull #1973.

Aside from switching to logical operators, which is likely undesirable
in this instance, or disabling the warning outright, the solution is
casting one of the expressions to an integer type to make it clear to
clang that the author knows what they are doing. Add a cast to U32 to
silence the warning. The first U32 cast is to silence an instance of
-Wshorten-64-to-32 because __builtin_expect() returns long so it cannot
be moved.

Link: https://github.com/ClangBuiltLinux/linux/issues/1486
Link: https://github.com/facebook/zstd/pull/1973
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Terrell <terrelln@fb.com>
2021-11-08 16:55:38 -08:00
..
common lib: zstd: Upgrade to latest upstream zstd version 1.4.10 2021-11-08 16:55:32 -08:00
compress lib: zstd: Upgrade to latest upstream zstd version 1.4.10 2021-11-08 16:55:32 -08:00
decompress lib: zstd: Add cast to silence clang's -Wbitwise-instead-of-logical 2021-11-08 16:55:38 -08:00
Makefile lib: zstd: Upgrade to latest upstream zstd version 1.4.10 2021-11-08 16:55:32 -08:00
decompress_sources.h lib: zstd: Upgrade to latest upstream zstd version 1.4.10 2021-11-08 16:55:32 -08:00
zstd_compress_module.c lib: zstd: Upgrade to latest upstream zstd version 1.4.10 2021-11-08 16:55:32 -08:00
zstd_decompress_module.c lib: zstd: Upgrade to latest upstream zstd version 1.4.10 2021-11-08 16:55:32 -08:00