From: Mike Yuan Date: Fri, 17 Nov 2023 12:37:26 +0000 (+0800) Subject: networkctl: use RET_GATHER more X-Git-Tag: v256-rc1~1567^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9b7408eb90918aace3b8153a8db1ca49dbb64f6;p=thirdparty%2Fsystemd.git networkctl: use RET_GATHER more --- diff --git a/src/network/networkctl.c b/src/network/networkctl.c index ec31e8eb444..d69d37fcd16 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -2741,23 +2741,25 @@ static int link_renew_one(sd_bus *bus, int index, const char *name) { static int link_renew(int argc, char *argv[], void *userdata) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; - int index, k = 0, r; + int r; r = acquire_bus(&bus); if (r < 0) return r; + r = 0; + for (int i = 1; i < argc; i++) { + int index; + index = rtnl_resolve_interface_or_warn(&rtnl, argv[i]); if (index < 0) return index; - r = link_renew_one(bus, index, argv[i]); - if (r < 0 && k >= 0) - k = r; + RET_GATHER(r, link_renew_one(bus, index, argv[i])); } - return k; + return r; } static int link_force_renew_one(sd_bus *bus, int index, const char *name) { @@ -3281,23 +3283,22 @@ static int verb_cat(int argc, char *argv[], void *userdata) { if (link_config) { r = get_config_files_by_link_config(link_config, &rtnl, &path, &dropins, /* ret_reload = */ NULL); if (r < 0) - return ret < 0 ? ret : r; + return RET_GATHER(ret, r); } else { r = get_config_files_by_name(*name, &path, &dropins); if (r == -ENOENT) { - log_error_errno(r, "Cannot find network config file '%s'.", *name); - ret = ret < 0 ? ret : r; + RET_GATHER(ret, log_error_errno(r, "Cannot find network config file '%s'.", *name)); continue; } if (r < 0) { log_error_errno(r, "Failed to get the path of network config '%s': %m", *name); - return ret < 0 ? ret : r; + return RET_GATHER(ret, r); } } r = cat_files(path, dropins, /* flags = */ CAT_FORMAT_HAS_SECTIONS); if (r < 0) - return ret < 0 ? ret : r; + return RET_GATHER(ret, r); } return ret;