summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2006-11-25 11:01:28 +0100
committerJim Meyering <jim@meyering.net>2006-11-26 17:39:53 +0100
commit1b95d5ee81d8621ff54d65ca3700c977c738610a (patch)
tree7dd951a5a80cc23cb7d3f4508886ec5a12adf727
parent6b7c67ad88613f80028ac875ca052eb0a2af9c46 (diff)
downloadcoreutils-1b95d5ee81d8621ff54d65ca3700c977c738610a.tar.xz
* src/remove.c (AD_pop_and_chdir): Return prev_dir rather than storing through
a pointer argument. All uses changed. Signed-off-by: Paul Eggert <eggert@cs.ucla.edu>
-rw-r--r--ChangeLog2
-rw-r--r--src/remove.c22
2 files changed, 13 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index b005871f6..90c930ff8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,8 @@
Replace each of two uses with literal AT_FDCWD.
(cache_stat_init): Return its argument, for convenience.
Update the caller in remove_dir.
+ (AD_pop_and_chdir): Return prev_dir rather than storing through
+ a pointer argument. All uses changed.
2006-11-25 Jim Meyering <jim@meyering.net>
diff --git a/src/remove.c b/src/remove.c
index ce9b3ddf2..03b7837a4 100644
--- a/src/remove.c
+++ b/src/remove.c
@@ -438,11 +438,11 @@ ds_free (Dirstack_state *ds)
that the post-chdir dev/ino numbers for `.' match the saved ones.
If any system call fails or if dev/ino don't match then give a
diagnostic and longjump out.
- Set *PREV_DIR to the name (in malloc'd storage) of the
+ Return the name (in malloc'd storage) of the
directory (usually now empty) from which we're coming, and which
corresponds to the input value of *DIRP. */
-static void
-AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
+static char *
+AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds)
{
struct AD_ent *leaf_dir_ent = AD_stack_top(ds);
struct dev_ino leaf_dev_ino = leaf_dir_ent->dev_ino;
@@ -451,7 +451,7 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
/* Get the name of the current (but soon to be `previous') directory
from the top of the stack. */
- *prev_dir = top_dir (ds);
+ char *prev_dir = top_dir (ds);
AD_stack_pop (ds);
pop_dir (ds);
@@ -479,7 +479,7 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
if (closedir (*dirp) != 0)
{
error (0, errno, _("FATAL: failed to close directory %s"),
- quote (full_filename (*prev_dir)));
+ quote (full_filename (prev_dir)));
goto next_cmdline_arg;
}
@@ -492,7 +492,7 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
if (fd < 0)
{
error (0, errno, _("FATAL: cannot open .. from %s"),
- quote (full_filename (*prev_dir)));
+ quote (full_filename (prev_dir)));
goto next_cmdline_arg;
}
@@ -522,7 +522,7 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
close (fd);
next_cmdline_arg:;
- free (*prev_dir);
+ free (prev_dir);
longjmp (ds->current_arg_jumpbuf, 1);
}
}
@@ -531,11 +531,13 @@ AD_pop_and_chdir (DIR **dirp, Dirstack_state *ds, char **prev_dir)
if (closedir (*dirp) != 0)
{
error (0, errno, _("FATAL: failed to close directory %s"),
- quote (full_filename (*prev_dir)));
+ quote (full_filename (prev_dir)));
goto next_cmdline_arg;
}
*dirp = NULL;
}
+
+ return prev_dir;
}
/* Initialize *HT if it is NULL.
@@ -1389,9 +1391,7 @@ remove_dir (int fd_cwd, Dirstack_state *ds, char const *dir,
{
/* The name of the directory that we have just processed,
nominally removing all of its contents. */
- char *empty_dir;
-
- AD_pop_and_chdir (&dirp, ds, &empty_dir);
+ char *empty_dir = AD_pop_and_chdir (&dirp, ds);
int fd = (dirp != NULL ? dirfd (dirp) : AT_FDCWD);
assert (dirp != NULL || AD_stack_height (ds) == 1);