]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: simplify syscall number handling master
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 8 Jul 2025 12:38:58 +0000 (07:38 -0500)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 11 Jul 2025 15:31:51 +0000 (10:31 -0500)
Use a switch() statement for syscall override handling, making it a
little bit less verbose.

Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/387
testsuite/init_module.c

index c419aa3e3456383b427eaaf93de973ba644577ab..6ad95d7faa46da54ffe16751ac910ae608b1da33 100644 (file)
@@ -332,12 +332,14 @@ TS_EXPORT long int syscall(long int __sysno, ...)
        va_list ap;
        long ret;
 
-       if (__sysno == -1) {
+       switch (__sysno) {
+       case -1:
+#ifdef __NR_riscv_hwprobe
+       case __NR_riscv_hwprobe:
+#endif
                errno = ENOSYS;
                return -1;
-       }
-
-       if (__sysno == __NR_finit_module) {
+       case __NR_finit_module:
                const char *args;
                int flags;
                int fd;
@@ -352,9 +354,7 @@ TS_EXPORT long int syscall(long int __sysno, ...)
 
                va_end(ap);
                return ret;
-       }
-
-       if (__sysno == __NR_gettid) {
+       case __NR_gettid:
                static long (*nextlib_syscall)(long number, ...);
 
                if (nextlib_syscall == NULL) {
@@ -370,13 +370,6 @@ TS_EXPORT long int syscall(long int __sysno, ...)
                return nextlib_syscall(__NR_gettid);
        }
 
-#ifdef __NR_riscv_hwprobe
-       if (__sysno == __NR_riscv_hwprobe) {
-               errno = ENOSYS;
-               return -1;
-       }
-#endif
-
        /*
         * FIXME: no way to call the libc function due since this is a
         * variadic argument function and we don't have a vsyscall() variant