Thread (1 message) 1 message, 1 author, 2017-09-27

Re: [PATCH 3/7] read_in_full: reset errno before reading

From: Junio C Hamano <hidden>
Date: 2017-09-27 04:27:54

Jeff King [off-list ref] writes:
You actually don't need errno for that. You can write:

  ret = read_in_full(..., size);
  if (ret < 0)
	die_errno("oops");
  else if (ret != size)
	die("short read");

So I think using errno as a sentinel value to tell between the two cases
doesn't have much value.
...
One of the reasons I dislike the helper I showed earlier is that it
involves assembling a lego sentence. But the alternative is requiring
the caller to write both sentences from scratch (and writing a good
sentence for the short read really is long: you expected X bytes but got
Y).
All sensible considerations.  I probably should have read the entire
discussion twice before starting to type X-<.  Sorry about the
noise.
Sometimes a custom "short read" message can be better, if it's "could
not read enough bytes for packfile header" or similar. You don't need to
know the exact number then.
That's true, too.  I dunno, either.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help