]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin: fix return value of udev_builtin_hwdb()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Oct 2018 17:42:02 +0000 (02:42 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 23 Oct 2018 19:30:05 +0000 (04:30 +0900)
This fixes a bug introduced by d354690e7d0429338cdd1c2cfe1fdd08fc53da9e.
Also, this adds more debug logs.

src/udev/udev-builtin-hwdb.c

index 3beb433589f8e818abb338b062764f75659c44a0..ccad98e89216ed53fb630406d25c6e5cd68f36a7 100644 (file)
@@ -9,6 +9,7 @@
 #include "sd-hwdb.h"
 
 #include "alloc-util.h"
+#include "device-util.h"
 #include "hwdb-util.h"
 #include "parse-util.h"
 #include "string-util.h"
@@ -159,17 +160,28 @@ static int builtin_hwdb(sd_device *dev, int argc, char *argv[], bool test) {
         }
 
         /* query a specific key given as argument */
-        if (argv[optind])
-                return udev_builtin_hwdb_lookup(dev, prefix, argv[optind], filter, test);
+        if (argv[optind]) {
+                r = udev_builtin_hwdb_lookup(dev, prefix, argv[optind], filter, test);
+                if (r < 0)
+                        return log_device_debug_errno(dev, r, "Failed to lookup hwdb: %m");
+                if (r == 0)
+                        return log_device_debug_errno(dev, ENOENT, "No entry found from hwdb: %m");
+                return r;
+        }
 
         /* read data from another device than the device we will store the data */
         if (device) {
                 r = sd_device_new_from_device_id(&srcdev, device);
                 if (r < 0)
-                        return r;
+                        return log_device_debug_errno(dev, r, "Failed to create sd_device object '%s': %m", device);
         }
 
-        return udev_builtin_hwdb_search(dev, srcdev, subsystem, prefix, filter, test);
+        r = udev_builtin_hwdb_search(dev, srcdev, subsystem, prefix, filter, test);
+        if (r < 0)
+                return log_device_debug_errno(dev, r, "Failed to lookup hwdb: %m");
+        if (r == 0)
+                return log_device_debug_errno(dev, ENOENT, "No entry found from hwdb: %m");
+        return r;
 }
 
 /* called at udev startup and reload */