diff options
author | James Youngman <jay@gnu.org> | 2011-06-14 23:44:57 +0100 |
---|---|---|
committer | James Youngman <jay@gnu.org> | 2011-06-14 23:44:57 +0100 |
commit | edb481e9d27e13fe68b28fe6a10a5a89fd72ae60 (patch) | |
tree | f0f5414f1dee4bbe73c1d9f82f828524c654ee51 | |
parent | f932373da8443e85dbe7bef125ceca0ba5976779 (diff) | |
download | findutils-edb481e9d27e13fe68b28fe6a10a5a89fd72ae60.tar.gz |
Fix further compiler warnings.
* find/ftsfind.c (show_outstanding_execdirs): Now that
execp->state.cmd_argc is a size_t, we can't print it with %d. So
print it with PRIuMAX (and include <inttypes.h> to define that).
* find/tree.c (prec_name): change return type to const char*.
(type_name): Likewise.
* find/exec.c (impl_pred_exec): use a separate variable (buf) to
point the memory allocated/freed with malloc/free, so that the
existing variable target can then be const (and so we can assign
pathname to it without a compiler warning).
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | find/exec.c | 9 | ||||
-rw-r--r-- | find/ftsfind.c | 3 | ||||
-rw-r--r-- | find/tree.c | 4 |
4 files changed, 21 insertions, 7 deletions
@@ -1,5 +1,16 @@ 2011-06-14 James Youngman <jay@gnu.org> + Fix further compiler warnings. + * find/ftsfind.c (show_outstanding_execdirs): Now that + execp->state.cmd_argc is a size_t, we can't print it with %d. So + print it with PRIuMAX (and include <inttypes.h> to define that). + * find/tree.c (prec_name): change return type to const char*. + (type_name): Likewise. + * find/exec.c (impl_pred_exec): use a separate variable (buf) to + point the memory allocated/freed with malloc/free, so that the + existing variable target can then be const (and so we can assign + pathname to it without a compiler warning). + Eliminate some compiler warnings. * find/find.c: Remove definition of SAFE_CHDIR, which we don't use. @@ -31,6 +42,7 @@ (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. diff --git a/find/exec.c b/find/exec.c index 95e3c6b9..989f207a 100644 --- a/find/exec.c +++ b/find/exec.c @@ -114,7 +114,8 @@ impl_pred_exec (const char *pathname, struct predicate *pred_ptr) { struct exec_val *execp = &pred_ptr->args.exec_vec; - char *target; + char *buf = NULL; + const char *target; bool result; const bool local = is_exec_in_local_dir (pred_ptr->pred_func); char *prefix; @@ -135,7 +136,7 @@ impl_pred_exec (const char *pathname, safely_quote_err_filename (0, pathname)); /*NOTREACHED*/ } - target = base_name (state.rel_pathname); + target = buf = base_name (state.rel_pathname); if ('/' == target[0]) { /* find / execdir ls -d {} \; */ @@ -210,10 +211,10 @@ impl_pred_exec (const char *pathname, result = false; } } - if (target != pathname) + if (buf) { assert (local); - free (target); + free (buf); } return result; } diff --git a/find/ftsfind.c b/find/ftsfind.c index 0d372f16..51d5749c 100644 --- a/find/ftsfind.c +++ b/find/ftsfind.c @@ -38,6 +38,7 @@ #include <errno.h> #include <assert.h> #include <locale.h> +#include <inttypes.h> #include <fcntl.h> #include <sys/stat.h> @@ -305,7 +306,7 @@ show_outstanding_execdirs (FILE *fp) fprintf (fp, "%s ", pfx); if (execp->multiple) fprintf (fp, "multiple "); - fprintf (fp, "%d args: ", execp->state.cmd_argc); + fprintf (fp, "%" PRIuMAX " args: ", (uintmax_t) execp->state.cmd_argc); for (i=0; i<execp->state.cmd_argc; ++i) { fprintf (fp, "%s ", execp->state.cmd_argv[i]); diff --git a/find/tree.c b/find/tree.c index 038bfc9a..0177aac5 100644 --- a/find/tree.c +++ b/find/tree.c @@ -1642,7 +1642,7 @@ cost_name (enum EvaluationCost cost) } -static char * +static const char * type_name (short type) { int i; @@ -1653,7 +1653,7 @@ type_name (short type) return type_table[i].type_name; } -static char * +static const char * prec_name (short prec) { int i; |