提交 e4ca819a 编写于 作者: J John Keeping 提交者: Junio C Hamano

refs.c: fix fread error handling

fread returns the number of items read, with no special error return.

Commit 98f85ff4 (reflog: add for_each_reflog_ent_reverse() API -
2013-03-08) introduced a call to fread which checks for an error with
"nread < 0" which is tautological since nread is unsigned.  The correct
check in this case (which tries to read a single item) is "nread != 1".
Signed-off-by: NJohn Keeping <john@keeping.me.uk>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 98f85ff4
......@@ -2357,7 +2357,7 @@ int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void
return error("cannot seek back reflog for %s: %s",
refname, strerror(errno));
nread = fread(buf, cnt, 1, logfp);
if (nread < 0)
if (nread != 1)
return error("cannot read %d bytes from reflog for %s: %s",
cnt, refname, strerror(errno));
pos -= cnt;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册