device: Log error message if device initialization failed
authorDustin Spicuzza <dustin@virtualroadside.com>
Wed, 19 Apr 2023 17:44:56 +0000 (13:44 -0400)
committerFelix Fietkau <nbd@nbd.name>
Mon, 18 Dec 2023 10:47:15 +0000 (11:47 +0100)
Signed-off-by: Dustin Spicuzza <dustin@virtualroadside.com>
device.c

index b352ee346d141356310c7eb12e78a4a241645ec2..eef6ca6d662fe1053e302a03b05bc9e83c9ad12a 100644 (file)
--- a/device.c
+++ b/device.c
@@ -758,8 +758,10 @@ int device_init_virtual(struct device *dev, struct device_type *type, const char
                int ret;
 
                ret = device_set_ifname(dev, name);
-               if (ret < 0)
+               if (ret < 0) {
+                       netifd_log_message(L_WARNING, "Failed to initalize device '%s'\n", name);
                        return ret;
+               }
        }
 
        if (!dev->set_state)
@@ -977,8 +979,11 @@ int device_set_ifname(struct device *dev, const char *name)
        if (!strcmp(dev->ifname, name))
                return 0;
 
-       if (strlen(name) > sizeof(dev->ifname) - 1)
+       if (strlen(name) > sizeof(dev->ifname) - 1) {
+               netifd_log_message(L_WARNING, "Cannot set device name: '%s' is longer than max size %zd\n",
+                       name, sizeof(dev->ifname) - 1);
                return -1;
+       }
 
        if (dev->avl.key)
                avl_delete(&devices, &dev->avl);