summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2024-10-16 09:50:02 +0200
committerGitHub <noreply@github.com>2024-10-16 09:50:02 +0200
commit40dce0be6a8f1cad15fce434177b48f9e69b96dd (patch)
tree4357df40613c26f8239060c323e03c87187ee0c7
parentMerge pull request #17116 from enkechen-panw/zfix-2 (diff)
parentvtysh: fix SA warning, no need to call getenv() twice (diff)
downloadfrr-40dce0be6a8f1cad15fce434177b48f9e69b96dd.tar.xz
frr-40dce0be6a8f1cad15fce434177b48f9e69b96dd.zip
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 64198132c..297d87ec4 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",