From d9b3e99656922a9b8772c9f9c7eca512e991a5bd Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 14 Oct 2018 01:06:50 +0900 Subject: [PATCH] udev: replace udev_device by sd_device in udev-builtin-net_setup_link.c --- src/udev/udev-builtin-net_setup_link.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c index 68e80a9978..e328e5ecd8 100644 --- a/src/udev/udev-builtin-net_setup_link.c +++ b/src/udev/udev-builtin-net_setup_link.c @@ -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; } -- 2.25.1