diff options
author | James Youngman <jay@gnu.org> | 2011-06-14 23:14:21 +0100 |
---|---|---|
committer | James Youngman <jay@gnu.org> | 2011-06-14 23:24:54 +0100 |
commit | f932373da8443e85dbe7bef125ceca0ba5976779 (patch) | |
tree | a61ae8d76ea40029820b4056fa913846fc01b40e | |
parent | 4f1a351a23a0995faba9cc72f51d02fdeaa8f38e (diff) | |
download | findutils-f932373da8443e85dbe7bef125ceca0ba5976779.tar.gz |
Eliminate some compiler warnings.
* find/find.c: Remove definition of SAFE_CHDIR, which we don't
use.
* find/defs.h: Remove redundant declaration of launch.
* find/parser.c (parse_false): Cast unused arguments to void.
(parse_print0): Likewise.
(pred_context): Likewise.
(parse_newerXY): Add some parens for slightly greater clarity.
(make_segment): Avoid switch-missing-default-case warning by
turning it into an if statement.
(check_path_safety): Remove unused argument.
(insert_exec_ok): Don't pass the unwanted arugment to
check_path_safety.
(get_relative_timestamp): silence compiler warning by adding a
case for the remaining enumberation value rather than using
default.
* find/pred.c (months): the strings can be const char*, rather
than just char*.
(ctime_format): change TIME_BUF_LEN to an integer constant to
avoid signed/unsigned comparison.
(blank_rtrim): Change to new-style function definition(!) and
remove unnecessary parentheses around a return value.
* lib/buildcmd.c: Omit redundant declaration of environ.
* find/tree.c (get_expr): Make static.
(cost_assoc): make the name field const.
(prec_assoc): make the prec_name field const.
(op_assoc): make the type_name field const.
(type_name): turn into an ANSI function definition(!).
(prec_name): Likewise! Also remove spurious parentheses around
return value.
(prec_name): Remove spurious parentheses around return value.
* lib/buildcmd.h (buildcmd_state): change types of several fields
to size_t: cmd_argc, cmd_argv_alloc, largest_successful_arg_count,
smallest_failed_arg_count.
(buildcmd_control): change types of several fields
to size_t: max_arg_count, initial_argc, lines_per_exec,
args_per_exec.
-rw-r--r-- | ChangeLog | 38 | ||||
-rw-r--r-- | find/defs.h | 2 | ||||
-rw-r--r-- | find/find.c | 1 | ||||
-rw-r--r-- | find/parser.c | 23 | ||||
-rw-r--r-- | find/pred.c | 12 | ||||
-rw-r--r-- | find/tree.c | 18 | ||||
-rw-r--r-- | lib/buildcmd.c | 2 | ||||
-rw-r--r-- | lib/buildcmd.h | 16 |
8 files changed, 74 insertions, 38 deletions
@@ -1,5 +1,43 @@ 2011-06-14 James Youngman <jay@gnu.org> + Eliminate some compiler warnings. + * find/find.c: Remove definition of SAFE_CHDIR, which we don't + use. + * find/defs.h: Remove redundant declaration of launch. + * find/parser.c (parse_false): Cast unused arguments to void. + (parse_print0): Likewise. + (pred_context): Likewise. + (parse_newerXY): Add some parens for slightly greater clarity. + (make_segment): Avoid switch-missing-default-case warning by + turning it into an if statement. + (check_path_safety): Remove unused argument. + (insert_exec_ok): Don't pass the unwanted arugment to + check_path_safety. + (get_relative_timestamp): silence compiler warning by adding a + case for the remaining enumberation value rather than using + default. + * find/pred.c (months): the strings can be const char*, rather + than just char*. + (ctime_format): change TIME_BUF_LEN to an integer constant to + avoid signed/unsigned comparison. + (blank_rtrim): Change to new-style function definition(!) and + remove unnecessary parentheses around a return value. + * lib/buildcmd.c: Omit redundant declaration of environ. + * find/tree.c (get_expr): Make static. + (cost_assoc): make the name field const. + (prec_assoc): make the prec_name field const. + (op_assoc): make the type_name field const. + (type_name): turn into an ANSI function definition(!). + (prec_name): Likewise! Also remove spurious parentheses around + return value. + (prec_name): Remove spurious parentheses around return value. + * lib/buildcmd.h (buildcmd_state): change types of several fields + to size_t: cmd_argc, cmd_argv_alloc, largest_successful_arg_count, + smallest_failed_arg_count. + (buildcmd_control): change types of several fields + to size_t: max_arg_count, initial_argc, lines_per_exec, + args_per_exec. + Assume SIGCHLD and O_NOFOLLOW are defined by gnulib. * find/find.c: Since gnulib defines O_NOFOLLOW, don't check to see if the macro is defined. Check instead to see if it is 0. diff --git a/find/defs.h b/find/defs.h index 17425923..6e111745 100644 --- a/find/defs.h +++ b/find/defs.h @@ -462,8 +462,6 @@ PREDICATEFUNCTION pred_context; -int launch (struct buildcmd_control *ctl, void *usercontext, int argc, char **argv); - char *find_pred_name (PRED_FUNC pred_func); diff --git a/find/find.c b/find/find.c index 09fb5a10..c1b57f22 100644 --- a/find/find.c +++ b/find/find.c @@ -28,7 +28,6 @@ #include <config.h> #include "defs.h" -#define USE_SAFE_CHDIR 1 #undef STAT_MOUNTPOINTS diff --git a/find/parser.c b/find/parser.c index ea676bd6..024e6061 100644 --- a/find/parser.c +++ b/find/parser.c @@ -953,6 +953,9 @@ insert_false(void) static bool parse_false (const struct parser_table* entry, char **argv, int *arg_ptr) { + (void) entry; + (void) argv; + (void) arg_ptr; return insert_false (); } @@ -1614,8 +1617,8 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr) /* -newertY (for any Y) is invalid. */ if (x == 't' - || 0 == strchr (validchars, x) - || 0 == strchr ( validchars, y)) + || (0 == strchr (validchars, x)) + || (0 == strchr ( validchars, y))) { return false; } @@ -2111,6 +2114,9 @@ parse_print (const struct parser_table* entry, char **argv, int *arg_ptr) static bool parse_print0 (const struct parser_table* entry, char **argv, int *arg_ptr) { + (void) entry; + (void) argv; + (void) arg_ptr; return insert_fprint (entry, NULL); } @@ -3106,17 +3112,15 @@ make_segment (struct segment **segment, strncpy (fmt, format, len); fmt += len; - switch (kind) + if (kind == KIND_PLAIN /* Plain text string, no % conversion. */ + || kind == KIND_STOP) /* Terminate argument, no newline. */ { - case KIND_PLAIN: /* Plain text string, no % conversion. */ - case KIND_STOP: /* Terminate argument, no newline. */ assert (0 == format_char); assert (0 == aux_format_char); *fmt = '\0'; if (mycost > pred->p_cost) pred->p_cost = NeedsNothing; return &(*segment)->next; - break; } assert (kind == KIND_FORMAT); @@ -3231,7 +3235,7 @@ make_segment (struct segment **segment, static void -check_path_safety (const char *action, char **argv) +check_path_safety (const char *action) { const char *path = getenv ("PATH"); const char *path_separators = ":"; @@ -3328,7 +3332,7 @@ insert_exec_ok (const char *action, { execp->wd_for_exec = NULL; options.ignore_readdir_race = false; - check_path_safety (action, argv); + check_path_safety (action); } else { @@ -3532,7 +3536,8 @@ get_relative_timestamp (const char *str, { case COMP_LT: result->kind = COMP_GT; break; case COMP_GT: result->kind = COMP_LT; break; - default: break; + case COMP_EQ: + break; /* inversion leaves it unchanged */ } /* Convert the ASCII number into floating-point. */ diff --git a/find/pred.c b/find/pred.c index 4aaebe24..eadd9636 100644 --- a/find/pred.c +++ b/find/pred.c @@ -1732,6 +1732,8 @@ pred_context (const char *pathname, struct stat *stat_buf, security_context_t scontext; int rv = (*options.x_getfilecon) (state.cwd_dir_fd, state.rel_pathname, &scontext); + (void) stat_buf; + if (rv < 0) { error (0, errno, _("getfilecon failed: %s"), @@ -2040,7 +2042,7 @@ static const char *weekdays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; -static char * months[] = +static const char * months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" @@ -2051,7 +2053,7 @@ static char * ctime_format (struct timespec ts) { const struct tm * ptm; -#define TIME_BUF_LEN 1024u +#define TIME_BUF_LEN 1024 static char resultbuf[TIME_BUF_LEN]; int nout; @@ -2094,9 +2096,7 @@ ctime_format (struct timespec ts) Return BUF. */ static char * -blank_rtrim (str, buf) - char *str; - char *buf; +blank_rtrim (char *str, char *buf) { int i; @@ -2107,7 +2107,7 @@ blank_rtrim (str, buf) while ((i >= 0) && ((buf[i] == ' ') || buf[i] == '\t')) i--; buf[++i] = '\0'; - return (buf); + return buf; } /* Print out the predicate list starting at NODE. */ diff --git a/find/tree.c b/find/tree.c index 4bfd77c7..038bfc9a 100644 --- a/find/tree.c +++ b/find/tree.c @@ -112,7 +112,7 @@ matches_start_point (const char *glob, bool foldcase) expression, which really is the expression that should be handed to our caller, so get_expr recurses. */ -struct predicate * +static struct predicate * get_expr (struct predicate **input, short int prev_prec, const struct predicate* prev_pred) @@ -1578,7 +1578,7 @@ get_new_pred_chk_op (const struct parser_table *entry, struct cost_assoc { enum EvaluationCost cost; - char *name; + const char *name; }; struct cost_assoc cost_table[] = { @@ -1598,7 +1598,7 @@ struct cost_assoc cost_table[] = struct prec_assoc { short prec; - char *prec_name; + const char *prec_name; }; static struct prec_assoc prec_table[] = @@ -1615,7 +1615,7 @@ static struct prec_assoc prec_table[] = struct op_assoc { short type; - char *type_name; + const char *type_name; }; static struct op_assoc type_table[] = @@ -1643,27 +1643,25 @@ cost_name (enum EvaluationCost cost) static char * -type_name (type) - short type; +type_name (short type) { int i; for (i = 0; type_table[i].type != (short) -1; i++) if (type_table[i].type == type) break; - return (type_table[i].type_name); + return type_table[i].type_name; } static char * -prec_name (prec) - short prec; +prec_name (short prec) { int i; for (i = 0; prec_table[i].prec != (short) -1; i++) if (prec_table[i].prec == prec) break; - return (prec_table[i].prec_name); + return prec_table[i].prec_name; } diff --git a/lib/buildcmd.c b/lib/buildcmd.c index f05167e7..785c093a 100644 --- a/lib/buildcmd.c +++ b/lib/buildcmd.c @@ -71,8 +71,6 @@ #include "buildcmd.h" -extern char **environ; - static const char *special_terminating_arg = "do_not_care"; diff --git a/lib/buildcmd.h b/lib/buildcmd.h index 923e2f78..860a7471 100644 --- a/lib/buildcmd.h +++ b/lib/buildcmd.h @@ -25,13 +25,13 @@ struct buildcmd_state { /* Number of valid elements in `cmd_argv', including terminating NULL. */ - int cmd_argc; /* 0 */ + size_t cmd_argc; /* 0 */ /* The list of args being built. */ char **cmd_argv; /* NULL */ /* Number of elements allocated for `cmd_argv'. */ - int cmd_argv_alloc; + size_t cmd_argv_alloc; /* Storage for elements of `cmd_argv'. */ char *argbuf; @@ -52,8 +52,8 @@ struct buildcmd_state int dir_fd; /* Summary of what we think the argv limits are. */ - int largest_successful_arg_count; - int smallest_failed_arg_count; + size_t largest_successful_arg_count; + size_t smallest_failed_arg_count; }; struct buildcmd_control @@ -77,7 +77,7 @@ struct buildcmd_control * function returns a useful value even if ARG_MAX is not defined. * However, sometimes, max_arg_count is LONG_MAX! */ - long max_arg_count; + size_t max_arg_count; /* The length of `replace_pat'. */ @@ -90,17 +90,17 @@ struct buildcmd_control char *replace_pat; /* Number of initial arguments given on the command line. */ - int initial_argc; /* 0 */ + size_t initial_argc; /* 0 */ /* exec callback. */ int (*exec_callback)(struct buildcmd_control *, void *usercontext, int argc, char **argv); /* If nonzero, the maximum number of nonblank lines from stdin to use per command line. */ - long lines_per_exec; /* 0 */ + size_t lines_per_exec; /* 0 */ /* The maximum number of arguments to use per command line. */ - long args_per_exec; + size_t args_per_exec; }; enum BC_INIT_STATUS |