All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v8 1/4] usage: make error functions a stack
Date: Tue, 15 Jul 2014 15:47:47 -0700	[thread overview]
Message-ID: <xmqq7g3etf1o.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1405459754-4220-2-git-send-email-jacob.e.keller@intel.com> (Jacob Keller's message of "Tue, 15 Jul 2014 14:29:11 -0700")

Jacob Keller <jacob.e.keller@intel.com> writes:

>  extern void set_error_routine(void (*routine)(const char *err, va_list params));
> +extern void pop_error_routine(void);

pop that undoes set smells somewhat weird.  Perhaps we should rename
set to push?  That would allow us catch possible topics that add new
calls to set_error_routine() as well by forcing the system not to
link when they are merged without necessary fixes.

> +/* push error routine onto the error function stack */
>  void set_error_routine(void (*routine)(const char *err, va_list params))
>  {
> -	error_routine = routine;
> +	struct error_func_list *efl = xmalloc(sizeof(*efl));
> +	efl->func = routine;
> +	efl->next = error_funcs;
> +	error_funcs = efl;
> +}
> +
> +/* pop a single error routine off of the error function stack, thus reverting
> + * to previous error. Should always be paired with a set_error_routine */
> +void pop_error_routine(void)
> +{
> +	assert(error_funcs != &default_error_func);
> +
> +	struct error_func_list *efl = error_funcs;

decl-after-stmt.  Can be fixed easily by flipping the above two
lines.

> +	if (efl->next) {
> +		error_funcs = efl->next;
> +		free(efl);
> +	}
>  }
>  
>  void set_die_is_recursing_routine(int (*routine)(void))
> @@ -144,7 +167,7 @@ int error(const char *err, ...)
>  	va_list params;
>  
>  	va_start(params, err);
> -	error_routine(err, params);
> +	error_funcs->func(err, params);
>  	va_end(params);
>  	return -1;
>  }

  reply	other threads:[~2014-07-15 22:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15 21:29 [PATCH v8 0/4] tag: configure default tag sort via .gitconfig Jacob Keller
2014-07-15 21:29 ` [PATCH v8 1/4] usage: make error functions a stack Jacob Keller
2014-07-15 22:47   ` Junio C Hamano [this message]
2014-07-15 23:24     ` Keller, Jacob E
2014-07-15 23:26     ` Keller, Jacob E
2014-07-16  0:49       ` Junio C Hamano
2014-07-16 19:50         ` Keller, Jacob E
2014-07-15 21:29 ` [PATCH v8 2/4] tag: fix --sort tests to use cat<<-\EOF format Jacob Keller
2014-07-15 21:29 ` [PATCH v8 3/4] tag: update parsing to be more precise regarding errors Jacob Keller
2014-07-15 21:29 ` [PATCH v8 4/4] tag: support configuring --sort via .gitconfig Jacob Keller
2014-07-15 22:40 ` [PATCH v8 0/4] tag: configure default tag sort " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq7g3etf1o.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.e.keller@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.