Re: [PATCH v3 02/10] unix-sockets: use strbuf_getcwd()
From: Jeff King <hidden>
Date: 2016-06-15 23:02:03
On Mon, Jul 28, 2014 at 08:25:40PM +0200, René Scharfe wrote:
quoted hunk ↗ jump to hunk
Instead of using a PATH_MAX-sized buffer, which can be too small on some file systems, use strbuf_getcwd(), which handles any path getcwd() returns. Also preserve the errno set by strbuf_getcwd() instead of setting it to ENAMETOOLONG; that way a more appropriate error message can be shown based on the actual reason for failing. Signed-off-by: Rene Scharfe <redacted> --- unix-socket.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)diff --git a/unix-socket.c b/unix-socket.c index 91bd6b8..19ed48b 100644 --- a/unix-socket.c +++ b/unix-socket.c@@ -18,12 +18,12 @@ static int chdir_len(const char *orig, int len) } struct unix_sockaddr_context { - char orig_dir[PATH_MAX]; + char *orig_dir; };
I would have expected this to just convert to a strbuf. I guess, though that you were making this...
static void unix_sockaddr_cleanup(struct unix_sockaddr_context *ctx)
{
- if (!ctx->orig_dir[0])
+ if (!ctx->orig_dir)
return;...a little nicer by using the pointer to check for validity. Looks good to me. -Peff