Skip to content

Commit 535b70c

Browse files
committed
tools/nolibc: avoid unused parameter warnings for ENOSYS fallbacks
The ENOSYS fallback code does not use its functions parameters. This can lead to compiler warnings about unused parameters. Explicitly avoid these warnings. Signed-off-by: Thomas Weißschuh <[email protected]> Acked-by: Willy Tarreau <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9531548 commit 535b70c

File tree

1 file changed

+27
-17
lines changed
  • tools/include/nolibc

1 file changed

+27
-17
lines changed

tools/include/nolibc/sys.h

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@
4343
: __sysret_arg; /* return original value */ \
4444
})
4545

46+
/* Syscall ENOSYS helper: Avoids unused-parameter warnings and provides a
47+
* debugging hook.
48+
*/
49+
50+
static __inline__ int __nolibc_enosys(const char *syscall, ...)
51+
{
52+
(void)syscall;
53+
return -ENOSYS;
54+
}
55+
4656

4757
/* Functions in this file only describe syscalls. They're declared static so
4858
* that the compiler usually decides to inline them while still being allowed
@@ -133,7 +143,7 @@ int sys_chmod(const char *path, mode_t mode)
133143
#elif defined(__NR_chmod)
134144
return my_syscall2(__NR_chmod, path, mode);
135145
#else
136-
return -ENOSYS;
146+
return __nolibc_enosys(__func__, path, mode);
137147
#endif
138148
}
139149

@@ -156,7 +166,7 @@ int sys_chown(const char *path, uid_t owner, gid_t group)
156166
#elif defined(__NR_chown)
157167
return my_syscall3(__NR_chown, path, owner, group);
158168
#else
159-
return -ENOSYS;
169+
return __nolibc_enosys(__func__, path, owner, group);
160170
#endif
161171
}
162172

@@ -230,7 +240,7 @@ int sys_dup2(int old, int new)
230240
#elif defined(__NR_dup2)
231241
return my_syscall2(__NR_dup2, old, new);
232242
#else
233-
return -ENOSYS;
243+
return __nolibc_enosys(__func__, old, new);
234244
#endif
235245
}
236246

@@ -312,7 +322,7 @@ pid_t sys_fork(void)
312322
#elif defined(__NR_fork)
313323
return my_syscall0(__NR_fork);
314324
#else
315-
return -ENOSYS;
325+
return __nolibc_enosys(__func__);
316326
#endif
317327
}
318328
#endif
@@ -486,7 +496,7 @@ int sys_gettimeofday(struct timeval *tv, struct timezone *tz)
486496
#ifdef __NR_gettimeofday
487497
return my_syscall2(__NR_gettimeofday, tv, tz);
488498
#else
489-
return -ENOSYS;
499+
return __nolibc_enosys(__func__, tv, tz);
490500
#endif
491501
}
492502

@@ -563,7 +573,7 @@ int sys_link(const char *old, const char *new)
563573
#elif defined(__NR_link)
564574
return my_syscall2(__NR_link, old, new);
565575
#else
566-
return -ENOSYS;
576+
return __nolibc_enosys(__func__, old, new);
567577
#endif
568578
}
569579

@@ -584,7 +594,7 @@ off_t sys_lseek(int fd, off_t offset, int whence)
584594
#ifdef __NR_lseek
585595
return my_syscall3(__NR_lseek, fd, offset, whence);
586596
#else
587-
return -ENOSYS;
597+
return __nolibc_enosys(__func__, fd, offset, whence);
588598
#endif
589599
}
590600

@@ -607,7 +617,7 @@ int sys_mkdir(const char *path, mode_t mode)
607617
#elif defined(__NR_mkdir)
608618
return my_syscall2(__NR_mkdir, path, mode);
609619
#else
610-
return -ENOSYS;
620+
return __nolibc_enosys(__func__, path, mode);
611621
#endif
612622
}
613623

@@ -629,7 +639,7 @@ int sys_rmdir(const char *path)
629639
#elif defined(__NR_unlinkat)
630640
return my_syscall3(__NR_unlinkat, AT_FDCWD, path, AT_REMOVEDIR);
631641
#else
632-
return -ENOSYS;
642+
return __nolibc_enosys(__func__, path);
633643
#endif
634644
}
635645

@@ -652,7 +662,7 @@ long sys_mknod(const char *path, mode_t mode, dev_t dev)
652662
#elif defined(__NR_mknod)
653663
return my_syscall3(__NR_mknod, path, mode, dev);
654664
#else
655-
return -ENOSYS;
665+
return __nolibc_enosys(__func__, path, mode, dev);
656666
#endif
657667
}
658668

@@ -742,7 +752,7 @@ int sys_open(const char *path, int flags, mode_t mode)
742752
#elif defined(__NR_open)
743753
return my_syscall3(__NR_open, path, flags, mode);
744754
#else
745-
return -ENOSYS;
755+
return __nolibc_enosys(__func__, path, flags, mode);
746756
#endif
747757
}
748758

@@ -842,7 +852,7 @@ int sys_poll(struct pollfd *fds, int nfds, int timeout)
842852
#elif defined(__NR_poll)
843853
return my_syscall3(__NR_poll, fds, nfds, timeout);
844854
#else
845-
return -ENOSYS;
855+
return __nolibc_enosys(__func__, fds, nfds, timeout);
846856
#endif
847857
}
848858

@@ -934,7 +944,7 @@ int sys_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeva
934944
#endif
935945
return my_syscall5(__NR__newselect, nfds, rfds, wfds, efds, timeout);
936946
#else
937-
return -ENOSYS;
947+
return __nolibc_enosys(__func__, nfds, rfds, wfds, efds, timeout);
938948
#endif
939949
}
940950

@@ -989,7 +999,7 @@ int sys_statx(int fd, const char *path, int flags, unsigned int mask, struct sta
989999
#ifdef __NR_statx
9901000
return my_syscall5(__NR_statx, fd, path, flags, mask, buf);
9911001
#else
992-
return -ENOSYS;
1002+
return __nolibc_enosys(__func__, fd, path, flags, mask, buf);
9931003
#endif
9941004
}
9951005

@@ -1047,7 +1057,7 @@ int sys_symlink(const char *old, const char *new)
10471057
#elif defined(__NR_symlink)
10481058
return my_syscall2(__NR_symlink, old, new);
10491059
#else
1050-
return -ENOSYS;
1060+
return __nolibc_enosys(__func__, old, new);
10511061
#endif
10521062
}
10531063

@@ -1104,7 +1114,7 @@ int sys_unlink(const char *path)
11041114
#elif defined(__NR_unlink)
11051115
return my_syscall1(__NR_unlink, path);
11061116
#else
1107-
return -ENOSYS;
1117+
return __nolibc_enosys(__func__, path);
11081118
#endif
11091119
}
11101120

@@ -1127,7 +1137,7 @@ pid_t sys_wait4(pid_t pid, int *status, int options, struct rusage *rusage)
11271137
#ifdef __NR_wait4
11281138
return my_syscall4(__NR_wait4, pid, status, options, rusage);
11291139
#else
1130-
return -ENOSYS;
1140+
return __nolibc_enosys(__func__, pid, status, options, rusage);
11311141
#endif
11321142
}
11331143

0 commit comments

Comments
 (0)