summaryrefslogtreecommitdiff
path: root/vtysh
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2024-10-16 12:50:50 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2024-10-16 13:30:25 +0200
commite8006bc2cbfca63eb3d73fe1006413563505ade3 (patch)
treee0b9d83afac5083432cc040b79c339dc2eb6338e /vtysh
parent42d468800d3024fe784e3b03abaa316f9f982c70 (diff)
vtysh: make clang-SA happy about reusing stdin
While the logic here is perfectly fine, clang-SA doesn't understand that the fopen() and fclose() match up with each other. Just use a separate variable to make clang-SA happy. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index b452618ce0..5a54c60c6b 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -695,7 +695,7 @@ static char *trim(char *s)
int vtysh_mark_file(const char *filename)
{
struct vty *vty;
- FILE *confp = NULL;
+ FILE *confp = NULL, *closefp = NULL;
int ret;
vector vline;
int tried = 0;
@@ -708,7 +708,7 @@ int vtysh_mark_file(const char *filename)
if (strncmp("-", filename, 1) == 0)
confp = stdin;
else
- confp = fopen(filename, "r");
+ confp = closefp = fopen(filename, "r");
if (confp == NULL) {
fprintf(stderr, "%% Can't open config file %s due to '%s'.\n",
@@ -848,9 +848,8 @@ int vtysh_mark_file(const char *filename)
vty_close(vty);
XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
- if (confp != stdin)
- fclose(confp);
-
+ if (closefp)
+ fclose(closefp);
return 0;
}