Re: [PATCH v3 02/10] unix-sockets: use strbuf_getcwd()
- From
Jeff King <peff@peff.net>
- Date
- Jul 28, 2014, 18:51 UTC
- Message-ID
- <20140728185109.GB11265@peff.net>
- In-Reply-To
- <53D695A4.2030403@web.de>
On Mon, Jul 28, 2014 at 08:25:40PM +0200, René Scharfe wrote:
Show 22 quoted lines
> 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 <l.s.r@web.de>
> ---
> 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...
Show 6 quoted lines
>
> 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