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);
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';
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;
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);
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);
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)
/* 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 &&