Staging
v0.5.1
v0.5.1
https://github.com/torvalds/linux
Revision dee2b702bcf067d7b6b62c18bdd060ff0810a800 authored by Gustavo A. R. Silva on 14 November 2021, 00:57:25 UTC, committed by Linus Torvalds on 14 November 2021, 21:27:30 UTC
Add Kconfig support for -Wimplicit-fallthrough for both GCC and Clang. The compiler option is under configuration CC_IMPLICIT_FALLTHROUGH, which is enabled by default. Special thanks to Nathan Chancellor who fixed the Clang bug[1][2]. This bugfix only appears in Clang 14.0.0, so older versions still contain the bug and -Wimplicit-fallthrough won't be enabled for them, for now. This concludes a long journey and now we are finally getting rid of the unintentional fallthrough bug-class in the kernel, entirely. :) Link: https://github.com/llvm/llvm-project/commit/9ed4a94d6451046a51ef393cd62f00710820a7e8 [1] Link: https://bugs.llvm.org/show_bug.cgi?id=51094 [2] Link: https://github.com/KSPP/linux/issues/115 Link: https://github.com/ClangBuiltLinux/linux/issues/236 Co-developed-by: Kees Cook <keescook@chromium.org> Signed-off-by: Kees Cook <keescook@chromium.org> Co-developed-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ce49bfc
Tip revision: dee2b702bcf067d7b6b62c18bdd060ff0810a800 authored by Gustavo A. R. Silva on 14 November 2021, 00:57:25 UTC
kconfig: Add support for -Wimplicit-fallthrough
kconfig: Add support for -Wimplicit-fallthrough
Tip revision: dee2b70
syscallhdr.sh
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only
#
# Generate a syscall number header.
#
# Each line of the syscall table should have the following format:
#
# NR ABI NAME [NATIVE] [COMPAT]
#
# NR syscall number
# ABI ABI name
# NAME syscall name
# NATIVE native entry point (optional)
# COMPAT compat entry point (optional)
set -e
usage() {
echo >&2 "usage: $0 [--abis ABIS] [--emit-nr] [--offset OFFSET] [--prefix PREFIX] INFILE OUTFILE" >&2
echo >&2
echo >&2 " INFILE input syscall table"
echo >&2 " OUTFILE output header file"
echo >&2
echo >&2 "options:"
echo >&2 " --abis ABIS ABI(s) to handle (By default, all lines are handled)"
echo >&2 " --emit-nr Emit the macro of the number of syscalls (__NR_syscalls)"
echo >&2 " --offset OFFSET The offset of syscall numbers"
echo >&2 " --prefix PREFIX The prefix to the macro like __NR_<PREFIX><NAME>"
exit 1
}
# default unless specified by options
abis=
emit_nr=
offset=
prefix=
while [ $# -gt 0 ]
do
case $1 in
--abis)
abis=$(echo "($2)" | tr ',' '|')
shift 2;;
--emit-nr)
emit_nr=1
shift 1;;
--offset)
offset=$2
shift 2;;
--prefix)
prefix=$2
shift 2;;
-*)
echo "$1: unknown option" >&2
usage;;
*)
break;;
esac
done
if [ $# -ne 2 ]; then
usage
fi
infile="$1"
outfile="$2"
guard=_UAPI_ASM_$(basename "$outfile" |
sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
-e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g')
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | {
echo "#ifndef $guard"
echo "#define $guard"
echo
max=0
while read nr abi name native compat ; do
max=$nr
if [ -n "$offset" ]; then
nr="($offset + $nr)"
fi
echo "#define __NR_$prefix$name $nr"
done
if [ -n "$emit_nr" ]; then
echo
echo "#ifdef __KERNEL__"
echo "#define __NR_${prefix}syscalls $(($max + 1))"
echo "#endif"
fi
echo
echo "#endif /* $guard */"
} > "$outfile"
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...