[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/3] Fix compile-time warnings.
From: |
Kamil Dudka |
Subject: |
[PATCH v2 3/3] Fix compile-time warnings. |
Date: |
Mon, 4 Feb 2013 14:28:02 +0100 |
* find/defs.h (struct predicate): Add a missing const modifier.
* find/find.c (wd_sanity_check): Suppress a warning in #else branch.
(process_dir): Remove an unused variables and statements.
* find/pred.c (pred_context): Use const modifier in the prototype.
* lib/buildcmd.{c,h} (bc_args_exceed_testing_limit): Remove a const
modifier causing unnecessary warnings.
* xargs/xargs.c (main): Add explicit type-casts.
---
ChangeLog | 9 +++++++++
find/defs.h | 2 +-
find/find.c | 14 +-------------
find/pred.c | 2 +-
lib/buildcmd.c | 7 +++++--
lib/buildcmd.h | 2 +-
xargs/xargs.c | 2 +-
7 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7781742..d96adc0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2013-02-03 Kamil Dudka <address@hidden>
+ Fix compile-time warnings.
+ * find/defs.h (struct predicate): Add a missing const modifier.
+ * find/find.c (wd_sanity_check): Suppress a warning in #else branch.
+ (process_dir): Remove an unused variables and statements.
+ * find/pred.c (pred_context): Use const modifier in the prototype.
+ * lib/buildcmd.{c,h} (bc_args_exceed_testing_limit): Remove a const
+ modifier causing unnecessary warnings.
+ * xargs/xargs.c (main): Add explicit type-casts.
+
Avoid using 'INCLUDES =' in automake templates.
* find/Makefile.am: Use AM_CPPFLAGS instead of deprecated INCLUDES.
* lib/Makefile.am: Likewise.
diff --git a/find/defs.h b/find/defs.h
index ca7d604..caccd2b 100644
--- a/find/defs.h
+++ b/find/defs.h
@@ -258,7 +258,7 @@ struct predicate
/* Only used for debugging, but defined unconditionally so individual
modules can be compiled with -DDEBUG. */
- char *p_name;
+ const char *p_name;
/* The type of this node. There are two kinds. The first is real
predicates ("primaries") such as -perm, -print, or -exec. The
diff --git a/find/find.c b/find/find.c
index 5d287b5..74b51d9 100644
--- a/find/find.c
+++ b/find/find.c
@@ -528,6 +528,7 @@ wd_sanity_check (const char *thing_to_stat,
#ifdef STAT_MOUNTPOINTS
isfatal = dirchange_is_fatal (specific_what,isfatal,silent,newinfo);
#else
+ (void) silent;
isfatal = RETRY_IF_SANITY_CHECK_FAILS;
#endif
}
@@ -1302,7 +1303,6 @@ process_dir (char *pathname, char *name, int pathlen,
const struct stat *statp,
{
int subdirs_left; /* Number of unexamined subdirs in PATHNAME. */
bool subdirs_unreliable; /* if true, cannot use dir link count as subdir
limif (if false, it may STILL be unreliable) */
- unsigned int idx; /* Which entry are we on? */
struct stat stat_buf;
size_t dircount = 0u;
DIR *dirp;
@@ -1519,7 +1519,6 @@ process_dir (char *pathname, char *name, int pathlen,
const struct stat *statp,
if (strcmp (name, "."))
{
enum SafeChdirStatus status;
- struct dir_id did;
/* We could go back and do the next command-line arg
instead, maybe using longjmp. */
@@ -1555,17 +1554,6 @@ process_dir (char *pathname, char *name, int pathlen,
const struct stat *statp,
"%s", safely_quote_err_filename (0, pathname));
return;
}
-
- if (dir_curr > 0)
- {
- did.dev = dir_ids[dir_curr-1].dev;
- did.ino = dir_ids[dir_curr-1].ino;
- }
- else
- {
- did.dev = starting_stat_buf.st_dev;
- did.ino = starting_stat_buf.st_ino;
- }
}
free (cur_path);
diff --git a/find/pred.c b/find/pred.c
index 88dacd9..e9c9a49 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -1216,7 +1216,7 @@ pred_context (const char *pathname, struct stat *stat_buf,
Return BUF. */
static char *
-blank_rtrim (char *str, char *buf)
+blank_rtrim (const char *str, char *buf)
{
int i;
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index eb46486..d135692 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -635,9 +635,12 @@ exceeds (const char *env_var_name, size_t quantity)
return 0;
}
-/* Return nonzero if the indicated argument list exceeds a testing limit. */
+/* Return nonzero if the indicated argument list exceeds a testing limit.
+ * NOTE: argv could be declared 'const char *const *argv', but it works as
+ * expected only with C++ compilers <http://c-faq.com/ansi/constmismatch.html>.
+ */
bool
-bc_args_exceed_testing_limit (const char **argv)
+bc_args_exceed_testing_limit (char **argv)
{
size_t chars, args;
diff --git a/lib/buildcmd.h b/lib/buildcmd.h
index dd8f3fc..f32aeec 100644
--- a/lib/buildcmd.h
+++ b/lib/buildcmd.h
@@ -138,7 +138,7 @@ extern size_t bc_get_arg_max(void);
extern void bc_use_sensible_arg_max(struct buildcmd_control *ctl);
extern void bc_clear_args(const struct buildcmd_control *ctl,
struct buildcmd_state *state);
-bool bc_args_exceed_testing_limit(const char **argv);
+bool bc_args_exceed_testing_limit(char **argv);
#endif
diff --git a/xargs/xargs.c b/xargs/xargs.c
index 5fd93cd..e98b0eb 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -554,7 +554,7 @@ main (int argc, char **argv)
error (0, 0,
_("warning: value %ld for -s option is too large, "
"using %ld instead"),
- arg_size, bc_ctl.posix_arg_size_max);
+ (long) arg_size, (long) bc_ctl.posix_arg_size_max);
arg_size = bc_ctl.posix_arg_size_max;
}
bc_ctl.arg_max = arg_size;
--
1.7.1