Re: [PATCH 1/2] inline constant return from error() function

2014-05-12 Thread Jeff King
On Sun, May 11, 2014 at 10:22:03AM -0700, Junio C Hamano wrote: The alternative you mentioned up-thread ... to write out return error(...) as error(...); return -1. In some ways that is more readable, though it is more verbose... has one more downside you did not mention, and the approach to

Re: [PATCH 1/2] inline constant return from error() function

2014-05-12 Thread Jonathan Nieder
Hi, Jeff King wrote: On Mon, May 05, 2014 at 05:29:38PM -0400, Jeff King wrote: I cannot think of any other way to make the compiler aware of the constant value, but perhaps somebody else is more clever than I am. This came to me in a dream, and seems to work. Clever. :) Thanks for

Re: [PATCH 1/2] inline constant return from error() function

2014-05-12 Thread Jeff King
On Mon, May 12, 2014 at 11:44:26AM -0700, Jonathan Nieder wrote: --- a/git-compat-util.h +++ b/git-compat-util.h @@ -331,7 +331,11 @@ extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2))) * using the function as usual. */ #if defined(__GNUC__) !

Re: [PATCH 1/2] inline constant return from error() function

2014-05-11 Thread Felipe Contreras
Junio C Hamano wrote: That's kind of W*A*T magic, and I generally try to avoid magic, as long as it solves your can we make both -O2 with new compilers and -O3 happy? I wouldn't complain ;-) In case anybody is looking for a non-hacky way of doing this that doesn't depend on the gcc version of

Re: [PATCH 1/2] inline constant return from error() function

2014-05-11 Thread Junio C Hamano
Jeff King p...@peff.net writes: On Tue, May 06, 2014 at 03:29:37PM -0700, Junio C Hamano wrote: That's kind of W*A*T magic, and I generally try to avoid magic, as long as it solves your can we make both -O2 with new compilers and -O3 happy? I wouldn't complain ;-) I agree it's rather

[PATCH 1/2] inline constant return from error() function

2014-05-06 Thread Jeff King
Commit e208f9c introduced a macro to turn error() calls into: (error(), -1) to make the constant return value more visible to the calling code (and thus let the compiler make better decisions about the code). This works well for code like: return error(...); but the -1 is superfluous in

Re: [PATCH 1/2] inline constant return from error() function

2014-05-06 Thread Junio C Hamano
Jeff King p...@peff.net writes: Commit e208f9c introduced a macro to turn error() calls into: (error(), -1) to make the constant return value more visible to the calling code (and thus let the compiler make better decisions about the code). This works well for code like: return

Re: [PATCH 1/2] inline constant return from error() function

2014-05-06 Thread Jeff King
On Tue, May 06, 2014 at 03:29:37PM -0700, Junio C Hamano wrote: We can work around this by encapsulating the constant return value in a static inline function, as gcc specifically avoids complaining about unused function returns unless the function has been specifically marked with the