No functional change indentended.
k = verify_prepare_filename(*filename, &prepared);
if (k < 0) {
log_warning_errno(k, "Failed to prepare filename %s: %m", *filename);
- if (r == 0)
- r = k;
+ RET_GATHER(r, k);
continue;
}
k = manager_load_startable_unit_or_warn(m, NULL, prepared, &units[count]);
if (k < 0) {
- if (r == 0)
- r = k;
+ RET_GATHER(r, k);
continue;
}
count++;
}
- for (size_t i = 0; i < count; i++) {
- k = offline_security_check(units[i], threshold, policy, pager_flags, json_format_flags);
- if (k < 0 && r == 0)
- r = k;
- }
+ for (size_t i = 0; i < count; i++)
+ RET_GATHER(r, offline_security_check(units[i], threshold, policy, pager_flags, json_format_flags));
return r;
}
}
static int verify_executables(Unit *u, const char *root) {
- ExecCommand *exec;
- int r = 0, k;
- unsigned i;
+ int r = 0;
assert(u);
- exec = u->type == UNIT_SOCKET ? SOCKET(u)->control_command :
+ ExecCommand *exec =
+ u->type == UNIT_SOCKET ? SOCKET(u)->control_command :
u->type == UNIT_MOUNT ? MOUNT(u)->control_command :
u->type == UNIT_SWAP ? SWAP(u)->control_command : NULL;
- k = verify_executable(u, exec, root);
- if (k < 0 && r == 0)
- r = k;
+ RET_GATHER(r, verify_executable(u, exec, root));
if (u->type == UNIT_SERVICE)
- for (i = 0; i < ELEMENTSOF(SERVICE(u)->exec_command); i++) {
- k = verify_executable(u, SERVICE(u)->exec_command[i], root);
- if (k < 0 && r == 0)
- r = k;
- }
+ for (unsigned i = 0; i < ELEMENTSOF(SERVICE(u)->exec_command); i++)
+ RET_GATHER(r, verify_executable(u, SERVICE(u)->exec_command[i], root));
if (u->type == UNIT_SOCKET)
- for (i = 0; i < ELEMENTSOF(SOCKET(u)->exec_command); i++) {
- k = verify_executable(u, SOCKET(u)->exec_command[i], root);
- if (k < 0 && r == 0)
- r = k;
- }
+ for (unsigned i = 0; i < ELEMENTSOF(SOCKET(u)->exec_command); i++)
+ RET_GATHER(r, verify_executable(u, SOCKET(u)->exec_command[i], root));
return r;
}
static int verify_unit(Unit *u, bool check_man, const char *root) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
- int r, k;
+ int r;
assert(u);
if (r < 0)
log_unit_error_errno(u, r, "Failed to create %s/start: %s", u->id, bus_error_message(&error, r));
- k = verify_socket(u);
- if (k < 0 && r == 0)
- r = k;
-
- k = verify_executables(u, root);
- if (k < 0 && r == 0)
- r = k;
-
- k = verify_documentation(u, check_man);
- if (k < 0 && r == 0)
- r = k;
+ RET_GATHER(r, verify_socket(u));
+ RET_GATHER(r, verify_executables(u, root));
+ RET_GATHER(r, verify_documentation(u, check_man));
return r;
}
_unused_ _cleanup_(clear_log_syntax_callback) dummy_t dummy;
Unit *units[strv_length(filenames)];
_cleanup_free_ char *var = NULL;
- int r, k, i, count = 0;
+ int r, k, count = 0;
if (strv_isempty(filenames))
return 0;
k = verify_prepare_filename(*filename, &prepared);
if (k < 0) {
log_error_errno(k, "Failed to prepare filename %s: %m", *filename);
- if (r == 0)
- r = k;
+ RET_GATHER(r, k);
continue;
}
k = manager_load_startable_unit_or_warn(m, NULL, prepared, &units[count]);
if (k < 0) {
- if (r == 0)
- r = k;
+ RET_GATHER(r, k);
continue;
}
count++;
}
- for (i = 0; i < count; i++) {
- k = verify_unit(units[i], check_man, root);
- if (k < 0 && r == 0)
- r = k;
- }
+ for (int i = 0; i < count; i++)
+ RET_GATHER(r, verify_unit(units[i], check_man, root));
if (s == POINTER_MAX)
return log_oom();
if (strchr(COMMENTS, p[0]))
continue;
- k = apply_rule(filename, line, p);
- if (k < 0 && r >= 0)
- r = k;
+ RET_GATHER(r, apply_rule(filename, line, p));
}
return r;
}
static int run(int argc, char *argv[]) {
- int r, k;
+ int r;
r = parse_argv(argc, argv);
if (r <= 0)
if (r <= 0)
return r;
- for (int i = optind; i < argc; i++) {
- k = apply_file(argv[i], false);
- if (k < 0 && r >= 0)
- r = k;
- }
+ for (int i = optind; i < argc; i++)
+ RET_GATHER(r, apply_file(argv[i], false));
+
} else {
_cleanup_strv_free_ char **files = NULL;
else
log_debug("Flushed all binfmt_misc rules.");
- STRV_FOREACH(f, files) {
- k = apply_file(*f, true);
- if (k < 0 && r >= 0)
- r = k;
- }
+ STRV_FOREACH(f, files)
+ RET_GATHER(r, apply_file(*f, true));
}
return r;
* newer version, or other boot loader in place. */
if (arg_graceful && IN_SET(k, -ESTALE, -ESRCH))
continue;
- if (k < 0 && r == 0)
- r = k;
+ RET_GATHER(r, k);
}
return r;
k = bus_call_method(bus, bus_systemd_mgr, "StartUnit", &error, NULL, "ss", unit, "replace");
if (k < 0) {
log_error_errno(k, "Failed to (re)start %s: %s", unit, bus_error_message(&error, r));
- if (r == 0)
- r = k;
+ RET_GATHER(r, k);
}
}
int sd_dhcp_server_forcerenew(sd_dhcp_server *server) {
DHCPLease *lease;
- int k, r = 0;
+ int r = 0;
assert_return(server, -EINVAL);
log_dhcp_server(server, "FORCERENEW");
- HASHMAP_FOREACH(lease, server->bound_leases_by_client_id) {
- k = server_send_forcerenew(server, lease->address, lease->gateway,
- lease->htype, lease->hlen, lease->chaddr);
- if (k < 0)
- r = k;
- }
-
+ HASHMAP_FOREACH(lease, server->bound_leases_by_client_id)
+ RET_GATHER(r,
+ server_send_forcerenew(server, lease->address, lease->gateway,
+ lease->htype, lease->hlen, lease->chaddr));
return r;
}
_cleanup_free_ sd_netlink_message **replies = NULL;
_cleanup_free_ uint32_t *serials = NULL;
- int k, r;
+ int r;
assert_return(nfnl, -EINVAL);
assert_return(!netlink_pid_changed(nfnl), -ECHILD);
if (r < 0)
return r;
- for (size_t i = 0; i < n_messages; i++) {
- k = sd_netlink_read(nfnl, serials[i], usec, ret_messages ? replies + i : NULL);
- if (k < 0 && r >= 0)
- r = k;
- }
+ for (size_t i = 0; i < n_messages; i++)
+ RET_GATHER(r,
+ sd_netlink_read(nfnl, serials[i], usec, ret_messages ? replies + i : NULL));
if (r < 0)
return r;
static int apply_glob_option_with_prefix(OrderedHashmap *sysctl_options, Option *option, const char *prefix) {
_cleanup_strv_free_ char **paths = NULL;
_cleanup_free_ char *pattern = NULL;
- int r, k;
+ int r;
assert(sysctl_options);
assert(option);
continue;
}
- k = sysctl_write_or_warn(key, option->value,
- /* ignore_failure = */ option->ignore_failure,
- /* ignore_enoent = */ !arg_strict);
- if (k < 0 && r >= 0)
- r = k;
+ RET_GATHER(r,
+ sysctl_write_or_warn(key, option->value,
+ /* ignore_failure = */ option->ignore_failure,
+ /* ignore_enoent = */ !arg_strict));
}
return r;
}
static int apply_glob_option(OrderedHashmap *sysctl_options, Option *option) {
- int r = 0, k;
+ int r = 0;
if (strv_isempty(arg_prefixes))
return apply_glob_option_with_prefix(sysctl_options, option, NULL);
- STRV_FOREACH(i, arg_prefixes) {
- k = apply_glob_option_with_prefix(sysctl_options, option, *i);
- if (k < 0 && r >= 0)
- r = k;
- }
-
+ STRV_FOREACH(i, arg_prefixes)
+ RET_GATHER(r, apply_glob_option_with_prefix(sysctl_options, option, *i));
return r;
}
k = sysctl_write_or_warn(option->key, option->value,
/* ignore_failure = */ option->ignore_failure,
/* ignore_enoent = */ !arg_strict);
- if (k < 0 && r >= 0)
- r = k;
+ RET_GATHER(r, k);
}
return r;
static int run(int argc, char *argv[]) {
_cleanup_ordered_hashmap_free_ OrderedHashmap *sysctl_options = NULL;
- int r, k;
+ int r;
r = parse_argv(argc, argv);
if (r <= 0)
umask(0022);
if (argc > optind) {
- int i;
-
r = 0;
- for (i = optind; i < argc; i++) {
- k = parse_file(&sysctl_options, argv[i], false);
- if (k < 0 && r == 0)
- r = k;
- }
+ for (int i = optind; i < argc; i++)
+ RET_GATHER(r, parse_file(&sysctl_options, argv[i], false));
+
} else {
_cleanup_strv_free_ char **files = NULL;
return cat_files(NULL, files, 0);
}
- STRV_FOREACH(f, files) {
- k = parse_file(&sysctl_options, *f, true);
- if (k < 0 && r == 0)
- r = k;
- }
+ STRV_FOREACH(f, files)
+ RET_GATHER(r, parse_file(&sysctl_options, *f, true));
- k = read_credential_lines(&sysctl_options);
- if (k < 0 && r == 0)
- r = k;
+ RET_GATHER(r, read_credential_lines(&sysctl_options));
}
- k = apply_all(sysctl_options);
- if (k < 0 && r == 0)
- r = k;
+ RET_GATHER(r, apply_all(sysctl_options));
return r;
}
int verb_set_property(int argc, char *argv[], void *userdata) {
sd_bus *bus;
_cleanup_strv_free_ char **names = NULL;
- int r, k;
+ int r;
r = acquire_bus(BUS_MANAGER, &bus);
if (r < 0)
return log_error_errno(r, "Failed to expand '%s' into names: %m", argv[1]);
r = 0;
- STRV_FOREACH(name, names) {
- k = set_property_one(bus, *name, strv_skip(argv, 2));
- if (k < 0 && r >= 0)
- r = k;
- }
+ STRV_FOREACH(name, names)
+ RET_GATHER(r, set_property_one(bus, *name, strv_skip(argv, 2)));
return r;
}
#include "device-util.h"
#include "devnode-acl.h"
+#include "errno-util.h"
#include "login-util.h"
#include "log.h"
#include "udev-builtin.h"
k = devnode_acl(path, true, false, 0, false, 0);
if (k < 0) {
log_device_full_errno(dev, k == -ENOENT ? LOG_DEBUG : LOG_ERR, k, "Failed to apply ACL: %m");
- if (r >= 0)
- r = k;
+ RET_GATHER(r, k);
}
}