This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 7/8] posix: Use char_array for home_dir in glob


On Nov 21 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> @@ -645,44 +655,48 @@ __glob (const char *pattern, int flags, int (*errfunc) (const char *, int),
>  		  if (!scratch_buffer_grow (&s))
>  		    goto err_nospace;
>  		}
> -	      if (err == 0)
> -		{
> -		  home_dir = strdup (p->pw_dir);
> -		  malloc_home_dir = 1;
> -		}
> +	      bool e = (err == 0 && char_array_set_str (&home_dir, p->pw_dir));
>  	      scratch_buffer_free (&s);
> -	      if (err == 0 && home_dir == NULL)
> +	      if (e == false)

!e


>  	  /* Now construct the full directory.  */
> +	  bool e = true;
>  	  if (char_array_pos (&dirname, 1) == '\0')
>  	    {
> -	      if (!char_array_set_str (&dirname, home_dir))
> -		goto err_nospace;
> +	      e = char_array_set_str (&dirname, char_array_str (&home_dir));
>  	      dirlen = char_array_size (&dirname) - 1;
>  	    }
>  	  else
>  	    {
>  	      /* Replaces '~' by the obtained HOME dir.  */
>  	      char_array_erase (&dirname, 0);
> -	      if (!char_array_prepend_str (&dirname, home_dir))
> -		goto err_nospace;
> +	      e = char_array_prepend_str (&dirname,
> +					  char_array_str (&home_dir));
> +	    }
> +	  if (e == false)

!e

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]