git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] diff.c: guard config parser from value=NULL

From
MKMartin Koegler <mkoegler@auto.tuwien.ac.at>
Date
Feb 10, 2008, 21:13 UTC
Message-ID
<20080210211341.GA24976@auto.tuwien.ac.at>
In-Reply-To
<20080210193534.d11d8b15.chriscool@tuxfamily.org>
On Sun, Feb 10, 2008 at 07:35:34PM +0100, Christian Couder wrote:
Show 32 quoted lines
> 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
Previous: Christian Couder
Message 4 of 4 in “diff.c: guard config parser from value=NULL”
  1. diff.c: guard config parser from value=NULLChristian Couder, Feb 10, 2008
  2. Pierre HabouzitFeb 10, 2008
  3. Christian CouderFeb 11, 2008
  4. Martin KoeglerFeb 10, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.