e2fsprogs: Don't try to close an fd which is negative
These reflect either file descriptors which aren't tested
for failure, or closures of fd's which may have failed.
In setup_tdb(), test for failure of mkstemp and return
without trying to open the file (again).
In reserve_stdio_fds, rather than closing the "extra"
fd == 3 due to the way the loop is written, just
don't go that far by using while (fd <= 2).
In logsave, it forks and retries forever if open fails,
but at least make coverity happy by explicitly not
trying to close a negative file descriptor.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/misc/logsave.c b/misc/logsave.c
index 74e09f7..17457a5 100644
--- a/misc/logsave.c
+++ b/misc/logsave.c
@@ -325,7 +325,8 @@
write_all(outfd, outbuf, outbufsize);
free(outbuf);
}
- close(outfd);
+ if (outfd >= 0)
+ close(outfd);
exit(rc);
}