From 19372d8528d25d9774c1c6ede2642bdf57ce3cc3 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 12 Feb 2023 21:07:31 +0100 Subject: netifd: Fix multiple -Wsign-compare warnings This fixes warnings like this: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare] Mostly this was an int compared to a size_t returned by ARRAY_SIZE(). The easiest fix is to count on the size_t type. The ifindex is sometimes an unsigned int and sometimes a signed int in the kernel interfaces. I think it normally fits into an unsigned 16 bit value, so this should be fine. Do the one comparison where the compiler complains as a long. Casting the result of sizeof() to int should be safe. These values are never out of range of int. Signed-off-by: Hauke Mehrtens --- handler.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'handler.c') diff --git a/handler.c b/handler.c index 04bdbee..78fc9a0 100644 --- a/handler.c +++ b/handler.c @@ -229,7 +229,8 @@ netifd_parse_extdev_handler(const char *path_to_file, create_extdev_handler_cb c void netifd_init_script_handlers(int dir_fd, script_dump_cb cb) { glob_t g; - int i, prev_fd; + int prev_fd; + size_t i; prev_fd = netifd_dir_push(dir_fd); if (glob("./*.sh", 0, NULL, &g)) { @@ -252,7 +253,7 @@ netifd_init_extdev_handlers(int dir_fd, create_extdev_handler_cb cb) prev_fd = netifd_dir_push(dir_fd); glob("*.json", 0, NULL, &g); - for (int i = 0; i < g.gl_pathc; i++) + for (size_t i = 0; i < g.gl_pathc; i++) netifd_parse_extdev_handler(g.gl_pathv[i], cb); netifd_dir_pop(prev_fd); } -- cgit v1.2.1