summaryrefslogtreecommitdiff
path: root/src/udev/udev-builtin-hwdb.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-10-23 18:26:06 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-10-23 18:29:25 +0900
commitd354690e7d0429338cdd1c2cfe1fdd08fc53da9e (patch)
treed973cacc0865e3ddcb222692459bc8d887ebfa09 /src/udev/udev-builtin-hwdb.c
parent45a73f4be32481eacdb652c0869d69025fab354c (diff)
downloadsystemd-d354690e7d0429338cdd1c2cfe1fdd08fc53da9e.tar.gz
systemd-d354690e7d0429338cdd1c2cfe1fdd08fc53da9e.tar.bz2
systemd-d354690e7d0429338cdd1c2cfe1fdd08fc53da9e.zip
udev-builtin: propagate negative errno
Diffstat (limited to 'src/udev/udev-builtin-hwdb.c')
-rw-r--r--src/udev/udev-builtin-hwdb.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/udev/udev-builtin-hwdb.c b/src/udev/udev-builtin-hwdb.c
index 5a905c3b66..3beb433589 100644
--- a/src/udev/udev-builtin-hwdb.c
+++ b/src/udev/udev-builtin-hwdb.c
@@ -127,9 +127,10 @@ static int builtin_hwdb(sd_device *dev, int argc, char *argv[], bool test) {
const char *subsystem = NULL;
const char *prefix = NULL;
_cleanup_(sd_device_unrefp) sd_device *srcdev = NULL;
+ int r;
if (!hwdb)
- return EXIT_FAILURE;
+ return -EINVAL;
for (;;) {
int option;
@@ -158,21 +159,17 @@ static int builtin_hwdb(sd_device *dev, int argc, char *argv[], bool test) {
}
/* query a specific key given as argument */
- if (argv[optind]) {
- if (udev_builtin_hwdb_lookup(dev, prefix, argv[optind], filter, test) > 0)
- return EXIT_SUCCESS;
- return EXIT_FAILURE;
- }
+ if (argv[optind])
+ return udev_builtin_hwdb_lookup(dev, prefix, argv[optind], filter, test);
/* read data from another device than the device we will store the data */
- if (device)
- if (sd_device_new_from_device_id(&srcdev, device) < 0)
- return EXIT_FAILURE;
-
- if (udev_builtin_hwdb_search(dev, srcdev, subsystem, prefix, filter, test) > 0)
- return EXIT_SUCCESS;
+ if (device) {
+ r = sd_device_new_from_device_id(&srcdev, device);
+ if (r < 0)
+ return r;
+ }
- return EXIT_FAILURE;
+ return udev_builtin_hwdb_search(dev, srcdev, subsystem, prefix, filter, test);
}
/* called at udev startup and reload */