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

2012-10-31 Thread Jeff King
On Tue, Oct 30, 2012 at 06:43:51PM +, Matt Kraai wrote:

 Michael Haggerty mhagger at alum.mit.edu writes:
 ...
  -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.

If you are referring to the last line, isn't it checking whether the
string is empty, not NULL?

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2012-10-31 Thread Matt Kraai
On Wed, Oct 31, 2012 at 10:06:36AM -0400, Jeff King wrote:
 On Tue, Oct 30, 2012 at 06:43:51PM +, Matt Kraai wrote:
 
  Michael Haggerty mhagger at alum.mit.edu writes:
   + 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.
 
 If you are referring to the last line, isn't it checking whether the
 string is empty, not NULL?

Oops, you're right.  Sorry for misreading that.

-- 
Matt Kraai
https://ftbfs.org/kraai
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2012-10-30 Thread Matt Kraai
Michael Haggerty mhagger at alum.mit.edu writes:
...
 -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.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html