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 v2] Add LFS support for fts functions [BZ #11460]


On Mon, Oct 12, 2015 at 09:52:58PM +0200, Mark Wielaard wrote:
[...]
> +static void
> +make_dir (const char *dirname)
> +{
> +  char *name = NULL;
> +  if (asprintf (&name, "%s/%s", fts_test_dir, dirname) < 0)
> +    {
> +      puts ("out of memory");
> +      exit (1);
> +    }
[...]
> +static void
> +prepare (void)
> +{
> +  size_t test_dir_len = strlen (test_dir);
> +  char dir_name[] = "/tst-fts.XXXXXX";
> +
> +  size_t dirbuflen = test_dir_len + sizeof (dir_name);
> +  char *dirbuf = malloc (dirbuflen);
> +  if (dirbuf == NULL)
> +    {
> +      puts ("out of memory");
> +      exit (1);
> +    }
> +
> +  snprintf (dirbuf, dirbuflen, "%s%s", test_dir, dir_name);

Wouldn't it be better to use asprintf instead of malloc+snprintf in the
second case, too?


-- 
ldv

Attachment: pgplq3VKQUP8y.pgp
Description: PGP signature


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