bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-tar] create.c warning from GCC with CVS tar


From: Paul Eggert
Subject: [Bug-tar] create.c warning from GCC with CVS tar
Date: Sun, 06 Nov 2005 21:15:58 -0800
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

I got this warning from GCC after doing a CVS merge into my private copy:

warning: passing argument 3 of 'xheader_store' discards qualifiers from pointer 
target type

Here's the source line:

              xheader_store ("GNU.dumpdir", st, gnu_list_name->dir_contents);

I installed this patch:

2005-11-06  Paul Eggert  <address@hidden>

        * src/xheader.c (struct xhdr_tab.coder): Last arg is void const *,
        not void *, to avoid create.c warning from GCC "passing argument 3
        of 'xheader_store' discards qualifiers from pointer target type".
        (dummy_coder, atime_coder, gid_coder, gname_coder, linkpath_coder):
        (ctime_coder, mtime_coder, path_coder, size_coder, uid_coder):
        (uname_coder, sparse_size_coder, sparse_numblocks_coder):
        (sparse_offset_coder, sparse_numbytes_coder, dumpdir_coder):
        (xheader_store): Likewise.
        * src/common.h (xheader_store): Likewise.

--- xheader.c   7 Nov 2005 02:52:58 -0000       1.32
+++ xheader.c   7 Nov 2005 05:11:40 -0000       1.34
@@ -424,7 +424,7 @@ struct xhdr_tab
 {
   char const *keyword;
   void (*coder) (struct tar_stat_info const *, char const *,
-                struct xheader *, void *data);
+                struct xheader *, void const *data);
   void (*decoder) (struct tar_stat_info *, char const *, size_t);
   bool protect;
 };
@@ -615,7 +615,8 @@ extended_header_init (void)
 }
 
 void
-xheader_store (char const *keyword, struct tar_stat_info const *st, void *data)
+xheader_store (char const *keyword, struct tar_stat_info const *st,
+              void const *data)
 {
   struct xhdr_tab const *t;
 
@@ -742,7 +743,7 @@ xheader_string_add (char const *s)
 
 void
 xheader_string_end (char const *keyword)
-{  
+{
   size_t len;
   size_t p;
   size_t n = 0;
@@ -753,9 +754,9 @@ xheader_string_end (char const *keyword)
   if (extended_header.buffer)
     return;
   extended_header_init ();
-  
+
   len = strlen (keyword) + string_length + 3; /* ' ' + '=' + '\n' */
-  
+
   do
     {
       p = n;
@@ -950,7 +951,7 @@ static void
 dummy_coder (struct tar_stat_info const *st __attribute__ ((unused)),
             char const *keyword __attribute__ ((unused)),
             struct xheader *xhdr __attribute__ ((unused)),
-            void *data __attribute__ ((unused)))
+            void const *data __attribute__ ((unused)))
 {
 }
 
@@ -963,7 +964,7 @@ dummy_decoder (struct tar_stat_info *st 
 
 static void
 atime_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_time (st->atime, keyword, xhdr);
 }
@@ -979,7 +980,7 @@ atime_decoder (struct tar_stat_info *st,
 
 static void
 gid_coder (struct tar_stat_info const *st, char const *keyword,
-          struct xheader *xhdr, void *data __attribute__ ((unused)))
+          struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_num (st->stat.st_gid, keyword, xhdr);
 }
@@ -995,7 +996,7 @@ gid_decoder (struct tar_stat_info *st, c
 
 static void
 gname_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->gname, keyword, xhdr);
 }
@@ -1009,7 +1010,7 @@ gname_decoder (struct tar_stat_info *st,
 
 static void
 linkpath_coder (struct tar_stat_info const *st, char const *keyword,
-               struct xheader *xhdr, void *data __attribute__ ((unused)))
+               struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->link_name, keyword, xhdr);
 }
@@ -1023,7 +1024,7 @@ linkpath_decoder (struct tar_stat_info *
 
 static void
 ctime_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_time (st->ctime, keyword, xhdr);
 }
@@ -1039,7 +1040,7 @@ ctime_decoder (struct tar_stat_info *st,
 
 static void
 mtime_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_time (st->mtime, keyword, xhdr);
 }
@@ -1055,7 +1056,7 @@ mtime_decoder (struct tar_stat_info *st,
 
 static void
 path_coder (struct tar_stat_info const *st, char const *keyword,
-           struct xheader *xhdr, void *data __attribute__ ((unused)))
+           struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->file_name, keyword, xhdr);
 }
@@ -1071,7 +1072,7 @@ path_decoder (struct tar_stat_info *st, 
 
 static void
 size_coder (struct tar_stat_info const *st, char const *keyword,
-           struct xheader *xhdr, void *data __attribute__ ((unused)))
+           struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_num (st->stat.st_size, keyword, xhdr);
 }
@@ -1087,7 +1088,7 @@ size_decoder (struct tar_stat_info *st, 
 
 static void
 uid_coder (struct tar_stat_info const *st, char const *keyword,
-          struct xheader *xhdr, void *data __attribute__ ((unused)))
+          struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_num (st->stat.st_uid, keyword, xhdr);
 }
@@ -1103,7 +1104,7 @@ uid_decoder (struct tar_stat_info *st, c
 
 static void
 uname_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data __attribute__ ((unused)))
+            struct xheader *xhdr, void const *data __attribute__ ((unused)))
 {
   code_string (st->uname, keyword, xhdr);
 }
@@ -1117,7 +1118,7 @@ uname_decoder (struct tar_stat_info *st,
 
 static void
 sparse_size_coder (struct tar_stat_info const *st, char const *keyword,
-            struct xheader *xhdr, void *data)
+            struct xheader *xhdr, void const *data)
 {
   size_coder (st, keyword, xhdr, data);
 }
@@ -1134,7 +1135,7 @@ sparse_size_decoder (struct tar_stat_inf
 static void
 sparse_numblocks_coder (struct tar_stat_info const *st, char const *keyword,
                        struct xheader *xhdr,
-                       void *data __attribute__ ((unused)))
+                       void const *data __attribute__ ((unused)))
 {
   code_num (st->sparse_map_avail, keyword, xhdr);
 }
@@ -1154,9 +1155,9 @@ sparse_numblocks_decoder (struct tar_sta
 
 static void
 sparse_offset_coder (struct tar_stat_info const *st, char const *keyword,
-                    struct xheader *xhdr, void *data)
+                    struct xheader *xhdr, void const *data)
 {
-  size_t *pi = data;
+  size_t const *pi = data;
   code_num (st->sparse_map[*pi].offset, keyword, xhdr);
 }
 
@@ -1177,9 +1178,9 @@ sparse_offset_decoder (struct tar_stat_i
 
 static void
 sparse_numbytes_coder (struct tar_stat_info const *st, char const *keyword,
-                      struct xheader *xhdr, void *data)
+                      struct xheader *xhdr, void const *data)
 {
-  size_t *pi = data;
+  size_t const *pi = data;
   code_num (st->sparse_map[*pi].numbytes, keyword, xhdr);
 }
 
@@ -1204,14 +1205,14 @@ sparse_map_decoder (struct tar_stat_info
 {
   int offset = 1;
   static char *keyword = "GNU.sparse.map";
-  
+
   st->sparse_map_avail = 0;
   while (1)
     {
       uintmax_t u;
       char *delim;
       struct sp_array e;
-      
+
       if (!ISDIGIT (*arg))
        {
          ERROR ((0, 0, _("Malformed extended header: invalid %s=%s"),
@@ -1247,7 +1248,7 @@ sparse_map_decoder (struct tar_stat_info
              return;
            }
        }
-           
+
       offset = !offset;
 
       if (*delim == 0)
@@ -1271,7 +1272,7 @@ sparse_map_decoder (struct tar_stat_info
 
 static void
 dumpdir_coder (struct tar_stat_info const *st, char const *keyword,
-              struct xheader *xhdr, void *data)
+              struct xheader *xhdr, void const *data)
 {
   xheader_print_n (xhdr, keyword, data, dumpdir_size (data));
 }
@@ -1316,7 +1317,7 @@ struct xhdr_tab const xhdr_tab[] = {
 
   { "GNU.dumpdir",           dumpdir_coder, dumpdir_decoder,
     true },
-  
+
 #if 0 /* GNU private keywords (not yet implemented) */
 
   /* Keeps the tape/volume header. May be present only in the global headers.
--- src/common.h.~1.63~ 2005-11-06 21:09:44.000000000 -0800
+++ src/common.h.~1.64.~        2005-11-06 21:10:24.000000000 -0800
@@ -611,7 +611,7 @@ void update_archive (void);
 
 void xheader_decode (struct tar_stat_info *);
 void xheader_decode_global (void);
-void xheader_store (char const *, struct tar_stat_info const *, void *);
+void xheader_store (char const *, struct tar_stat_info const *, void const *);
 void xheader_read (union block *, size_t);
 void xheader_write (char type, char *name, struct xheader *xhdr);
 void xheader_write_global (void);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]