summaryrefslogtreecommitdiff
path: root/vlan.c
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2023-02-12 21:07:31 +0100
committerHauke Mehrtens <hauke@hauke-m.de>2023-02-19 16:08:28 +0100
commit19372d8528d25d9774c1c6ede2642bdf57ce3cc3 (patch)
treed7bdc939ff703af66c9b884d9f28dab1ce0bc2df /vlan.c
parented65a00adc751d102c2041a4a9a32df9dad52b9e (diff)
downloadnetifd-19372d8528d25d9774c1c6ede2642bdf57ce3cc3.tar.gz
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 <hauke@hauke-m.de>
Diffstat (limited to 'vlan.c')
-rw-r--r--vlan.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/vlan.c b/vlan.c
index 3d444a9..4d32b60 100644
--- a/vlan.c
+++ b/vlan.c
@@ -143,7 +143,7 @@ static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
vlan_hotplug_check(vldev, dep->dev);
vldev->dev.hidden = dep->dev->hidden;
if (snprintf(name, sizeof(name), "%s.%d", dep->dev->ifname,
- vldev->id) >= sizeof(name) - 1 ||
+ vldev->id) >= (int)sizeof(name) - 1 ||
device_set_ifname(&vldev->dev, name))
free_vlan_if(&vldev->dev);
break;
@@ -203,7 +203,7 @@ static struct device *get_vlan_device(struct device *dev, char *id_str, bool cre
if (!create)
return NULL;
- if (snprintf(name, sizeof(name), "%s.%d", dev->ifname, id) >= sizeof(name) - 1)
+ if (snprintf(name, sizeof(name), "%s.%d", dev->ifname, id) >= (int)sizeof(name) - 1)
return NULL;
D(DEVICE, "Create vlan device '%s'\n", name);