1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-06 08:26:52 +03:00

sd-device: fix return codes on error

asprintf() does not set errno.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2015-05-20 23:34:12 -04:00
parent 925fbb9f80
commit 53fae771bc
2 changed files with 6 additions and 6 deletions

View File

@ -764,9 +764,9 @@ static int parent_crawl_children(sd_device_enumerator *enumerator, const char *p
if (dent->d_type != DT_DIR) if (dent->d_type != DT_DIR)
continue; continue;
k = asprintf(&child, "%s/%s", path, dent->d_name); child = strjoin(path, "/", dent->d_name, NULL);
if (k < 0) if (!child)
return -errno; return -ENOMEM;
k = parent_add_child(enumerator, child); k = parent_add_child(enumerator, child);
if (k < 0) if (k < 0)

View File

@ -1193,12 +1193,12 @@ int device_get_id_filename(sd_device *device, const char **ret) {
streq(subsystem, "block") ? 'b' : 'c', streq(subsystem, "block") ? 'b' : 'c',
major(devnum), minor(devnum)); major(devnum), minor(devnum));
if (r < 0) if (r < 0)
return -errno; return -ENOMEM;
} else if (ifindex > 0) { } else if (ifindex > 0) {
/* use netdev ifindex -- n3 */ /* use netdev ifindex -- n3 */
r = asprintf(&id, "n%u", ifindex); r = asprintf(&id, "n%u", ifindex);
if (r < 0) if (r < 0)
return -errno; return -ENOMEM;
} else { } else {
/* use $subsys:$sysname -- pci:0000:00:1f.2 /* use $subsys:$sysname -- pci:0000:00:1f.2
* sysname() has '!' translated, get it from devpath * 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); r = asprintf(&id, "+%s:%s", subsystem, sysname);
if (r < 0) if (r < 0)
return -errno; return -ENOMEM;
} }
device->id_filename = id; device->id_filename = id;