summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSimon Peeters <peeters.simon@gmail.com>2014-01-04 02:35:27 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-01-05 09:16:15 -0500
commite3e45d4f82daa5cd85ba40dde9127df900096c0c (patch)
tree307e427adfd64298ff3f21f6c6fd97aca1e17d42 /src/core
parentbf85c24daaf63f72562bbe4c627ca8b963dfb964 (diff)
strv: multiple cleanups
- turn strv_merge into strv_extend_strv. appending strv b to the end of strv a instead of creating a new strv - strv_append: remove in favor of strv_extend and strv_push. - strv_remove: write slightly more elegant - strv_remove_prefix: remove unused function - strv_overlap: use strv_contains - strv_printf: STRV_FOREACH handles NULL correctly
Diffstat (limited to 'src/core')
-rw-r--r--src/core/main.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/core/main.c b/src/core/main.c
index d052c8debc..6db42991e8 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -601,15 +601,12 @@ static int config_parse_join_controllers(const char *unit,
if (strv_overlap(*a, l)) {
char **c;
- c = strv_merge(*a, l);
- if (!c) {
+ if (strv_extend_strv(&l, *a) < 0) {
strv_free(l);
strv_free_free(t);
return log_oom();
}
- strv_free(l);
- l = c;
} else {
char **c;
@@ -1853,10 +1850,11 @@ finish:
shutdown_verb,
NULL
};
- char **env_block;
+ _cleanup_strv_free_ char **env_block = NULL;
+ env_block = strv_copy(environ);
if (arm_reboot_watchdog && arg_shutdown_watchdog > 0) {
- char e[32];
+ char *e;
/* If we reboot let's set the shutdown
* watchdog and tell the shutdown binary to
@@ -1864,15 +1862,11 @@ finish:
watchdog_set_timeout(&arg_shutdown_watchdog);
watchdog_close(false);
- /* Tell the binary how often to ping */
- snprintf(e, sizeof(e), "WATCHDOG_USEC="USEC_FMT, arg_shutdown_watchdog);
- char_array_0(e);
-
- env_block = strv_append(environ, e);
- } else {
- env_block = strv_copy(environ);
+ /* Tell the binary how often to ping, ignore failure */
+ if (asprintf(&e, "WATCHDOG_USEC="USEC_FMT, arg_shutdown_watchdog) > 0)
+ strv_push(&env_block, e);
+ } else
watchdog_close(true);
- }
/* Avoid the creation of new processes forked by the
* kernel; at this point, we will not listen to the
@@ -1881,7 +1875,6 @@ finish:
cg_uninstall_release_agent(SYSTEMD_CGROUP_CONTROLLER);
execve(SYSTEMD_SHUTDOWN_BINARY_PATH, (char **) command_line, env_block);
- free(env_block);
log_error("Failed to execute shutdown binary, freezing: %m");
}