[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Findutils-patches] [PATCH] Rename local and member "dirfd" to avoid sha
From: |
Jim Meyering |
Subject: |
[Findutils-patches] [PATCH] Rename local and member "dirfd" to avoid shadowing the function |
Date: |
Mon, 10 Mar 2008 10:11:01 +0100 |
Rename local and member "dirfd" to avoid shadowing the function.
This avoids many warnings from gcc -Wshadow:
* lib/buildcmd.h (struct buildcmd_state) [dir_fd]: Rename member
from dirfd.
* find/defs.h (struct exec_val) [dir_fd]: Likewise.
Rename parameter in prototype.
* find/ftsfind.c (inside_dir): Rename parameter: s/dirfd/dir_fd/
* find/parser.c (new_insert_exec_ok, insert_exec_ok): Likewise.
* find/pred.c (new_impl_pred_exec, prep_child_for_exec, launch):
s/dirfd/dir_fd/
* find/util.c (do_complete_pending_execdirs): Likewise.
(complete_pending_execdirs): Likewise
* lib/buildcmd.c (bc_init_state, bc_clear_args): Likewise.
* lib/dircallback.c (run_in_dir): Likewise.
* lib/dircallback.h (DIRCALLBACK_H): Likewise.
* lib/listfile.c (list_file, get_link_name_at): Likewise.
* lib/listfile.h (LISTFILE_H): Likewise.
Signed-off-by: Jim Meyering <address@hidden>
---
find/defs.h | 7 ++++---
find/ftsfind.c | 22 +++++++++++-----------
find/parser.c | 12 ++++++------
find/pred.c | 18 +++++++++---------
find/util.c | 13 +++++++------
lib/buildcmd.c | 7 ++++---
lib/buildcmd.h | 4 ++--
lib/dircallback.c | 8 ++++----
lib/dircallback.h | 4 ++--
lib/listfile.c | 11 ++++++-----
lib/listfile.h | 4 ++--
12 files changed, 61 insertions(+), 53 deletions(-)
diff --git a/find/defs.h b/find/defs.h
index d076aa9..1708d83 100644
--- a/find/defs.h
+++ b/find/defs.h
@@ -1,5 +1,6 @@
/* defs.h -- data types and declarations.
- Copyright (C) 1990, 91, 92, 93, 94, 2000, 2004, 2005, 2006, 2007 Free
Software Foundation, Inc.
+ Copyright (C) 1990, 91, 92, 93, 94, 2000, 2004, 2005,
+ 2006, 2007, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -196,7 +197,7 @@ struct exec_val
int num_args;
boolean use_current_dir; /* If nonzero, don't chdir to start dir */
boolean close_stdin; /* If true, close stdin in the child. */
- int dirfd; /* The directory to do the exec in. */
+ int dir_fd; /* The directory to do the exec in. */
};
/* The format string for a -printf or -fprintf is chopped into one or
@@ -489,7 +490,7 @@ struct predicate *insert_primary_withpred PARAMS((const
struct parser_table *ent
void usage PARAMS((FILE *fp, int status, char *msg));
extern boolean check_nofollow(void);
void complete_pending_execs(struct predicate *p);
-void complete_pending_execdirs(int dirfd); /* Passing dirfd is an unpleasant
CodeSmell. */
+void complete_pending_execdirs(int dir_fd); /* Passing dir_fd is an unpleasant
CodeSmell. */
const char *safely_quote_err_filename (int n, char const *arg);
void fatal_file_error(const char *name) ATTRIBUTE_NORETURN;
void nonfatal_file_error(const char *name);
diff --git a/find/ftsfind.c b/find/ftsfind.c
index 7f882a6..543b80f 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -1,6 +1,6 @@
/* find -- search for files in a directory hierarchy (fts version)
- Copyright (C) 1990, 91, 92, 93, 94, 2000,
- 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1990, 91, 92, 93, 94, 2000, 2003, 2004, 2005, 2006,
+ 2007, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -133,34 +133,34 @@ static void left_dir(void)
}
/*
- * Signal that we are now inside a directory pointed to by dirfd.
+ * Signal that we are now inside a directory pointed to by dir_fd.
* The caller can't tell if this is the first time this happens, so
* we have to be careful not to call dup() more than once
*/
-static void inside_dir(int dirfd)
+static void inside_dir(int dir_fd)
{
if (ftsoptions & FTS_CWDFD)
{
- assert (dirfd == AT_FDCWD || dirfd >= 0);
+ assert (dir_fd == AT_FDCWD || dir_fd >= 0);
- state.cwd_dir_fd = dirfd;
+ state.cwd_dir_fd = dir_fd;
if (curr_fd < 0)
{
- if (AT_FDCWD == dirfd)
+ if (AT_FDCWD == dir_fd)
{
curr_fd = AT_FDCWD;
}
- else if (dirfd >= 0)
+ else if (dir_fd >= 0)
{
- curr_fd = dup(dirfd);
+ curr_fd = dup(dir_fd);
set_close_on_exec(curr_fd);
}
else
{
- /* curr_fd is invalid, but dirfd is also invalid.
+ /* curr_fd is invalid, but dir_fd is also invalid.
* This should not have happened.
*/
- assert (curr_fd >= 0 || dirfd >= 0);
+ assert (curr_fd >= 0 || dir_fd >= 0);
}
}
}
diff --git a/find/parser.c b/find/parser.c
index b7ef88f..246c4ce 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -1,6 +1,6 @@
/* parser.c -- convert the command line args into an expression tree.
- Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2003,
- 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2001, 2003,
+ 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -178,7 +178,7 @@ static struct segment **make_segment PARAMS((struct segment
**segment,
struct predicate *pred));
static boolean insert_exec_ok PARAMS((const char *action,
const struct parser_table *entry,
- int dirfd,
+ int dir_fd,
char *argv[],
int *arg_ptr));
static boolean get_comp_type PARAMS((const char **str,
@@ -3001,7 +3001,7 @@ check_path_safety(const char *action, char **argv)
static boolean
new_insert_exec_ok (const char *action,
const struct parser_table *entry,
- int dirfd,
+ int dir_fd,
char **argv,
int *arg_ptr)
{
@@ -3205,11 +3205,11 @@ new_insert_exec_ok (const char *action,
static boolean
insert_exec_ok (const char *action,
const struct parser_table *entry,
- int dirfd,
+ int dir_fd,
char **argv,
int *arg_ptr)
{
- return new_insert_exec_ok(action, entry, dirfd, argv, arg_ptr);
+ return new_insert_exec_ok(action, entry, dir_fd, argv, arg_ptr);
}
diff --git a/find/pred.c b/find/pred.c
index 75e6774..d758276 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -1,5 +1,5 @@
/* pred.c -- execute the expression tree.
- Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2003,
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 2000, 2003,
2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -499,7 +499,7 @@ pred_empty (const char *pathname, struct stat *stat_buf,
struct predicate *pred_
}
static boolean
-new_impl_pred_exec (int dirfd, const char *pathname,
+new_impl_pred_exec (int dir_fd, const char *pathname,
struct stat *stat_buf,
struct predicate *pred_ptr,
const char *prefix, size_t pfxlen)
@@ -508,7 +508,7 @@ new_impl_pred_exec (int dirfd, const char *pathname,
size_t len = strlen(pathname);
(void) stat_buf;
- execp->dirfd = dirfd;
+ execp->dir_fd = dir_fd;
if (execp->multiple)
{
/* Push the argument onto the current list.
@@ -1862,7 +1862,7 @@ pred_xtype (const char *pathname, struct stat *stat_buf,
struct predicate *pred_
static boolean
-prep_child_for_exec (boolean close_stdin, int dirfd)
+prep_child_for_exec (boolean close_stdin, int dir_fd)
{
boolean ok = true;
if (close_stdin)
@@ -1898,10 +1898,10 @@ prep_child_for_exec (boolean close_stdin, int dirfd)
* announcement of a call to stat() anyway, as we're about to exec
* something.
*/
- if (dirfd != AT_FDCWD)
+ if (dir_fd != AT_FDCWD)
{
- assert (dirfd >= 0);
- if (0 != fchdir(dirfd))
+ assert (dir_fd >= 0);
+ if (0 != fchdir(dir_fd))
{
/* If we cannot execute our command in the correct directory,
* we should not execute it at all.
@@ -1927,7 +1927,7 @@ launch (const struct buildcmd_control *ctl,
if (!execp->use_current_dir)
{
assert (starting_desc >= 0);
- assert (execp->dirfd == starting_desc);
+ assert (execp->dir_fd == starting_desc);
}
@@ -1952,7 +1952,7 @@ launch (const struct buildcmd_control *ctl,
{
/* We are the child. */
assert (starting_desc >= 0);
- if (!prep_child_for_exec(execp->close_stdin, execp->dirfd))
+ if (!prep_child_for_exec(execp->close_stdin, execp->dir_fd))
{
_exit(1);
}
diff --git a/find/util.c b/find/util.c
index 40f36d5..a06eada 100644
--- a/find/util.c
+++ b/find/util.c
@@ -1,5 +1,6 @@
/* util.c -- functions for initializing new tree elements, and other things.
- Copyright (C) 1990, 91, 92, 93, 94, 2000, 2003, 2004, 2005 Free Software
Foundation, Inc.
+ Copyright (C) 1990, 91, 92, 93, 94, 2000, 2003, 2004, 2005,
+ 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -288,14 +289,14 @@ check_nofollow(void)
* have no effect if there are no arguments waiting).
*/
static void
-do_complete_pending_execdirs(struct predicate *p, int dirfd)
+do_complete_pending_execdirs(struct predicate *p, int dir_fd)
{
if (NULL == p)
return;
assert (state.execdirs_outstanding);
- do_complete_pending_execdirs(p->pred_left, dirfd);
+ do_complete_pending_execdirs(p->pred_left, dir_fd);
if (pred_is(p, pred_execdir) || pred_is(p, pred_okdir))
{
@@ -315,15 +316,15 @@ do_complete_pending_execdirs(struct predicate *p, int
dirfd)
}
}
- do_complete_pending_execdirs(p->pred_right, dirfd);
+ do_complete_pending_execdirs(p->pred_right, dir_fd);
}
void
-complete_pending_execdirs(int dirfd)
+complete_pending_execdirs(int dir_fd)
{
if (state.execdirs_outstanding)
{
- do_complete_pending_execdirs(get_eval_tree(), dirfd);
+ do_complete_pending_execdirs(get_eval_tree(), dir_fd);
state.execdirs_outstanding = false;
}
}
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index bda2492..6c6a9c4 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -1,5 +1,6 @@
/* buildcmd.c -- build command lines from a list of arguments.
- Copyright (C) 1990, 91, 92, 93, 94, 2000, 2003, 2005, 2006, 2007 Free
Software Foundation, Inc.
+ Copyright (C) 1990, 91, 92, 93, 94, 2000, 2003, 2005, 2006,
+ 2007, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -538,7 +539,7 @@ bc_init_state(const struct buildcmd_control *ctl,
state->cmd_argv_chars = state->cmd_initial_argv_chars = 0;
state->todo = 0;
- state->dirfd = -1;
+ state->dir_fd = -1;
state->usercontext = context;
}
@@ -549,5 +550,5 @@ bc_clear_args(const struct buildcmd_control *ctl,
state->cmd_argc = ctl->initial_argc;
state->cmd_argv_chars = state->cmd_initial_argv_chars;
state->todo = 0;
- state->dirfd = -1;
+ state->dir_fd = -1;
}
diff --git a/lib/buildcmd.h b/lib/buildcmd.h
index cbd3f84..e295852 100644
--- a/lib/buildcmd.h
+++ b/lib/buildcmd.h
@@ -1,5 +1,5 @@
/* buildcmd.[ch] -- build command lines from a stream of arguments
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -47,7 +47,7 @@ struct buildcmd_state
int todo;
/* Directory in which to perform the exec. */
- int dirfd;
+ int dir_fd;
};
struct buildcmd_control
diff --git a/lib/dircallback.c b/lib/dircallback.c
index b551c02..29fb276 100644
--- a/lib/dircallback.c
+++ b/lib/dircallback.c
@@ -1,5 +1,5 @@
/* listfile.c -- run a function in a specific directory
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -59,9 +59,9 @@
int
-run_in_dir (int dirfd, int (*callback)(void*), void *usercontext)
+run_in_dir (int dir_fd, int (*callback)(void*), void *usercontext)
{
- if (dirfd == AT_FDCWD)
+ if (dir_fd == AT_FDCWD)
{
return (*callback)(usercontext);
}
@@ -74,7 +74,7 @@ run_in_dir (int dirfd, int (*callback)(void*), void
*usercontext)
if (save_cwd (&saved_cwd) != 0)
openat_save_fail (errno);
- if (fchdir (dirfd) != 0)
+ if (fchdir (dir_fd) != 0)
{
saved_errno = errno;
free_cwd (&saved_cwd);
diff --git a/lib/dircallback.h b/lib/dircallback.h
index abce104..41ea282 100644
--- a/lib/dircallback.h
+++ b/lib/dircallback.h
@@ -1,5 +1,5 @@
/* listfile.h -- display a long listing of a file
- Copyright (C) 2007 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -19,6 +19,6 @@
#if !defined DIRCALLBACK_H
# define DIRCALLBACK_H
-int run_in_dir (int dirfd, int (*callback)(void*), void *usercontext);
+int run_in_dir (int dir_fd, int (*callback)(void*), void *usercontext);
#endif
diff --git a/lib/listfile.c b/lib/listfile.c
index 9b4ed20..ca9eae2 100644
--- a/lib/listfile.c
+++ b/lib/listfile.c
@@ -1,5 +1,6 @@
/* listfile.c -- display a long listing of a file
- Copyright (C) 1991, 1993, 2000, 2004, 2005, 2007 Free Software Foundation,
Inc.
+ Copyright (C) 1991, 1993, 2000, 2004, 2005, 2007,
+ 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -185,7 +186,7 @@ file_blocksize(const struct stat *p)
void
list_file (const char *name,
- int dirfd,
+ int dir_fd,
char *relname,
const struct stat *statp,
time_t current_time,
@@ -299,7 +300,7 @@ list_file (const char *name,
#ifdef S_ISLNK
if (S_ISLNK (statp->st_mode))
{
- char *linkname = get_link_name_at (name, dirfd, relname);
+ char *linkname = get_link_name_at (name, dir_fd, relname);
if (linkname)
{
@@ -417,13 +418,13 @@ get_link_name_cb(void *context)
}
char *
-get_link_name_at (const char *name, int dirfd, char *relname)
+get_link_name_at (const char *name, int dir_fd, char *relname)
{
struct link_name_args args;
args.result = NULL;
args.name = name;
args.relname = relname;
- if (0 == run_in_dir(dirfd, get_link_name_cb, &args))
+ if (0 == run_in_dir(dir_fd, get_link_name_cb, &args))
return args.result;
else
return NULL;
diff --git a/lib/listfile.h b/lib/listfile.h
index d894d23..0f162fe 100644
--- a/lib/listfile.h
+++ b/lib/listfile.h
@@ -1,5 +1,5 @@
/* listfile.h -- display a long listing of a file
- Copyright (C) 1991, 1993, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1991, 1993, 2000, 2008 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -21,7 +21,7 @@
void list_file (const char *name, int dir_fd, char *relname, const struct stat
*statp, time_t current_time, int output_block_size, int literal_control_chars,
FILE *stream);
-char * get_link_name_at (const char *name, int dirfd, char *relname);
+char * get_link_name_at (const char *name, int dir_fd, char *relname);
size_t file_blocksize(const struct stat *p);
--
1.5.4.4.482.g5f904
- [Findutils-patches] [PATCH] Rename local and member "dirfd" to avoid shadowing the function,
Jim Meyering <=