[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 07/10] build: avoid many const-related warnings
From: |
Jim Meyering |
Subject: |
[PATCH 07/10] build: avoid many const-related warnings |
Date: |
Fri, 20 Nov 2009 21:06:18 +0100 |
From: Jim Meyering <address@hidden>
* gzip.c: Add "const" to many variables, to avoid compiler warnings.
* util.c (add_envopt): Make 3rd parameter const
(gzip_error): Make sole parameter const.
* gzip.h: Update prototypes.
---
gzip.c | 24 ++++++++++++------------
gzip.h | 6 +++---
util.c | 14 ++++++--------
3 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/gzip.c b/gzip.c
index c1280d2..07bebc3 100644
--- a/gzip.c
+++ b/gzip.c
@@ -28,7 +28,7 @@
* See the file algorithm.doc for the compression algorithms and file formats.
*/
-static char *license_msg[] = {
+static char const *const license_msg[] = {
"Copyright (C) 2007 Free Software Foundation, Inc.",
"Copyright (C) 1993 Jean-loup Gailly.",
"This is free software. You may redistribute copies of it under the terms of",
@@ -203,7 +203,7 @@ struct timespec time_stamp; /* original time stamp
(modification time) */
off_t ifile_size; /* input file size, -1 for devices (debug only) */
char *env; /* contents of GZIP env variable */
char **args = NULL; /* argv pointer if GZIP env variable defined */
-char *z_suffix; /* default suffix (can be set with --suffix) */
+char const *z_suffix; /* default suffix (can be set with --suffix) */
size_t z_len; /* strlen(z_suffix) */
/* The set of signals that are caught. */
@@ -327,7 +327,7 @@ try_help ()
/* ======================================================================== */
local void help()
{
- static char *help_msg[] = {
+ static char const* const help_msg[] = {
"Compress or uncompress FILEs (by default, compress FILES in-place).",
"",
"Mandatory arguments to long options are mandatory for short options too.",
@@ -368,7 +368,7 @@ local void help()
"",
"Report bugs to <address@hidden>.",
0};
- char **p = help_msg;
+ char const *const *p = help_msg;
printf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
while (*p) printf ("%s\n", *p++);
@@ -377,7 +377,7 @@ local void help()
/* ======================================================================== */
local void license()
{
- char **p = license_msg;
+ char const *const *p = license_msg;
printf ("%s %s\n", program_name, VERSION);
while (*p) printf ("%s\n", *p++);
@@ -970,13 +970,13 @@ local char *get_suffix(name)
{
int nlen, slen;
char suffix[MAX_SUFFIX+3]; /* last chars of name, forced to lower case */
- static char *known_suffixes[] =
+ static char const *known_suffixes[] =
{NULL, ".gz", ".z", ".taz", ".tgz", "-gz", "-z", "_z",
#ifdef MAX_EXT_CHARS
"z",
#endif
NULL};
- char **suf = known_suffixes;
+ char const **suf = known_suffixes;
*suf = z_suffix;
if (strequ(z_suffix, "z")) suf++; /* check long suffixes first */
@@ -1061,9 +1061,9 @@ open_input_file (iname, sbuf)
{
int ilen; /* strlen(ifname) */
int z_suffix_errno = 0;
- static char *suffixes[] = {NULL, ".gz", ".z", "-z", ".Z", NULL};
- char **suf = suffixes;
- char *s;
+ static char const *suffixes[] = {NULL, ".gz", ".z", "-z", ".Z", NULL};
+ char const **suf = suffixes;
+ char const *s;
#ifdef NO_MULTIPLE_DOTS
char *dot; /* pointer to ifname extension, or NULL */
#endif
@@ -1107,7 +1107,7 @@ open_input_file (iname, sbuf)
/* Search for all suffixes */
do {
- char *s0 = s = *suf;
+ char const *s0 = s = *suf;
strcpy (ifname, iname);
#ifdef NO_MULTIPLE_DOTS
if (*s == '.') s++;
@@ -1448,7 +1448,7 @@ local void do_list(ifd, method)
{
ulg crc; /* original crc */
static int first_time = 1;
- static char* methods[MAX_METHODS] = {
+ static char const *const methods[MAX_METHODS] = {
"store", /* 0 */
"compr", /* 1 */
"pack ", /* 2 */
diff --git a/gzip.h b/gzip.h
index c4f890f..1ab89e6 100644
--- a/gzip.h
+++ b/gzip.h
@@ -329,10 +329,10 @@ extern char *strlwr OF((char *s));
extern char *gzip_base_name OF((char *fname));
extern int xunlink OF((char *fname));
extern void make_simple_name OF((char *name));
-extern char *add_envopt OF((int *argcp, char ***argvp, char *env));
-extern void gzip_error OF((char *m)) ATTRIBUTE_NORETURN;
+extern char *add_envopt OF((int *argcp, char ***argvp, char const *env));
+extern void gzip_error OF((char const *m)) ATTRIBUTE_NORETURN;
extern void xalloc_die OF((void)) ATTRIBUTE_NORETURN;
-extern void warning OF((char *m));
+extern void warning OF((char const *m));
extern void read_error OF((void));
extern void write_error OF((void));
extern void display_ratio OF((off_t num, off_t den, FILE *file));
diff --git a/util.c b/util.c
index 40b36fc..6bd0987 100644
--- a/util.c
+++ b/util.c
@@ -357,10 +357,10 @@ int strcspn(s, reject)
*/
#define SEPARATOR " \t" /* separators in env variable */
-char *add_envopt(argcp, argvp, env)
- int *argcp; /* pointer to argc */
- char ***argvp; /* pointer to argv */
- char *env; /* name of environment variable */
+char *add_envopt(
+ int *argcp, /* pointer to argc */
+ char ***argvp, /* pointer to argv */
+ char const *env) /* name of environment variable */
{
char *p; /* running pointer through env variable */
char **oargv; /* runs through old argv array */
@@ -414,8 +414,7 @@ char *add_envopt(argcp, argvp, env)
* Error handlers.
*/
void
-gzip_error (m)
- char *m;
+gzip_error (char const *m)
{
fprintf (stderr, "\n%s: %s: %s\n", program_name, ifname, m);
abort_gzip();
@@ -428,8 +427,7 @@ xalloc_die ()
abort_gzip ();
}
-void warning (m)
- char *m;
+void warning (char const *m)
{
WARN ((stderr, "%s: %s: warning: %s\n", program_name, ifname, m));
}
--
1.6.5.3.433.g11067
- [PATCH 01/10] build: "make stable" emitted an invalid gnupload command, Jim Meyering, 2009/11/20
- [PATCH 09/10] build: avoid warnings about unused macros, Jim Meyering, 2009/11/20
- [PATCH 02/10] maint: cfg.mk: remove factored-out ftp host/dir definitions, Jim Meyering, 2009/11/20
- [PATCH 08/10] build: util.c: avoid warnings about add_envopt, Jim Meyering, 2009/11/20
- [PATCH 05/10] build: use gnulib's fdopendir module, Jim Meyering, 2009/11/20
- [PATCH 03/10] maint: tweak formatting of bootstrap.conf, Jim Meyering, 2009/11/20
- [PATCH 04/10] build: enable many warnings, Jim Meyering, 2009/11/20
- [PATCH 06/10] build: avoid warnings from -Wstrict-prototypes, Jim Meyering, 2009/11/20
- [PATCH 07/10] build: avoid many const-related warnings,
Jim Meyering <=
- [PATCH 10/10] build: unlzw.c: avoid warnings about unused macros, Jim Meyering, 2009/11/20