From 2c740afd1613a7ab5e70e39251767a3429c543cc Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 1 Sep 2018 23:12:47 +0900 Subject: [PATCH] tree-wide: do not assign unused return values --- src/cryptsetup/cryptsetup.c | 16 +++++----------- src/fsck/fsck.c | 3 +-- src/network/networkctl.c | 19 +++++++------------ 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index a622db8..b590d70 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -271,7 +271,6 @@ static int parse_options(const char *options) { } static char* disk_description(const char *path) { - static const char name_fields[] = "ID_PART_ENTRY_NAME\0" "DM_NAME\0" @@ -279,9 +278,8 @@ static char* disk_description(const char *path) { "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); @@ -291,17 +289,13 @@ static char* disk_description(const char *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; } diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c index 50f838a..132714f 100644 --- a/src/fsck/fsck.c +++ b/src/fsck/fsck.c @@ -357,8 +357,7 @@ int main(int argc, char *argv[]) { 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); diff --git a/src/network/networkctl.c b/src/network/networkctl.c index aaf1a14..c4a8fc8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -39,16 +39,13 @@ static bool arg_legend = true; 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) @@ -768,12 +765,10 @@ static int link_status_one( (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); } -- 2.7.4