[PATCH v3] server: Fail if non-empty directory marked for deletion.

Daniel Lehman dlehman25 at gmail.com
Thu May 28 19:44:32 CDT 2020


> > +    empty = 1;
> > +    while (empty && (de = readdir( dir )))
> > +    {
> > +        if (!strcmp( de->d_name, "." ) || !strcmp( de->d_name, ".." )) continue;
> > +        empty = 0;
>
> You could probably break from the loop after this point, since you found what you were looking for.

it does break the loop.  i originally had an explicit break, but
changed it to break when empty is zeroed.  i can switch it back if
preferred

> > +    }
> > +    closedir( dir );
> > +    close( fd );
>
> This close(2) call shouldn't be necessary, since closedir(3) does that for you. It's the reason I suggested dup(2)'ing the fd in the first place. Leaving this in will set errno to EBADF, which may not be desirable.

i had considered that, but the documentation suggests that using a
file descriptor is implementation-dependent.  i know that's the case
for linux, but not sure about the others.  from docs, it looks like
freebsd, macosx, and android are the same.  if that covers it, i'll
remove the close

thanks
daniel



More information about the wine-devel mailing list