public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: fread does not return negative on error
@ 2009-06-22 16:26 Roel Kluin
  2009-06-22 15:34 ` Ingo Molnar
  0 siblings, 1 reply; 15+ messages in thread
From: Roel Kluin @ 2009-06-22 16:26 UTC (permalink / raw)
  To: ingo; +Cc: LKML, Andrew Morton

size_t res cannot be less than 0. fread returns 0 on error.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Is this correct? please review.

diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c
index eaba093..376a337 100644
--- a/tools/perf/util/strbuf.c
+++ b/tools/perf/util/strbuf.c
@@ -259,7 +259,7 @@ size_t strbuf_fread(struct strbuf *sb, size_t size, FILE *f)
 	res = fread(sb->buf + sb->len, 1, size, f);
 	if (res > 0)
 		strbuf_setlen(sb, sb->len + res);
-	else if (res < 0 && oldalloc == 0)
+	else if (res == 0 && oldalloc == 0)
 		strbuf_release(sb);
 	return res;
 }

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

end of thread, other threads:[~2009-06-25 18:31 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-22 16:26 [PATCH] tools: fread does not return negative on error Roel Kluin
2009-06-22 15:34 ` Ingo Molnar
2009-06-22 15:47   ` roel kluin
2009-06-22 16:42     ` [PATCH] " René Scharfe
2009-06-23 23:56       ` Junio C Hamano
2009-06-24  8:18         ` Ingo Molnar
2009-06-24 10:03           ` Johannes Schindelin
2009-06-24 16:15             ` Junio C Hamano
2009-06-24 16:40               ` Johannes Schindelin
2009-06-24 17:59                 ` Ingo Molnar
2009-06-24 21:19                   ` Alex Riesen
2009-06-24 21:55                     ` Junio C Hamano
2009-06-24 10:53           ` Christian Couder
2009-06-24 12:12             ` Ingo Molnar
2009-06-25 18:31           ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox