Linux kernel modifications for the Kernel Hacking exam
Find a file
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
arch cxl for v5.16 2021-11-08 11:49:48 -08:00
block for-5.16/inode-sync-2021-10-29 2021-11-01 10:25:27 -07:00
certs
crypto lib: zstd: Add kernel-specific API 2021-11-08 16:55:21 -08:00
Documentation - Remove Drivers 2021-11-08 12:07:52 -08:00
drivers - Fix-ups 2021-11-08 12:21:28 -08:00
fs lib: zstd: Add kernel-specific API 2021-11-08 16:55:21 -08:00
include lib: zstd: Upgrade to latest upstream zstd version 1.4.10 2021-11-08 16:55:32 -08:00
init Merge branch 'akpm' (patches from Andrew) 2021-11-06 14:08:17 -07:00
ipc
kernel kgdb patches for 5.16 2021-11-08 09:35:43 -08:00
lib lib: zstd: Add cast to silence clang's -Wbitwise-instead-of-logical 2021-11-08 16:55:38 -08:00
LICENSES
mm Merge branch 'akpm' (patches from Andrew) 2021-11-06 14:08:17 -07:00
net Merge branch 'akpm' (patches from Andrew) 2021-11-06 14:08:17 -07:00
samples Add gitignore file for samples/fanotify/ subdirectory 2021-11-07 11:19:24 -08:00
scripts Kbuild updates for v5.16 2021-11-08 09:15:45 -08:00
security Merge branch 'akpm' (patches from Andrew) 2021-11-06 14:08:17 -07:00
sound TTY / Serial driver update for 5.16-rc1 2021-11-04 09:09:37 -07:00
tools cxl for v5.16 2021-11-08 11:49:48 -08:00
usr initramfs: Check timestamp to prevent broken cpio archive 2021-10-24 13:48:40 +09:00
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap ARM: SoC DT updates for v5.16 2021-11-03 16:56:03 -07:00
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS MAINTAINERS: Add maintainer entry for zstd 2021-11-08 16:55:38 -08:00
Makefile Kbuild updates for v5.16 2021-11-08 09:15:45 -08:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.