]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
main: use strv_extendf() where appropriate
authorLennart Poettering <lennart@poettering.net>
Fri, 24 Sep 2021 09:05:00 +0000 (11:05 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 24 Sep 2021 11:42:54 +0000 (20:42 +0900)
src/core/main.c

index 58c7b96881da7e7593ca8bbf42cd4ede4cb0c50d..ff7f189370ded18470c67adce52db1d409f3fcc7 100644 (file)
@@ -1535,20 +1535,16 @@ static int become_shutdown(
                 watchdog_timer = arg_kexec_watchdog;
 
         if (timestamp_is_set(watchdog_timer)) {
-                char *e;
-
-                /* If we reboot or kexec let's set the shutdown watchdog and
-                 * tell the shutdown binary to repeatedly ping it */
+                /* If we reboot or kexec let's set the shutdown watchdog and tell the shutdown binary to
+                 * repeatedly ping it */
                 r = watchdog_setup(watchdog_timer);
                 watchdog_close(r < 0);
 
                 /* Tell the binary how often to ping, ignore failure */
-                if (asprintf(&e, "WATCHDOG_USEC="USEC_FMT, watchdog_timer) > 0)
-                        (void) strv_consume(&env_block, e);
+                (void) strv_extendf(&env_block, "WATCHDOG_USEC="USEC_FMT, watchdog_timer);
 
-                if (arg_watchdog_device &&
-                    asprintf(&e, "WATCHDOG_DEVICE=%s", arg_watchdog_device) > 0)
-                        (void) strv_consume(&env_block, e);
+                if (arg_watchdog_device)
+                        (void) strv_extendf(&env_block, "WATCHDOG_DEVICE=%s", arg_watchdog_device);
         } else
                 watchdog_close(true);