git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dir: do all size checks before seeking back and fix file closing
@ 2006-08-26 14:17 Jonas Fonseca
  2006-08-26 18:43 ` Mitchell Blank Jr
  2006-08-26 22:13 ` Linus Torvalds
  0 siblings, 2 replies; 10+ messages in thread
From: Jonas Fonseca @ 2006-08-26 14:17 UTC (permalink / raw)
  To: git

Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
 dir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dir.c b/dir.c
index d53d48f..ff8a2fb 100644
--- a/dir.c
+++ b/dir.c
@@ -122,11 +122,11 @@ static int add_excludes_from_file_1(cons
 	size = lseek(fd, 0, SEEK_END);
 	if (size < 0)
 		goto err;
-	lseek(fd, 0, SEEK_SET);
 	if (size == 0) {
 		close(fd);
 		return 0;
 	}
+	lseek(fd, 0, SEEK_SET);
 	buf = xmalloc(size+1);
 	if (read(fd, buf, size) != size)
 		goto err;
@@ -146,7 +146,7 @@ static int add_excludes_from_file_1(cons
 	return 0;
 
  err:
-	if (0 <= fd)
+	if (0 >= fd)
 		close(fd);
 	return -1;
 }
-- 
1.4.2.GIT

-- 
Jonas Fonseca

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-08-27 23:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-26 14:17 [PATCH] dir: do all size checks before seeking back and fix file closing Jonas Fonseca
2006-08-26 18:43 ` Mitchell Blank Jr
2006-08-26 20:44   ` Jonas Fonseca
2006-08-26 22:13 ` Linus Torvalds
2006-08-26 22:35   ` Jakub Narebski
2006-08-27  0:07   ` Junio C Hamano
2006-08-27  2:15     ` Junio C Hamano
2006-08-27  2:37     ` Linus Torvalds
2006-08-27  3:04       ` Junio C Hamano
2006-08-27 23:55     ` [PATCH] Use fstat instead of fseek Jonas Fonseca

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).