diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-21 14:06:41 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-11-22 23:49:55 +0900 |
commit | fd05c424c0d781ba0e86700095c61938339df991 (patch) | |
tree | 054443397b686506d59578730b82c9d6c55b4915 /src/libudev/libudev-hwdb.c | |
parent | 6f9fe5818962a142d9277e99febe0e930d2ba2fa (diff) | |
download | systemd-fd05c424c0d781ba0e86700095c61938339df991.tar.gz |
libudev: introduce return_with_errno() and use it where applicable
Diffstat (limited to 'src/libudev/libudev-hwdb.c')
-rw-r--r-- | src/libudev/libudev-hwdb.c | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/src/libudev/libudev-hwdb.c b/src/libudev/libudev-hwdb.c index 65b98c04d0..ed755e5d3c 100644 --- a/src/libudev/libudev-hwdb.c +++ b/src/libudev/libudev-hwdb.c @@ -40,16 +40,12 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) { int r; r = sd_hwdb_new(&hwdb_internal); - if (r < 0) { - errno = -r; - return NULL; - } + if (r < 0) + return_with_errno(NULL, r); hwdb = new(struct udev_hwdb, 1); - if (!hwdb) { - errno = ENOMEM; - return NULL; - } + if (!hwdb) + return_with_errno(NULL, ENOMEM); *hwdb = (struct udev_hwdb) { .n_ref = 1, @@ -111,16 +107,13 @@ _public_ struct udev_list_entry *udev_hwdb_get_properties_list_entry(struct udev udev_list_cleanup(&hwdb->properties_list); - SD_HWDB_FOREACH_PROPERTY(hwdb->hwdb, modalias, key, value) { - if (!udev_list_entry_add(&hwdb->properties_list, key, value)) { - errno = ENOMEM; - return NULL; - } - } + SD_HWDB_FOREACH_PROPERTY(hwdb->hwdb, modalias, key, value) + if (!udev_list_entry_add(&hwdb->properties_list, key, value)) + return_with_errno(NULL, ENOMEM); e = udev_list_get_entry(&hwdb->properties_list); if (!e) - errno = ENODATA; + return_with_errno(NULL, ENODATA); return e; } |