]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: use saved_argv where we can
authorLennart Poettering <lennart@poettering.net>
Fri, 15 Mar 2019 09:47:19 +0000 (10:47 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 21 Mar 2019 17:10:06 +0000 (18:10 +0100)
No need to have another variable where we keep the original argv[].
Let's juse reuse the one DEFINE_MAIN_FUNCTION() stores for us anyway.

src/systemctl/systemctl.c

index afe6f84f774a82704c19071b12162d3c216a6870..c411873c8bdb225c8921efd96d91b8bef77a1d0a 100644 (file)
@@ -141,7 +141,6 @@ static const char *arg_kill_who = NULL;
 static int arg_signal = SIGTERM;
 static char *arg_root = NULL;
 static usec_t arg_when = 0;
-static char *argv_cmdline = NULL;
 static enum action {
         ACTION_SYSTEMCTL,
         ACTION_HALT,
@@ -6177,10 +6176,11 @@ static int switch_root(int argc, char *argv[], void *userdata) {
                         init = NULL;
         }
 
-        /* Instruct PID1 to exclude us from its killing spree applied during
-         * the transition. Otherwise we would exit with a failure status even
-         * though the switch to the new root has succeed. */
-        argv_cmdline[0] = '@';
+        /* Instruct PID1 to exclude us from its killing spree applied during the transition. Otherwise we
+         * would exit with a failure status even though the switch to the new root has succeed. */
+        assert(saved_argv);
+        assert(saved_argv[0]);
+        saved_argv[0][0] = '@';
 
         r = acquire_bus(BUS_MANAGER, &bus);
         if (r < 0)
@@ -9161,8 +9161,6 @@ static int logind_cancel_shutdown(void) {
 static int run(int argc, char *argv[]) {
         int r;
 
-        argv_cmdline = argv[0];
-
         setlocale(LC_ALL, "");
         log_parse_environment();
         log_open();