}
static char* disk_description(const char *path) {
-
static const char name_fields[] =
"ID_PART_ENTRY_NAME\0"
"DM_NAME\0"
"ID_MODEL\0";
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
+ const char *i, *name;
struct stat st;
- const char *i;
- int r;
assert(path);
if (!S_ISBLK(st.st_mode))
return NULL;
- r = sd_device_new_from_devnum(&device, 'b', st.st_rdev);
- if (r < 0)
+ if (sd_device_new_from_devnum(&device, 'b', st.st_rdev) < 0)
return NULL;
- NULSTR_FOREACH(i, name_fields) {
- const char *name;
-
- r = sd_device_get_property_value(device, i, &name);
- if (r >= 0 && !isempty(name))
+ NULSTR_FOREACH(i, name_fields)
+ if (sd_device_get_property_value(device, i, &name) >= 0 &&
+ !isempty(name))
return strdup(name);
- }
return NULL;
}
root_directory = true;
}
- r = sd_device_get_property_value(dev, "ID_FS_TYPE", &type);
- if (r >= 0) {
+ if (sd_device_get_property_value(dev, "ID_FS_TYPE", &type) >= 0) {
r = fsck_exists(type);
if (r < 0)
log_warning_errno(r, "Couldn't detect if fsck.%s may be used for %s, proceeding: %m", type, device);
static bool arg_all = false;
static char *link_get_type_string(unsigned short iftype, sd_device *d) {
- const char *t;
+ const char *t, *devtype;
char *p;
- if (d) {
- const char *devtype = NULL;
-
- (void) sd_device_get_devtype(d, &devtype);
- if (!isempty(devtype))
- return strdup(devtype);
- }
+ if (d &&
+ sd_device_get_devtype(d, &devtype) >= 0 &&
+ !isempty(devtype))
+ return strdup(devtype);
t = arphrd_to_name(iftype);
if (!t)
(void) sd_device_get_property_value(d, "ID_NET_DRIVER", &driver);
(void) sd_device_get_property_value(d, "ID_PATH", &path);
- r = sd_device_get_property_value(d, "ID_VENDOR_FROM_DATABASE", &vendor);
- if (r < 0)
+ if (sd_device_get_property_value(d, "ID_VENDOR_FROM_DATABASE", &vendor) < 0)
(void) sd_device_get_property_value(d, "ID_VENDOR", &vendor);
- r = sd_device_get_property_value(d, "ID_MODEL_FROM_DATABASE", &model);
- if (r < 0)
+ if (sd_device_get_property_value(d, "ID_MODEL_FROM_DATABASE", &model) < 0)
(void) sd_device_get_property_value(d, "ID_MODEL", &model);
}