Skip to content

Commit e4ca819

Browse files
johnkeepinggitster
authored andcommitted
refs.c: fix fread error handling
fread returns the number of items read, with no special error return. Commit 98f85ff (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: John Keeping <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 98f85ff commit e4ca819

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,7 @@ int for_each_reflog_ent_reverse(const char *refname, each_reflog_ent_fn fn, void
23572357
return error("cannot seek back reflog for %s: %s",
23582358
refname, strerror(errno));
23592359
nread = fread(buf, cnt, 1, logfp);
2360-
if (nread < 0)
2360+
if (nread != 1)
23612361
return error("cannot read %d bytes from reflog for %s: %s",
23622362
cnt, refname, strerror(errno));
23632363
pos -= cnt;

0 commit comments

Comments
 (0)