Skip to content

Commit c6a3a81

Browse files
committed
scripts: check duplicated syscall number in syscall table
Currently, syscall{hdr,tbl}.sh sorts the entire syscall table, but you can assume it is already sorted by the syscall number. The generated syscall table does not work if the same syscall number appears twice. Check it in the script. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent a0e781a commit c6a3a81

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

scripts/syscallhdr.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ guard=_UAPI_ASM_$(basename "$outfile" |
6969
sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
7070
-e 's/[^A-Z0-9_]/_/g' -e 's/__/_/g')
7171

72-
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | sort -n | {
72+
grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | {
7373
echo "#ifndef $guard"
7474
echo "#define $guard"
7575
echo

scripts/syscalltbl.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,15 @@ outfile="$2"
5252

5353
nxt=0
5454

55-
grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n | {
55+
grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | {
5656

5757
while read nr abi name native compat ; do
5858

59+
if [ $nxt -gt $nr ]; then
60+
echo "error: $infile: syscall table is not sorted or duplicates the same syscall number" >&2
61+
exit 1
62+
fi
63+
5964
while [ $nxt -lt $nr ]; do
6065
echo "__SYSCALL($nxt, sys_ni_syscall)"
6166
nxt=$((nxt + 1))

0 commit comments

Comments
 (0)