]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: replace udev_device by sd_device in udev-builtin-net_setup_link.c
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 13 Oct 2018 16:06:50 +0000 (01:06 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Oct 2018 09:28:38 +0000 (18:28 +0900)
src/udev/udev-builtin-net_setup_link.c

index 68e80a99789b17572db28ad1c82a570f82beab1d..e328e5ecd8e3b294da0e15b3806defff80d7a85b 100644 (file)
@@ -1,29 +1,30 @@
 /* SPDX-License-Identifier: LGPL-2.1+ */
 
 #include "alloc-util.h"
-#include "libudev-device-internal.h"
 #include "link-config.h"
 #include "log.h"
+#include "string-util.h"
 #include "udev-builtin.h"
 
 static link_config_ctx *ctx = NULL;
 
-static int builtin_net_setup_link(struct udev_device *dev, int argc, char **argv, bool test) {
+static int builtin_net_setup_link(struct udev_device *_dev, int argc, char **argv, bool test) {
         _cleanup_free_ char *driver = NULL;
         const char *name = NULL;
         link_config *link;
         int r;
+        sd_device *dev = _dev->device;
 
         if (argc > 1) {
                 log_error("This program takes no arguments.");
                 return EXIT_FAILURE;
         }
 
-        r = link_get_driver(ctx, dev->device, &driver);
+        r = link_get_driver(ctx, dev, &driver);
         if (r >= 0)
-                udev_builtin_add_property(dev->device, test, "ID_NET_DRIVER", driver);
+                udev_builtin_add_property(dev, test, "ID_NET_DRIVER", driver);
 
-        r = link_config_get(ctx, dev->device, &link);
+        r = link_config_get(ctx, dev, &link);
         if (r < 0) {
                 if (r == -ENOENT) {
                         log_debug("No matching link configuration found.");
@@ -34,14 +35,18 @@ static int builtin_net_setup_link(struct udev_device *dev, int argc, char **argv
                 }
         }
 
-        r = link_config_apply(ctx, link, dev->device, &name);
-        if (r < 0)
-                log_warning_errno(r, "Could not apply link config to %s, ignoring: %m", udev_device_get_sysname(dev));
+        r = link_config_apply(ctx, link, dev, &name);
+        if (r < 0) {
+                const char *sysname = NULL;
+
+                (void) sd_device_get_sysname(dev, &sysname);
+                log_warning_errno(r, "Could not apply link config to %s, ignoring: %m", strnull(sysname));
+        }
 
-        udev_builtin_add_property(dev->device, test, "ID_NET_LINK_FILE", link->filename);
+        udev_builtin_add_property(dev, test, "ID_NET_LINK_FILE", link->filename);
 
         if (name)
-                udev_builtin_add_property(dev->device, test, "ID_NET_NAME", name);
+                udev_builtin_add_property(dev, test, "ID_NET_NAME", name);
 
         return EXIT_SUCCESS;
 }