On Fri, Oct 28, 2005 at 04:07:53PM -0700, Paul Eggert wrote:
> I installed this patch instead, both in gnulib and coreutils.
[...]
> @@ -70,7 +70,6 @@ char *
>  savedir (const char *dir)
>  {
>    DIR *dirp;
> -  struct dirent *dp;
>    char *name_space;
>    size_t allocated = NAME_SIZE_DEFAULT;
>    size_t used = 0;
> @@ -82,12 +81,19 @@ savedir (const char *dir)
>  
>    name_space = xmalloc (allocated);
>  
> -  errno = 0;
> -  while ((dp = readdir (dirp)) != NULL)
> +  for (;;)
>      {
> +      struct dirent const *dp;
> +      char const *entry;
> +
> +      errno = 0;
> +      dp = readdir (dirp);
> +      if (! dp)
> +     break;
> +

I must say here that if errno is used to test for readdir() errors like in
this example, then errno should be cleared before each readdir() call, not
just before first one.  Similar issue exists in lib/getcwd.c


-- 
ldv

Attachment: pgpMN9ywUqbib.pgp
Description: PGP signature

_______________________________________________
Bug-coreutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to