public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH 7/8] posix: Use char_array for home_dir in glob
Date: Tue, 21 Nov 2017 14:24:00 -0000	[thread overview]
Message-ID: <mvmtvxn3e26.fsf@suse.de> (raw)
In-Reply-To: <1511272530-10936-8-git-send-email-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Tue, 21 Nov 2017 11:55:29 -0200")

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."

  reply	other threads:[~2017-11-21 14:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 13:55 [PATCH 0/8] posix: glob fixes and refactor Adhemerval Zanella
2017-11-21 13:55 ` [PATCH 7/8] posix: Use char_array for home_dir in glob Adhemerval Zanella
2017-11-21 14:24   ` Andreas Schwab [this message]
2017-11-21 13:55 ` [PATCH 6/8] posix: Remove alloca usage on glob user_name Adhemerval Zanella
2017-11-21 13:55 ` [PATCH 1/8] malloc: Add specialized dynarray for C strings Adhemerval Zanella
2017-11-21 14:15   ` Andreas Schwab
2017-11-21 16:20     ` Adhemerval Zanella
2017-11-21 14:19   ` Andreas Schwab
2017-11-21 16:32     ` Adhemerval Zanella
2017-11-21 13:55 ` [PATCH 2/8] posix: Use char_array for internal glob dirname Adhemerval Zanella
2017-11-21 13:55 ` [PATCH 3/8] posix: Remove alloca usage for GLOB_BRACE on glob Adhemerval Zanella
2017-11-21 13:55 ` [PATCH 8/8] posix: Remove all alloca usage in glob Adhemerval Zanella
2017-11-21 13:55 ` [PATCH 5/8] posix: Use dynarray for globname " Adhemerval Zanella
2017-11-21 13:55 ` [PATCH 4/8] posix: Remove alloca usage on glob dirname Adhemerval Zanella
2017-12-12 17:02 ` [PATCH 0/8] posix: glob fixes and refactor Adhemerval Zanella
2021-01-05 18:58 [PATCH 0/8] Remove alloca usage from glob Adhemerval Zanella
2021-01-05 18:58 ` [PATCH 7/8] posix: Use char_array for home_dir in glob Adhemerval Zanella

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=mvmtvxn3e26.fsf@suse.de \
    --to=schwab@suse.de \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).