summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-10-28 22:06:44 +0100
committerJim Meyering <meyering@redhat.com>2008-11-10 08:11:59 +0100
commit854284f7887677395239c1085b27a09e834291b7 (patch)
treec719e6ee13b41342e70faa7bf6f8e3bc0acdbfd1
parent0e2ac2de24b2d64924826a693630d8d555beae3a (diff)
downloadcoreutils-854284f7887677395239c1085b27a09e834291b7.tar.xz
avoid warnings about discarding "qualifiers from pointer target type"
Use the new "bad_cast" function or an actual cast-to-"(char *)" to avoid warnings. * src/system.h (bad_cast): Define. * src/chown.c (main): * src/chroot.c (main): * src/date.c (main): * src/du.c (main): * src/expand.c (stdin_argv): * src/ls.c (decode_switches): * src/md5sum.c (main): * src/paste.c (main): * src/pr.c (col_sep_string, column_separator, line_separator, main): * src/sort.c (main): * src/split.c (main): * src/tail.c (main): * src/unexpand.c (stdin_argv): * src/yes.c (main):
-rw-r--r--src/chown.c2
-rw-r--r--src/chroot.c4
-rw-r--r--src/date.c2
-rw-r--r--src/du.c2
-rw-r--r--src/expand.c2
-rw-r--r--src/ls.c4
-rw-r--r--src/md5sum.c2
-rw-r--r--src/paste.c2
-rw-r--r--src/pr.c8
-rw-r--r--src/sort.c2
-rw-r--r--src/split.c4
-rw-r--r--src/system.h6
-rw-r--r--src/tail.c2
-rw-r--r--src/unexpand.c2
-rw-r--r--src/yes.c2
15 files changed, 26 insertions, 20 deletions
diff --git a/src/chown.c b/src/chown.c
index e5740d259..972b281af 100644
--- a/src/chown.c
+++ b/src/chown.c
@@ -312,7 +312,7 @@ main (int argc, char **argv)
empty string so that diagnostics say "ownership :GROUP"
rather than "group GROUP". */
if (!chopt.user_name && chopt.group_name)
- chopt.user_name = "";
+ chopt.user_name = bad_cast ("");
optind++;
}
diff --git a/src/chroot.c b/src/chroot.c
index 299acbcbf..1eb443c24 100644
--- a/src/chroot.c
+++ b/src/chroot.c
@@ -93,9 +93,9 @@ main (int argc, char **argv)
/* No command. Run an interactive shell. */
char *shell = getenv ("SHELL");
if (shell == NULL)
- shell = "/bin/sh";
+ shell = bad_cast ("/bin/sh");
argv[0] = shell;
- argv[1] = "-i";
+ argv[1] = bad_cast ("-i");
argv[2] = NULL;
}
else
diff --git a/src/date.c b/src/date.c
index 3cfcc6265..e94de6013 100644
--- a/src/date.c
+++ b/src/date.c
@@ -385,7 +385,7 @@ main (int argc, char **argv)
/* POSIX says that `date -u' is equivalent to setting the TZ
environment variable, so this option should do nothing other
than setting TZ. */
- if (putenv ("TZ=UTC0") != 0)
+ if (putenv (bad_cast ("TZ=UTC0")) != 0)
xalloc_die ();
TZSET;
break;
diff --git a/src/du.c b/src/du.c
index fafcea08e..2b0792b37 100644
--- a/src/du.c
+++ b/src/du.c
@@ -674,7 +674,7 @@ main (int argc, char **argv)
/* If true, display only a total for each argument. */
bool opt_summarize_only = false;
- cwd_only[0] = ".";
+ cwd_only[0] = bad_cast (".");
cwd_only[1] = NULL;
initialize_main (&argc, &argv);
diff --git a/src/expand.c b/src/expand.c
index 8efb81b33..87c89152e 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -76,7 +76,7 @@ static char **file_list;
/* Default for `file_list' if no files are given on the command line. */
static char *stdin_argv[] =
{
- "-", NULL
+ (char *) "-", NULL
};
/* True if we have ever read standard input. */
diff --git a/src/ls.c b/src/ls.c
index d5bd8d1e0..460e161d1 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1769,7 +1769,7 @@ decode_switches (int argc, char **argv)
case FULL_TIME_OPTION:
format = long_format;
- time_style_option = "full-iso";
+ time_style_option = bad_cast ("full-iso");
break;
case COLOR_OPTION:
@@ -1887,7 +1887,7 @@ decode_switches (int argc, char **argv)
if (! style)
if (! (style = getenv ("TIME_STYLE")))
- style = "locale";
+ style = bad_cast ("locale");
while (strncmp (style, posix_prefix, sizeof posix_prefix - 1) == 0)
{
diff --git a/src/md5sum.c b/src/md5sum.c
index d31a780bf..969cc7175 100644
--- a/src/md5sum.c
+++ b/src/md5sum.c
@@ -686,7 +686,7 @@ main (int argc, char **argv)
binary = 0;
if (optind == argc)
- argv[argc++] = "-";
+ argv[argc++] = bad_cast ("-");
for (; optind < argc; ++optind)
{
diff --git a/src/paste.c b/src/paste.c
index 9dee94aa4..f04bcc3b1 100644
--- a/src/paste.c
+++ b/src/paste.c
@@ -496,7 +496,7 @@ main (int argc, char **argv)
}
if (optind == argc)
- argv[argc++] = "-";
+ argv[argc++] = bad_cast ("-");
if (collapse_escapes (delim_arg))
{
diff --git a/src/pr.c b/src/pr.c
index 0d8845fe6..044bb5609 100644
--- a/src/pr.c
+++ b/src/pr.c
@@ -691,10 +691,10 @@ static bool use_col_separator = false;
/* String used to separate columns if the -S option has been specified.
Default without -S but together with one of the column options
-a|COLUMN|-m is a `space' and with the -J option a `tab'. */
-static char *col_sep_string = "";
+static char *col_sep_string = (char *) "";
static int col_sep_length = 0;
-static char *column_separator = " ";
-static char *line_separator = "\t";
+static char *column_separator = (char *) " ";
+static char *line_separator = (char *) "\t";
/* Number of separator characters waiting to be printed as soon as we
know that we have any input remaining to be printed. */
@@ -1030,7 +1030,7 @@ main (int argc, char **argv)
case 'S':
old_s = false;
/* Reset an additional input of -s, -S dominates -s */
- col_sep_string = "";
+ col_sep_string = bad_cast ("");
col_sep_length = 0;
use_col_separator = true;
if (optarg)
diff --git a/src/sort.c b/src/sort.c
index 43c28fc84..fe58908b9 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -3381,7 +3381,7 @@ main (int argc, char **argv)
if (nfiles == 0)
{
- static char *minus = "-";
+ static char *minus = (char *) "-";
nfiles = 1;
free (files);
files = &minus;
diff --git a/src/split.c b/src/split.c
index be182eff6..1d8a94ca7 100644
--- a/src/split.c
+++ b/src/split.c
@@ -401,8 +401,8 @@ main (int argc, char **argv)
/* Parse command line options. */
- infile = "-";
- outbase = "x";
+ infile = bad_cast ( "-");
+ outbase = bad_cast ("x");
while (1)
{
diff --git a/src/system.h b/src/system.h
index 8577d4464..ee0d25cd9 100644
--- a/src/system.h
+++ b/src/system.h
@@ -631,3 +631,9 @@ timetostr (time_t t, char *buf)
? imaxtostr (t, buf)
: umaxtostr (t, buf));
}
+
+static inline char *
+bad_cast (char const *s)
+{
+ return (char *) s;
+}
diff --git a/src/tail.c b/src/tail.c
index 6ad6d4330..fe3460054 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1629,7 +1629,7 @@ main (int argc, char **argv)
}
else
{
- static char *dummy_stdin = "-";
+ static char *dummy_stdin = (char *) "-";
n_files = 1;
file = &dummy_stdin;
diff --git a/src/unexpand.c b/src/unexpand.c
index 5a2d0cdeb..d73d101d4 100644
--- a/src/unexpand.c
+++ b/src/unexpand.c
@@ -80,7 +80,7 @@ static char **file_list;
/* Default for `file_list' if no files are given on the command line. */
static char *stdin_argv[] =
{
- "-", NULL
+ (char *) "-", NULL
};
/* True if we have ever read standard input. */
diff --git a/src/yes.c b/src/yes.c
index e2a58445f..cfd06079f 100644
--- a/src/yes.c
+++ b/src/yes.c
@@ -75,7 +75,7 @@ main (int argc, char **argv)
if (argc <= optind)
{
optind = argc;
- argv[argc++] = "y";
+ argv[argc++] = bad_cast ("y");
}
for (;;)