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 --- ubus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ubus.c') diff --git a/ubus.c b/ubus.c index 7f4821d..4d05786 100644 --- a/ubus.c +++ b/ubus.c @@ -1132,7 +1132,7 @@ netifd_handle_iface(struct ubus_context *ctx, struct ubus_object *obj, { struct interface *iface; struct blob_attr *tb; - int i; + size_t i; blobmsg_parse(&iface_policy, 1, &tb, blob_data(msg), blob_len(msg)); if (!tb) @@ -1158,7 +1158,7 @@ netifd_handle_iface(struct ubus_context *ctx, struct ubus_object *obj, static void netifd_add_iface_object(void) { struct ubus_method *methods; - int i; + size_t i; methods = calloc(1, sizeof(iface_object_methods)); if (!methods) -- cgit v1.2.1