This is the mail archive of the cygwin-patches mailing list for the Cygwin 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: [1.7] rename/renameat error


On Fri, Sep 25, 2009 at 06:03:22PM -0600, Eric Blake wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>According to Christopher Faylor on 9/25/2009 9:11 AM:
>>> >+  /* POSIX says mkdir("symlink-to-missing/") should create the
>>> >+     directory "missing", but Linux rejects it with EEXIST.  Copy
>>> >+     Linux behavior for now.  */
>>> >+
>>> >+  dlen = strlen (dir);
>>> >+  if (isdirsep (dir[dlen - 1]))
>> 
>> Couldn't this index negatively if dir is zero length?
>
>Yep, and so could rename, where this was copied from.  Fixed in the respin
>below.
>
>> 
>>> >+    {
>>> >+      stpcpy (newbuf = tp.c_get (), dir);
>> 
>>Since stpcpy returns a pointer to the end of the buffer couldn't we use
>>that and do pointer arithmetic rather than index arithmetic?
>
>Theoretically, a good compiler can do just as well with either.

But a good compiler is not going to infer that stpcpy is returning
something that you're essentially calculating in the next line.

>But how does it look now?

It looks good.  Thanks.  Please check in.

cgf


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