]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: make sd_device_get_devname() failure non-fatal
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Oct 2018 19:04:35 +0000 (04:04 +0900)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Oct 2018 16:02:23 +0000 (18:02 +0200)
As it is just for logging.

Follow-up for eb276e98419af59d4a587f2dd37e0b923e4c6fd2.

src/udev/udev-watch.c

index 04182b2e151dee3b8d3f086aef688c926935ab4c..3f5885c52e5b8059b74ce46958a815fa6fe1e471 100644 (file)
@@ -121,23 +121,22 @@ int udev_watch_begin(sd_device *dev) {
 
 int udev_watch_end(sd_device *dev) {
         char filename[STRLEN("/run/udev/watch/") + DECIMAL_STR_MAX(int)];
-        const char *devnode;
+        const char *name = NULL;
         int wd, r;
 
         if (inotify_fd < 0)
                 return log_error_errno(EINVAL, "Invalid inotify descriptor.");
 
-        r = sd_device_get_devname(dev, &devnode);
-        if (r < 0)
-                return log_error_errno(r, "Failed to get device name: %m");
+        if (sd_device_get_devname(dev, &name) < 0)
+                (void) sd_device_get_syspath(dev, &name);
 
         r = device_get_watch_handle(dev, &wd);
         if (r == -ENOENT)
                 return 0;
         if (r < 0)
-                return log_error_errno(r, "Failed to get watch handle for device '%s', ignoring: %m", devnode);
+                return log_error_errno(r, "Failed to get watch handle for device '%s', ignoring: %m", strnull(name));
 
-        log_debug("Removing watch on '%s'", devnode);
+        log_debug("Removing watch on '%s'", strnull(name));
         (void) inotify_rm_watch(inotify_fd, wd);
 
         xsprintf(filename, "/run/udev/watch/%d", wd);