From 174da8f922dbf9de116c1aae04a07877ba5cf5e7 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Fri, 24 Nov 2017 22:16:43 +0100 Subject: [PATCH] ifcfg-rh: close file descriptor only when necessary If the file was read-only, we already closed it. This fixes the following valgrind warnings: Warning: invalid file descriptor -1 in syscall close() --- src/settings/plugins/ifcfg-rh/shvar.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/settings/plugins/ifcfg-rh/shvar.c b/src/settings/plugins/ifcfg-rh/shvar.c index df03bf654c..1b4529c4e1 100644 --- a/src/settings/plugins/ifcfg-rh/shvar.c +++ b/src/settings/plugins/ifcfg-rh/shvar.c @@ -1373,7 +1373,8 @@ svCloseFile (shvarFile *s) g_return_if_fail (s != NULL); - nm_close (s->fd); + if (s->fd >= 0) + nm_close (s->fd); g_free (s->fileName); c_list_for_each_safe (current, safe, &s->lst_head) line_free (c_list_entry (current, shvarLine, lst));