git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: mkoegler@auto.tuwien.ac.at (Martin Koegler)
To: Christian Couder <chriscool@tuxfamily.org>
Cc: Junio Hamano <junkio@cox.net>,
	Johannes Sixt <j.sixt@viscovery.net>,
	Pierre Habouzit <madcoder@debian.org>,
	Govind Salinas <blix@sophiasuchtig.com>,
	git@vger.kernel.org
Subject: Re: [PATCH] diff.c: guard config parser from value=NULL
Date: Sun, 10 Feb 2008 22:13:41 +0100	[thread overview]
Message-ID: <20080210211341.GA24976@auto.tuwien.ac.at> (raw)
In-Reply-To: <20080210193534.d11d8b15.chriscool@tuxfamily.org>

On Sun, Feb 10, 2008 at 07:35:34PM +0100, Christian Couder wrote:
> In fact we also guard for value="" as it doesn't make more sense
> for the variables here.
> 
> We do that by using a new function 'xstrdup_confval' to avoid code
> duplication.
> 
> By the way this changes a 'strdup' into 'xstrdup'.
> 
> Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
> ---
>  diff.c |   23 +++++++++++++----------
>  1 files changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/diff.c b/diff.c
> index 5b8afdc..d51aecb 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -60,6 +60,14 @@ static struct ll_diff_driver {
>  	char *cmd;
>  } *user_diff, **user_diff_tail;
>  
> +static int xstrdup_confval(const char *dest, const char *var, const char *value)
> +{
> +	if (!value || !*value)
> +		return error("%s: lacks value", var);
> +	dest = xstrdup(value);
> +	return 0;
> +}
> +
>  /*
>   * Currently there is only "diff.<drivername>.command" variable;
>   * because there are "diff.color.<slot>" variables, we are parsing

This function could be used in config.c too. So move it to a common file.

mfg Martin Kögler

      parent reply	other threads:[~2008-02-10 21:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-10 18:35 [PATCH] diff.c: guard config parser from value=NULL Christian Couder
2008-02-10 19:01 ` Pierre Habouzit
2008-02-11  4:55   ` Christian Couder
2008-02-10 21:13 ` Martin Koegler [this message]

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=20080210211341.GA24976@auto.tuwien.ac.at \
    --to=mkoegler@auto.tuwien.ac.at \
    --cc=blix@sophiasuchtig.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=j.sixt@viscovery.net \
    --cc=junkio@cox.net \
    --cc=madcoder@debian.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).