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 --- interface-ip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'interface-ip.c') diff --git a/interface-ip.c b/interface-ip.c index ab4a5cf..7359db2 100644 --- a/interface-ip.c +++ b/interface-ip.c @@ -99,7 +99,7 @@ static struct uloop_timeout valid_until_timeout; static void clear_if_addr(union if_addr *a, int mask) { - int m_bytes = (mask + 7) / 8; + size_t m_bytes = (mask + 7) / 8; uint8_t m_clear = (1 << (m_bytes * 8 - mask)) - 1; uint8_t *p = (uint8_t *) a; -- cgit v1.2.1