]> git.dujemihanovic.xyz Git - linux.git/commitdiff
scripts: check duplicated syscall number in syscall table
authorMasahiro Yamada <masahiroy@kernel.org>
Mon, 5 Jul 2021 06:06:54 +0000 (15:06 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 8 Jul 2021 19:00:39 +0000 (04:00 +0900)
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>
scripts/syscallhdr.sh
scripts/syscalltbl.sh

index 848ac27351150f010545b6d62d760bd7cc575cac..22e34cd46b9ba4c150f896cbbdde2c7af32142f9 100755 (executable)
@@ -69,7 +69,7 @@ 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" | sort -n | {
+grep -E "^[0-9A-Fa-fXx]+[[:space:]]+$abis" "$infile" | {
        echo "#ifndef $guard"
        echo "#define $guard"
        echo
index aa6ab156301c1bda009d5081507827dc29620a2c..6abe143889ef6d293ada078ae2e52f7cc8f1669d 100755 (executable)
@@ -52,10 +52,15 @@ outfile="$2"
 
 nxt=0
 
-grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | sort -n | {
+grep -E "^[0-9]+[[:space:]]+$abis" "$infile" | {
 
        while read nr abi name native compat ; do
 
+               if [ $nxt -gt $nr ]; then
+                       echo "error: $infile: syscall table is not sorted or duplicates the same syscall number" >&2
+                       exit 1
+               fi
+
                while [ $nxt -lt $nr ]; do
                        echo "__SYSCALL($nxt, sys_ni_syscall)"
                        nxt=$((nxt + 1))