[igt-dev] [PATCH i-g-t 18/21] lib/igt_core: Initialize fds in igt_system_quiet

Petri Latvala petri.latvala at intel.com
Wed Jan 16 11:20:47 UTC 2019


This avoids calling close() with uninitialized ints if some dup()
calls succeed and others don't.

Signed-off-by: Petri Latvala <petri.latvala at intel.com>
Cc: Abdiel Janulgue <abdiel.janulgue at linux.intel.com>
---
 lib/igt_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 0cae9b6a..49fbf70d 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -2391,7 +2391,7 @@ err:
  */
 int igt_system_quiet(const char *command)
 {
-	int stderr_fd_copy, stdout_fd_copy, status, nullfd;
+	int stderr_fd_copy = -1, stdout_fd_copy = -1, status, nullfd = -1;
 
 	/* redirect */
 	if ((nullfd = open("/dev/null", O_WRONLY)) == -1)
-- 
2.19.1



More information about the igt-dev mailing list