[patch] cygcheck.cc update for cygpath()

Brian Dessent brian@dessent.net
Tue Mar 11 17:09:00 GMT 2008

Corinna Vinschen wrote:

> Btw., you don't need to make the buffers MAX_PATH + 1.  MAX_PATH is
> defined including the trailing NUL.  Existing code shows a lot of
> irritation about this...

Oh, I wasn't even thinking of that... the reason I used MAX_PATH + 1 was
because earlier I had written

+      static char tmp[SYMLINK_MAX + 1];

so that the following sizes would not need to be SYMLINK_MAX - 1, 

+      if (!readlink (fh, tmp, SYMLINK_MAX))

+	  strncpy (tmp, cygpath (papp, NULL), SYMLINK_MAX);

+	  strncpy (lastsep+1, ptr, SYMLINK_MAX - (lastsep-tmp));

I.e. pure lazyness of wanting to type the least necessary.  But now that
you mention it, it makes more sense to have the "- 1" than the "+ 1"
form, so I'll change that.


More information about the Cygwin-patches mailing list