Re: [PATCH 1/4] error: save and restore errno

2014-11-19 Thread Jeff King
On Wed, Nov 19, 2014 at 10:14:17AM -0800, Junio C Hamano wrote: > >> What the above doesn't explain is why the caller cares about errno. > >> Are they going to print another message with strerror(errno)? Or are > >> they going to consider some errors non-errors (like ENOENT when trying > >> to un

Re: [PATCH 1/4] error: save and restore errno

2014-11-19 Thread Junio C Hamano
Jeff King writes: > On Tue, Nov 18, 2014 at 05:43:44PM -0800, Jonathan Nieder wrote: > >> Jeff King wrote: >> >> > It's common to use error() to return from a function, like: >> > >> >if (open(...) < 0) >> >return error("open failed"); >> > >> > Unfortunately this may clobber the

Re: [PATCH 1/4] error: save and restore errno

2014-11-18 Thread Jeff King
On Tue, Nov 18, 2014 at 05:43:44PM -0800, Jonathan Nieder wrote: > Jeff King wrote: > > > It's common to use error() to return from a function, like: > > > > if (open(...) < 0) > > return error("open failed"); > > > > Unfortunately this may clobber the errno from the open() > > ca

Re: [PATCH 1/4] error: save and restore errno

2014-11-18 Thread Jonathan Nieder
Jeff King wrote: > It's common to use error() to return from a function, like: > > if (open(...) < 0) > return error("open failed"); > > Unfortunately this may clobber the errno from the open() > call. So we often end up with code like this: > > if (open(...) < 0) { >

Re: [PATCH 1/4] error: save and restore errno

2014-11-18 Thread Stefan Beller
This one makes my day. A really good fix as it minimizes maintenance burden for checking incoming patches for that pattern. Reviewed-by: Stefan Beller On Tue, Nov 18, 2014 at 5:37 PM, Jeff King wrote: > It's common to use error() to return from a function, like: > > if (open(...) < 0)