]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
vconsole-setup: don't concat strv if we don't need to (i.e. not in debug log mode)
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Mar 2018 16:07:18 +0000 (17:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 22 Mar 2018 19:30:40 +0000 (20:30 +0100)
src/vconsole/vconsole-setup.c

index 92656c63833b7496057268ebb14e7d57c79ce5a2..b91968e81fdf1c5e254264b57f69eed987ee4c09 100644 (file)
@@ -129,7 +129,6 @@ static int toggle_utf8_sysfs(bool utf8) {
 }
 
 static int keyboard_load_and_wait(const char *vc, const char *map, const char *map_toggle, bool utf8) {
-        _cleanup_free_ char *cmd = NULL;
         const char *args[8];
         unsigned i = 0;
         pid_t pid;
@@ -150,8 +149,12 @@ static int keyboard_load_and_wait(const char *vc, const char *map, const char *m
                 args[i++] = map_toggle;
         args[i++] = NULL;
 
-        log_debug("Executing \"%s\"...",
-                  strnull((cmd = strv_join((char**) args, " "))));
+        if (DEBUG_LOGGING) {
+                _cleanup_free_ char *cmd;
+
+                cmd = strv_join((char**) args, " ");
+                log_debug("Executing \"%s\"...", strnull(cmd));
+        }
 
         r = safe_fork("(loadkeys)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid);
         if (r < 0)
@@ -165,7 +168,6 @@ static int keyboard_load_and_wait(const char *vc, const char *map, const char *m
 }
 
 static int font_load_and_wait(const char *vc, const char *font, const char *map, const char *unimap) {
-        _cleanup_free_ char *cmd = NULL;
         const char *args[9];
         unsigned i = 0;
         pid_t pid;
@@ -190,8 +192,12 @@ static int font_load_and_wait(const char *vc, const char *font, const char *map,
                 args[i++] = font;
         args[i++] = NULL;
 
-        log_debug("Executing \"%s\"...",
-                  strnull((cmd = strv_join((char**) args, " "))));
+        if (DEBUG_LOGGING) {
+                _cleanup_free_ char *cmd;
+
+                cmd = strv_join((char**) args, " ");
+                log_debug("Executing \"%s\"...", strnull(cmd));
+        }
 
         r = safe_fork("(setfont)", FORK_RESET_SIGNALS|FORK_CLOSE_ALL_FDS|FORK_LOG, &pid);
         if (r < 0)