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>
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;
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",
vty_close(vty);
XFREE(MTYPE_VTYSH_CMD, vty_buf_copy);
- if (confp != stdin)
- fclose(confp);
-
+ if (closefp)
+ fclose(closefp);
return 0;
}