From 5d845ab29ac2c335d3061eae050f5d8686b73980 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Tue, 8 Jul 2025 07:38:58 -0500 Subject: [PATCH] testsuite: simplify syscall number handling Use a switch() statement for syscall override handling, making it a little bit less verbose. Signed-off-by: Lucas De Marchi Reviewed-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/387 --- testsuite/init_module.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/testsuite/init_module.c b/testsuite/init_module.c index c419aa3e..6ad95d7f 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -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 -- 2.39.5