summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-10-16 10:50:02 +0300
committerGitHub <noreply@github.com>2024-10-16 10:50:02 +0300
commit40dce0be6a8f1cad15fce434177b48f9e69b96dd (patch)
tree4357df40613c26f8239060c323e03c87187ee0c7
parentc32bdc24697aa0a988fa739228022083b96acecc (diff)
parent38661a6aa50204e7204182bf7eeec45e2a87f14b (diff)
Merge pull request #17114 from Jafaral/getenv
vtysh: fix SA warning, no need to call getenv() twice
-rw-r--r--vtysh/vtysh_main.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 64198132cc..297d87ec41 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -350,6 +350,7 @@ int main(int argc, char **argv, char **env)
char pathspace[MAXPATHLEN] = "";
const char *histfile = NULL;
const char *histfile_env = getenv("VTYSH_HISTFILE");
+ const char *logpath = getenv("VTYSH_LOG");
/* SUID: drop down to calling user & go back up when needed */
elevuid = geteuid();
@@ -643,9 +644,7 @@ int main(int argc, char **argv, char **env)
}
}
- if (getenv("VTYSH_LOG")) {
- const char *logpath = getenv("VTYSH_LOG");
-
+ if (logpath != NULL) {
logfile = fopen(logpath, "a");
if (!logfile) {
fprintf(stderr, "Failed to open logfile (%s): %s\n",