From: Roel Kluin <roel.kluin@gmail.com>
To: ingo <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] tools: fread does not return negative on error
Date: Mon, 22 Jun 2009 18:26:05 +0200 [thread overview]
Message-ID: <4A3FB09D.9050903@gmail.com> (raw)
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;
}
next reply other threads:[~2009-06-22 14:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-22 16:26 Roel Kluin [this message]
2009-06-22 15:34 ` [PATCH] tools: fread does not return negative on error 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A3FB09D.9050903@gmail.com \
--to=roel.kluin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox