[PATCH v2] Add LFS support for fts functions [BZ #11460]
Dmitry V. Levin
ldv@altlinux.org
Tue Oct 13 08:30:00 GMT 2015
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20151013/c81630a5/attachment.sig>
More information about the Libc-alpha
mailing list