From: Alex Riesen Date: Thu, 26 Apr 2007 12:14:51 GMT Subject: Re: [PATCH] Use PATH_MAX rather than a hardwired constant maximum length. Message-ID: <81b0412b0704260514k1eeec53ex97df3be600244305@mail.gmail.com> In-Reply-To: <20070426091254.GA23586@midwinter.com> On 4/26/07, koreth@midwinter.com wrote: > Signed-off-by: Steven Grimm > --- > > Is the +1 really needed? The existing code is doing this in other places No, not according SUSv3, where PATH_MAX is defined as "Maximum number of bytes in a pathname, including the terminating null character." http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html#tag_13_24 getcwd expects the size of the buffer, so it can store the cwd _and_ NUL. See ERANGE in in SUSv3: http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html > but I'm not sure it's necessary since we're also doing sizeof(buffer)-1 The -1 is wrong too. > in the getcwd() call. I figured it was best to be consistent with the > existing code, e.g. setup_git_directory_gently(). setup_git_directory_gently is wrong. But it does not really matter in practice.