Re: Porting git to HP NonStop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



--
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]