summaryrefslogtreecommitdiff
path: root/src/remove.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/remove.c')
-rw-r--r--src/remove.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/remove.c b/src/remove.c
index cf808dd21..c5cba1e39 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -55,10 +55,8 @@
# define ROOT_CAN_UNLINK_DIRS 1
#endif
-#if HAVE_WORKING_READDIR
-# define IF_READDIR_NEEDS_REWINDDIR(Code) /* empty */
-#else
-# define IF_READDIR_NEEDS_REWINDDIR(Code) Code
+#ifndef HAVE_WORKING_READDIR
+# define HAVE_WORKING_READDIR 0
#endif
enum Ternary
@@ -810,7 +808,7 @@ remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb,
DIR *dirp = opendir (".");
struct AD_ent *top = AD_stack_top (ds);
enum RM_status status = top->status;
- IF_READDIR_NEEDS_REWINDDIR (int performed_unlink_or_rmdir = 0);
+ bool need_rewinddir = false;
assert (VALID_STATUS (status));
*subdir = NULL;
@@ -846,18 +844,13 @@ remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb,
/* Arrange to give a diagnostic after exiting this loop. */
dirp = NULL;
}
- else
+ else if (need_rewinddir)
{
-#if ! HAVE_WORKING_READDIR
/* On buggy systems, call rewinddir if we've called unlink
or rmdir since the opendir or a previous rewinddir. */
- if (performed_unlink_or_rmdir)
- {
- rewinddir (dirp);
- performed_unlink_or_rmdir = 0;
- continue;
- }
-#endif
+ rewinddir (dirp);
+ need_rewinddir = false;
+ continue;
}
break;
}
@@ -878,7 +871,7 @@ remove_cwd_entries (Dirstack_state *ds, char **subdir, struct stat *subdir_sb,
case RM_OK:
/* On buggy systems, record the fact that we've just
removed a directory entry. */
- IF_READDIR_NEEDS_REWINDDIR (performed_unlink_or_rmdir = 1);
+ need_rewinddir = ! HAVE_WORKING_READDIR;
break;
case RM_ERROR: