On Wed, Aug 22, 2012 at 11:33 AM, Junio C Hamano <gitster@xxxxxxxxx> wrote: > Brandon Casey <drafnel@xxxxxxxxx> writes: > >> Perhaps something like: >> >> diff --git a/usage.c b/usage.c >> index a2a6678..2d0ff35 100644 >> --- a/usage.c >> +++ b/usage.c >> @@ -80,8 +80,15 @@ void NORETURN usage(const char *err) >> >> void NORETURN die(const char *err, ...) >> { >> + static int dying; >> va_list params; >> >> + if (dying) { >> + fputs("fatal: recursion detected in die handler\n", stderr); >> + exit(128); >> + } >> + dying = 1; >> + >> va_start(params, err); >> die_routine(err, params); >> va_end(params); >> @@ -89,11 +96,18 @@ void NORETURN die(const char *err, ...) >> >> void NORETURN die_errno(const char *fmt, ...) >> { >> + static int dying; >> va_list params; >> char fmt_with_err[1024]; >> char str_error[256], *err; >> int i, j; >> >> + if (dying) { >> + fputs("fatal: recursion detected in die handler\n", stderr); >> + exit(128); >> + } >> + dying = 1; >> + >> err = strerror(errno); >> for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) { >> if ((str_error[j++] = err[i++]) != '%') > > With two function-scope static, you can go like this: > > die() > -> die_routine() > -> xsomething() > -> die_errno() > -> die_routine() > -> xsomethingelse() > -> die() or die_errno() > > Not that we probably care too deeply about, as at least we won't > infinitely recurse and die out of stack space. Yeah, I noticed that, but didn't think it was important or likely. But there's no reason not to make "dying" a global. -Brandon -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html