From: Dustin Spicuzza Date: Wed, 19 Apr 2023 17:44:56 +0000 (-0400) Subject: device: Log error message if device initialization failed X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=c59457f697095631559d7e268ea575e7568d8866;p=project%2Fnetifd.git device: Log error message if device initialization failed Signed-off-by: Dustin Spicuzza --- diff --git a/device.c b/device.c index b352ee3..eef6ca6 100644 --- 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);