summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-07-16 18:04:45 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-07-16 22:08:12 +0200
commit9e79123884a36ce095b98d1c0fe247dddf02dbec (patch)
tree44aa6f24493ba003d091f802fc51cff52c78b61d /src
parent46d4149d0f89c66b7cf856b7a0d6ffe3478f6d17 (diff)
downloadsystemd-9e79123884a36ce095b98d1c0fe247dddf02dbec.tar.gz
tree-wide: use SYNTHETIC_ERRNO with log_device_* in more places
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-device/device-monitor.c7
-rw-r--r--src/libsystemd/sd-device/device-private.c22
-rw-r--r--src/mount/mount-tool.c14
-rw-r--r--src/udev/udev-node.c8
4 files changed, 23 insertions, 28 deletions
diff --git a/src/libsystemd/sd-device/device-monitor.c b/src/libsystemd/sd-device/device-monitor.c
index ffec11bbd3..bed45da8e4 100644
--- a/src/libsystemd/sd-device/device-monitor.c
+++ b/src/libsystemd/sd-device/device-monitor.c
@@ -558,10 +558,9 @@ int device_monitor_send_device(
r = device_get_properties_nulstr(device, (const uint8_t **) &buf, &blen);
if (r < 0)
return log_device_debug_errno(device, r, "sd-device-monitor: Failed to get device properties: %m");
- if (blen < 32) {
- log_device_debug(device, "sd-device-monitor: Length of device property nulstr is too small to contain valid device information");
- return -EINVAL;
- }
+ if (blen < 32)
+ log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
+ "sd-device-monitor: Length of device property nulstr is too small to contain valid device information");
/* fill in versioned header */
r = sd_device_get_subsystem(device, &val);
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
index 16f8627bdb..1e61732dfe 100644
--- a/src/libsystemd/sd-device/device-private.c
+++ b/src/libsystemd/sd-device/device-private.c
@@ -363,10 +363,9 @@ static int device_append(sd_device *device, char *key, const char **_major, cons
assert(_minor);
value = strchr(key, '=');
- if (!value) {
- log_device_debug(device, "sd-device: Not a key-value pair: '%s'", key);
- return -EINVAL;
- }
+ if (!value)
+ return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
+ "sd-device: Not a key-value pair: '%s'", key);
*value = '\0';
@@ -400,10 +399,9 @@ void device_seal(sd_device *device) {
static int device_verify(sd_device *device) {
assert(device);
- if (!device->devpath || !device->subsystem || device->action < 0 || device->seqnum == 0) {
- log_device_debug(device, "sd-device: Device created from strv or nulstr lacks devpath, subsystem, action or seqnum.");
- return -EINVAL;
- }
+ if (!device->devpath || !device->subsystem || device->action < 0 || device->seqnum == 0)
+ return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
+ "sd-device: Device created from strv or nulstr lacks devpath, subsystem, action or seqnum.");
device->sealed = true;
@@ -464,10 +462,10 @@ int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) {
key = (char*)&nulstr[i];
end = memchr(key, '\0', len - i);
- if (!end) {
- log_device_debug(device, "sd-device: Failed to parse nulstr");
- return -EINVAL;
- }
+ if (!end)
+ return log_device_debug_errno(device, SYNTHETIC_ERRNO(EINVAL),
+ "sd-device: Failed to parse nulstr");
+
i += end - key + 1;
r = device_append(device, key, &major, &minor);
diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c
index 84d5288c75..f5873d1c06 100644
--- a/src/mount/mount-tool.c
+++ b/src/mount/mount-tool.c
@@ -936,10 +936,9 @@ static int umount_by_device(sd_bus *bus, const char *what) {
if (r < 0)
return log_device_error_errno(d, r, "Failed to get device property: %m");
- if (!streq(v, "filesystem")) {
- log_device_error(d, "%s does not contain a known file system.", what);
- return -EINVAL;
- }
+ if (!streq(v, "filesystem"))
+ return log_device_error_errno(d, SYNTHETIC_ERRNO(EINVAL),
+ "%s does not contain a known file system.", what);
if (sd_device_get_property_value(d, "SYSTEMD_MOUNT_WHERE", &v) >= 0)
r2 = stop_mounts(bus, v);
@@ -1275,10 +1274,9 @@ static int discover_loop_backing_file(void) {
if (r < 0)
return log_error_errno(r, "Failed to get device from device number: %m");
- if (sd_device_get_property_value(d, "ID_FS_USAGE", &v) < 0 || !streq(v, "filesystem")) {
- log_device_error(d, "%s does not contain a known file system.", arg_mount_what);
- return -EINVAL;
- }
+ if (sd_device_get_property_value(d, "ID_FS_USAGE", &v) < 0 || !streq(v, "filesystem"))
+ return log_device_error_errno(d, SYNTHETIC_ERRNO(EINVAL),
+ "%s does not contain a known file system.", arg_mount_what);
r = acquire_mount_type(d);
if (r < 0)
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index a34b8d6945..31a3403093 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -47,10 +47,10 @@ static int node_symlink(sd_device *dev, const char *node, const char *slink) {
/* preserve link with correct target, do not replace node of other device */
if (lstat(slink, &stats) == 0) {
- if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode)) {
- log_device_error(dev, "Conflicting device node '%s' found, link to '%s' will not be created.", slink, node);
- return -EOPNOTSUPP;
- } else if (S_ISLNK(stats.st_mode)) {
+ if (S_ISBLK(stats.st_mode) || S_ISCHR(stats.st_mode))
+ return log_device_error_errno(dev, SYNTHETIC_ERRNO(EOPNOTSUPP),
+ "Conflicting device node '%s' found, link to '%s' will not be created.", slink, node);
+ else if (S_ISLNK(stats.st_mode)) {
_cleanup_free_ char *buf = NULL;
if (readlink_malloc(slink, &buf) >= 0 &&