]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
avoid warnings about discarding "qualifiers from pointer target type"
authorJim Meyering <meyering@redhat.com>
Tue, 28 Oct 2008 21:06:44 +0000 (22:06 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 10 Nov 2008 07:11:59 +0000 (08:11 +0100)
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):

15 files changed:
src/chown.c
src/chroot.c
src/date.c
src/du.c
src/expand.c
src/ls.c
src/md5sum.c
src/paste.c
src/pr.c
src/sort.c
src/split.c
src/system.h
src/tail.c
src/unexpand.c
src/yes.c

index e5740d259be6c22fb44f3836db323ee9be9bdeb1..972b281af249078cf3a666547b965cad76aba4bd 100644 (file)
@@ -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++;
     }
index 299acbcbf7e15928e96b59979c451d503170e174..1eb443c2461c0d6d299feeed7b7384bd1b150346 100644 (file)
@@ -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
index 3cfcc6265325883bcbe77bdbe799df99f3302853..e94de6013730e9662266bba905f61fcc3da86e44 100644 (file)
@@ -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;
index fafcea08ef4f604b0a66ff1b0fa565928d4701ae..2b0792b37cfc0411e72623a40913100b4777479c 100644 (file)
--- 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);
index 8efb81b3355ae0a1981ca52242d1bc3155038765..87c89152eff8dac4dcd3222da9f58cd1f0c00fc6 100644 (file)
@@ -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.  */
index d5bd8d1e0c26e01b48745cdffe56337fc7d216c6..460e161d13d6a258a0c5b588c8efe6d2a73ec275 100644 (file)
--- 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)
        {
index d31a780bfd93f9fde14e1e8c816f57820e7ae3f7..969cc71756225b816426200ba03f538e8f325ec3 100644 (file)
@@ -686,7 +686,7 @@ main (int argc, char **argv)
     binary = 0;
 
   if (optind == argc)
-    argv[argc++] = "-";
+    argv[argc++] = bad_cast ("-");
 
   for (; optind < argc; ++optind)
     {
index 9dee94aa459559b42ad551aa617d553780d3024d..f04bcc3b1efc3745e8f806d9d01f56e863d920c7 100644 (file)
@@ -496,7 +496,7 @@ main (int argc, char **argv)
     }
 
   if (optind == argc)
-    argv[argc++] = "-";
+    argv[argc++] = bad_cast ("-");
 
   if (collapse_escapes (delim_arg))
     {
index 0d8845fe6dbfc3b6efcdbf2c2a5e282ef7cb67ca..044bb5609a9ac9d9f1d853dde0f7d3ab75e86b27 100644 (file)
--- 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)
index 43c28fc84df2509ebd5ea2b43be9cf9ca7cae36c..fe58908b92000985ba4c3854e6c3d30206659f8a 100644 (file)
@@ -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;
index be182eff653e2c57cedb66d6e098fc14d0a8c269..1d8a94ca759a85e11a2c55cd526bfc35ed746a77 100644 (file)
@@ -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)
     {
index 8577d44642fb74e0dd3c3fdd20b4f8cf58a61a85..ee0d25cd902923e60702ffe71c7dc1d5c83f73d2 100644 (file)
@@ -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;
+}
index 6ad6d4330d7f1d264ac47d4aa6bacb9189f96fa0..fe346005456e9677f692e849da09f1e9b1b3dde4 100644 (file)
@@ -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;
 
index 5a2d0cdeb787d64521bc12502337b818ecf333a6..d73d101d4962604931bd74fbd34f584cf00f6de5 100644 (file)
@@ -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.  */
index e2a58445f0c701c5505d7db45b9b97fa669cdc7c..cfd06079f0969d3ff66ecf7031e82a270f82e5c2 100644 (file)
--- 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 (;;)