From: René Scharfe Date: Mon, 22 Jun 2009 16:42:33 GMT Subject: [PATCH] fread does not return negative on error Message-ID: <4A3FB479.2090902@lsrfire.ath.cx> In-Reply-To: <25e057c00906220847t15425f38maf486c291d1d2468@mail.gmail.com> Hi, the following patch is for git. I just removed the unneeded check for res == 0 from your version. Does it look OK? Thanks, René --- snip! --- From: Roel Kluin size_t res cannot be less than 0. fread returns 0 on error. Reported-by: Ingo Molnar Signed-off-by: Roel Kluin --- strbuf.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/strbuf.c b/strbuf.c index a884960..f03d117 100644 --- a/strbuf.c +++ b/strbuf.c @@ -260,7 +260,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 (oldalloc == 0) strbuf_release(sb); return res; }