aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-15 16:13:44 +0100
committerLennart Poettering <lennart@poettering.net>2017-12-15 20:52:28 +0100
commit4dc63c4bc7850bc570fcf33800a444e09dec81d5 (patch)
tree48852c9a8cf51155e3eeb7cabde00996884fccef /src
parentFix logical error in meson.build (#7658) (diff)
downloadsystemd-4dc63c4bc7850bc570fcf33800a444e09dec81d5.tar.gz
systemd-4dc63c4bc7850bc570fcf33800a444e09dec81d5.tar.bz2
systemd-4dc63c4bc7850bc570fcf33800a444e09dec81d5.zip
main: minor optimization
Let's remove one memory allocation in the common path.
Diffstat (limited to 'src')
-rw-r--r--src/core/main.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/core/main.c b/src/core/main.c
index 2ad507336..1be787442 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1413,6 +1413,7 @@ static int bump_unix_max_dgram_qlen(void) {
static int fixup_environment(void) {
_cleanup_free_ char *term = NULL;
+ const char *t;
int r;
/* We expect the environment to be set correctly
@@ -1432,13 +1433,10 @@ static int fixup_environment(void) {
r = proc_cmdline_get_key("TERM", 0, &term);
if (r < 0)
return r;
- if (r == 0) {
- term = strdup(default_term_for_tty("/dev/console"));
- if (!term)
- return -ENOMEM;
- }
- if (setenv("TERM", term, 1) < 0)
+ t = term ?: default_term_for_tty("/dev/console");
+
+ if (setenv("TERM", t, 1) < 0)
return -errno;
return 0;