Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Bruno Haible
Andreas Dilger wrote: > I was worried if > "ls" or something is saving all of the symlink targets in memory that using a > too-large buffer size would cause excess memory to be allocated for a long > time. Good point. careadlinkat.c has a "Shrink BUF before returning it." logic, but not all simil

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Bruno Haible
Hi, Andreas Dilger wrote: > + size_t buf_size = size < initial_limit ? (size ?: 31) + 1 : initial_limit; This syntax is specific to GCC [1]. In patches for gnulib, please stick to portable C99 syntax. Thanks. Bruno [1] https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Conditionals.html

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Andreas Dilger
On Jul 4, 2019, at 04:44, Pádraig Brady wrote: > > diff --git a/lib/areadlink-with-size.c b/lib/areadlink-with-size.c > index eacad3f..2fbe51c 100644 > --- a/lib/areadlink-with-size.c > +++ b/lib/areadlink-with-size.c > @@ -36,14 +36,15 @@ > check, so it's OK to guess too small on hosts where

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Andreas Dilger
On Jul 4, 2019, at 04:44, Pádraig Brady wrote: > > On 03/07/19 21:24, Andreas Dilger wrote: >> When calling 'stat -c %N' to print the filename, don't explicitly >> request the size of the file via statx(), as it may add overhead on >> some filesystems. The size is only needed to optimize an allo

[PATCH] areadlink-with-size: guess a lower bound with 0 size

2019-07-04 Thread Pádraig Brady
BTW this would allocate more for empty symlinks, but they're rare: https://lwn.net/Articles/551224/ cheers, Pádraig >From 6be031b4c9d6cb742a010dbe3fe38f77fe515fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draig=20Brady?= Date: Thu, 4 Jul 2019 11:50:16 +0100 Subject: [PATCH] areadlink-with-s

Re: [PATCH] stat: don't explicitly request file size for filenames

2019-07-04 Thread Pádraig Brady
On 03/07/19 21:24, Andreas Dilger wrote: > When calling 'stat -c %N' to print the filename, don't explicitly > request the size of the file via statx(), as it may add overhead on > some filesystems. The size is only needed to optimize an allocation > for the relatively rare case of reading a symli