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: RFC V3 [1/2] test-in-container


On 06/25/2018 11:48 PM, DJ Delorie wrote:
   slash_p = strrchr (path, '/');
   if (slash_p)

No implicit comparison against NULL, please.

     {
       while (slash_p > path && slash_p[-1] == '/')
	--slash_p;
       if (slash_p > path)
	{
	  char *parent = xstrndup (path, slash_p - path);
	  rv = xmkdirp (parent, mode);
	  free (parent);
	}
     }

   rv = mkdir (path, mode);
   if (rv != 0)
     FAIL_EXIT1 ("mkdir_p (\"%s\", 0%o): %m", path, mode);

The recursion is a bit awkward, but I think it will give a reasonable error code because of the preceding stat check (which is repeated many times unnecessarily). But for test support code, that's fine, I think.

Thanks,
Florian


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