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

Re: [PATCH] parse_dirstat_params(): use string_list to split comma-separated string

From
MKMatt Kraai <kraai@ftbfs.org>
Date
Oct 30, 2012, 18:43 UTC
Message-ID
<loom.20121030T193428-242@post.gmane.org>
In-Reply-To
<1351443054-10472-1-git-send-email-mhagger@alum.mit.edu>

Michael Haggerty <mhagger <at> alum.mit.edu> writes: ...

Show 15 quoted lines
> -static int parse_dirstat_params(struct diff_options *options, const char ...
> +static int parse_dirstat_params(struct diff_options *options, const char ...
>  				struct strbuf *errmsg)
>  {
> -	const char *p = params;
> -	int p_len, ret = 0;
> +	char *params_copy = xstrdup(params_string);
> +	struct string_list params = STRING_LIST_INIT_NODUP;
> +	int ret = 0;
> +	int i;
> 
> -	while (*p) {
> -		p_len = strchrnul(p, ',') - p;
> -		if (!memcmp(p, "changes", p_len)) {
> +	if (*params_copy)

params_copy is set to the value returned by xstrdup, which cannot be NULL. This check can be removed and if params_string can be NULL, it should be checked before being passed to xstrdup.

Previous: Michael HaggertyNext: Jeff King
Message 2 of 4 in “parse_dirstat_params(): use string_list to split comma-separated string”
  1. parse_dirstat_params(): use string_list to split comma-separated stringMichael Haggerty, Oct 28, 2012
  2. Matt KraaiOct 30, 2012
  3. Jeff KingOct 31, 2012
  4. Matt KraaiOct 31, 2012

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.