chiark / gitweb /
sd-device: fix return codes on error
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 21 May 2015 03:34:12 +0000 (23:34 -0400)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 08:57:27 +0000 (09:57 +0100)
asprintf() does not set errno.

src/libelogind/sd-device/sd-device.c
src/libsystemd/sd-device/device-enumerator.c

index 691b9c6..97da4a8 100644 (file)
@@ -1193,12 +1193,12 @@ int device_get_id_filename(sd_device *device, const char **ret) {
                                      streq(subsystem, "block") ? 'b' : 'c',
                                      major(devnum), minor(devnum));
                         if (r < 0)
-                                return -errno;
+                                return -ENOMEM;
                 } else if (ifindex > 0) {
                         /* use netdev ifindex -- n3 */
                         r = asprintf(&id, "n%u", ifindex);
                         if (r < 0)
-                                return -errno;
+                                return -ENOMEM;
                 } else {
                         /* use $subsys:$sysname -- pci:0000:00:1f.2
                          * sysname() has '!' translated, get it from devpath
@@ -1211,7 +1211,7 @@ int device_get_id_filename(sd_device *device, const char **ret) {
 
                         r = asprintf(&id, "+%s:%s", subsystem, sysname);
                         if (r < 0)
-                                return -errno;
+                                return -ENOMEM;
                 }
 
                 device->id_filename = id;
index d59da7d..1d79aff 100644 (file)
@@ -771,9 +771,9 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p
                 if (dent->d_type != DT_DIR)
                         continue;
 
-                k = asprintf(&child, "%s/%s", path, dent->d_name);
-                if (k < 0)
-                        return -errno;
+                child = strjoin(path, "/", dent->d_name, NULL);
+                if (!child)
+                        return -ENOMEM;
 
                 k = parent_add_child(enumerator, child);
                 if (k < 0)