From: Thomas Weißschuh Date: Sun, 23 Jul 2023 20:05:48 +0000 (+0200) Subject: enosys: avoid warnings when no aliases are found X-Git-Tag: v2.40-rc1~275^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1078c4ae93562934a8625a6d314d17a7af370910;p=thirdparty%2Futil-linux.git enosys: avoid warnings when no aliases are found Signed-off-by: Thomas Weißschuh --- diff --git a/misc-utils/enosys.c b/misc-utils/enosys.c index 8415c63b5c..81e9323637 100644 --- a/misc-utils/enosys.c +++ b/misc-utils/enosys.c @@ -58,6 +58,13 @@ struct syscall { long number; }; +/* When the alias arrays are empty the compiler emits -Wtype-limits warnings. + * Avoid those by going through this function. */ +static inline bool lt(size_t a, size_t b) +{ + return a < b; +} + static const struct syscall syscalls[] = { #define UL_SYSCALL(name, nr) { name, nr }, #include "syscalls.h" @@ -124,7 +131,7 @@ int main(int argc, char **argv) switch (c) { case 's': found = 0; - for (i = 0; i < ARRAY_SIZE(syscalls); i++) { + for (i = 0; lt(i, ARRAY_SIZE(syscalls)); i++) { if (strcmp(optarg, syscalls[i].name) == 0) { blocked_number = syscalls[i].number; found = 1; @@ -142,7 +149,7 @@ int main(int argc, char **argv) break; case 'i': found = 0; - for (i = 0; i < ARRAY_SIZE(ioctls); i++) { + for (i = 0; lt(i, ARRAY_SIZE(ioctls)); i++) { if (strcmp(optarg, ioctls[i].name) == 0) { blocked_number = ioctls[i].number; found = 1; @@ -159,11 +166,11 @@ int main(int argc, char **argv) break; case 'l': - for (i = 0; i < ARRAY_SIZE(syscalls); i++) + for (i = 0; lt(i, ARRAY_SIZE(syscalls)); i++) printf("%5ld %s\n", syscalls[i].number, syscalls[i].name); return EXIT_SUCCESS; case 'm': - for (i = 0; i < ARRAY_SIZE(ioctls); i++) + for (i = 0; lt(i, ARRAY_SIZE(ioctls)); i++) printf("%5ld %s\n", ioctls[i].number, ioctls[i].name); return EXIT_SUCCESS; case 'V':