]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fix build failure with -Wcast-qual GCC option since it happend on FreeBSD current.
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 8 Feb 2012 23:45:22 +0000 (08:45 +0900)
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>
Wed, 8 Feb 2012 23:45:22 +0000 (08:45 +0900)
libarchive/archive_match.c
libarchive/archive_read_support_format_7zip.c
libarchive/archive_write_set_format_7zip.c
libarchive/archive_write_set_format_xar.c
libarchive/test/test_archive_read_next_header_raw.c

index 32cdbc8ccc9fdebe91eccf1e37de477b510dc8df..c4dfd8b4786cd99ab970a26737df8c404cee05e7 100644 (file)
@@ -1099,8 +1099,8 @@ static int
 cmp_node_mbs(const struct archive_rb_node *n1,
     const struct archive_rb_node *n2)
 {
-       struct match_file *f1 = (struct match_file *)n1;
-       struct match_file *f2 = (struct match_file *)n2;
+       struct match_file *f1 = (struct match_file *)(uintptr_t)n1;
+       struct match_file *f2 = (struct match_file *)(uintptr_t)n2;
        const char *p1, *p2;
 
        archive_mstring_get_mbs(NULL, &(f1->pathname), &p1);
@@ -1115,7 +1115,7 @@ cmp_node_mbs(const struct archive_rb_node *n1,
 static int
 cmp_key_mbs(const struct archive_rb_node *n, const void *key)
 {
-       struct match_file *f = (struct match_file *)n;
+       struct match_file *f = (struct match_file *)(uintptr_t)n;
        const char *p;
 
        archive_mstring_get_mbs(NULL, &(f->pathname), &p);
@@ -1128,8 +1128,8 @@ static int
 cmp_node_wcs(const struct archive_rb_node *n1,
     const struct archive_rb_node *n2)
 {
-       struct match_file *f1 = (struct match_file *)n1;
-       struct match_file *f2 = (struct match_file *)n2;
+       struct match_file *f1 = (struct match_file *)(uintptr_t)n1;
+       struct match_file *f2 = (struct match_file *)(uintptr_t)n2;
        const wchar_t *p1, *p2;
 
        archive_mstring_get_wcs(NULL, &(f1->pathname), &p1);
@@ -1144,7 +1144,7 @@ cmp_node_wcs(const struct archive_rb_node *n1,
 static int
 cmp_key_wcs(const struct archive_rb_node *n, const void *key)
 {
-       struct match_file *f = (struct match_file *)n;
+       struct match_file *f = (struct match_file *)(uintptr_t)n;
        const wchar_t *p;
 
        archive_mstring_get_wcs(NULL, &(f->pathname), &p);
index 8f73ba9f40fe9e92ac513a853aa2fe179287926f..a17025a0d13c2891766fa925011e728a1f2b3a28 100644 (file)
@@ -481,7 +481,7 @@ check_7zip_header_in_sfx(const char *p)
                 * Magic Code, so we should do this in order not to
                 * make a mis-detection.
                 */
-               if (crc32(0, (unsigned char *)p + 12, 20)
+               if (crc32(0, (const unsigned char *)p + 12, 20)
                        != archive_le32dec(p + 8))
                        return (6); 
                /* Hit the header! */
@@ -2709,7 +2709,8 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip,
        }
 
        /* CRC check. */
-       if (crc32(0, (unsigned char *)p + 12, 20) != archive_le32dec(p + 8)) {
+       if (crc32(0, (const unsigned char *)p + 12, 20)
+           != archive_le32dec(p + 8)) {
                archive_set_error(&a->archive, -1, "Header CRC error");
                return (ARCHIVE_FATAL);
        }
index 6e08e2d155b814c7e127eb048c909e606a14dac5..f02af4a3f7928409cd5b57b2af266ae2bf8674bd 100644 (file)
@@ -512,7 +512,7 @@ static int
 write_to_temp(struct archive_write *a, const void *buff, size_t s)
 {
        struct _7zip *zip;
-       unsigned char *p;
+       const unsigned char *p;
        ssize_t ws;
 
        zip = (struct _7zip *)a->format_data;
@@ -530,7 +530,7 @@ write_to_temp(struct archive_write *a, const void *buff, size_t s)
                }
        }
 
-       p = (unsigned char *)buff;
+       p = (const unsigned char *)buff;
        while (s) {
                ws = write(zip->temp_fd, p, s);
                if (ws < 0) {
@@ -1451,8 +1451,8 @@ static int
 file_cmp_node(const struct archive_rb_node *n1,
     const struct archive_rb_node *n2)
 {
-       struct file *f1 = (struct file *)n1;
-       struct file *f2 = (struct file *)n2;
+       const struct file *f1 = (const struct file *)n1;
+       const struct file *f2 = (const struct file *)n2;
 
        if (f1->name_len == f2->name_len)
                return (memcmp(f1->utf16name, f2->utf16name, f1->name_len));
@@ -1462,7 +1462,7 @@ file_cmp_node(const struct archive_rb_node *n1,
 static int
 file_cmp_key(const struct archive_rb_node *n, const void *key)
 {
-       struct file *f = (struct file *)n;
+       const struct file *f = (const struct file *)n;
 
        return (f->name_len - *(const char *)key);
 }
index 31f67450801ba290981cbe3788322fa186e97fb9..15531f1a7fdc8d08391919018db98c86e585bce2 100644 (file)
@@ -97,6 +97,8 @@ archive_write_set_format_xar(struct archive *_a)
 
 /*#define DEBUG_PRINT_TOC              1 */
 
+#define BAD_CAST_CONST (const xmlChar *)
+
 #define HEADER_MAGIC   0x78617221
 #define HEADER_SIZE    28
 #define HEADER_VERSION 1
@@ -621,11 +623,11 @@ static int
 write_to_temp(struct archive_write *a, const void *buff, size_t s)
 {
        struct xar *xar;
-       unsigned char *p;
+       const unsigned char *p;
        ssize_t ws;
 
        xar = (struct xar *)a->format_data;
-       p = (unsigned char *)buff;
+       p = (const unsigned char *)buff;
        while (s) {
                ws = write(xar->temp_fd, p, s);
                if (ws < 0) {
@@ -756,7 +758,7 @@ xmlwrite_string_attr(struct archive_write *a, xmlTextWriterPtr writer,
 {
        int r;
 
-       r = xmlTextWriterStartElement(writer, BAD_CAST(key));
+       r = xmlTextWriterStartElement(writer, BAD_CAST_CONST(key));
        if (r < 0) {
                archive_set_error(&a->archive,
                    ARCHIVE_ERRNO_MISC,
@@ -765,7 +767,7 @@ xmlwrite_string_attr(struct archive_write *a, xmlTextWriterPtr writer,
        }
        if (attrkey != NULL && attrvalue != NULL) {
                r = xmlTextWriterWriteAttribute(writer,
-                   BAD_CAST(attrkey), BAD_CAST(attrvalue));
+                   BAD_CAST_CONST(attrkey), BAD_CAST_CONST(attrvalue));
                if (r < 0) {
                        archive_set_error(&a->archive,
                            ARCHIVE_ERRNO_MISC,
@@ -774,7 +776,7 @@ xmlwrite_string_attr(struct archive_write *a, xmlTextWriterPtr writer,
                }
        }
        if (value != NULL) {
-               r = xmlTextWriterWriteString(writer, BAD_CAST(value));
+               r = xmlTextWriterWriteString(writer, BAD_CAST_CONST(value));
                if (r < 0) {
                        archive_set_error(&a->archive,
                            ARCHIVE_ERRNO_MISC,
@@ -801,7 +803,7 @@ xmlwrite_string(struct archive_write *a, xmlTextWriterPtr writer,
        if (value == NULL)
                return (ARCHIVE_OK);
        
-       r = xmlTextWriterStartElement(writer, BAD_CAST(key));
+       r = xmlTextWriterStartElement(writer, BAD_CAST_CONST(key));
        if (r < 0) {
                archive_set_error(&a->archive,
                    ARCHIVE_ERRNO_MISC,
@@ -809,7 +811,7 @@ xmlwrite_string(struct archive_write *a, xmlTextWriterPtr writer,
                return (ARCHIVE_FATAL);
        }
        if (value != NULL) {
-               r = xmlTextWriterWriteString(writer, BAD_CAST(value));
+               r = xmlTextWriterWriteString(writer, BAD_CAST_CONST(value));
                if (r < 0) {
                        archive_set_error(&a->archive,
                            ARCHIVE_ERRNO_MISC,
@@ -1062,7 +1064,7 @@ make_fflags_entry(struct archive_write *a, xmlTextWriterPtr writer,
        } while (p != NULL);
 
        if (n > 0) {
-               r = xmlTextWriterStartElement(writer, BAD_CAST(element));
+               r = xmlTextWriterStartElement(writer, BAD_CAST_CONST(element));
                if (r < 0) {
                        archive_set_error(&a->archive,
                            ARCHIVE_ERRNO_MISC,
@@ -1557,7 +1559,7 @@ make_toc(struct archive_write *a)
                        goto exit_toc;
                }
                r = xmlTextWriterWriteAttribute(writer, BAD_CAST("style"),
-                   BAD_CAST(getalgname(xar->opt_toc_sumalg)));
+                   BAD_CAST_CONST(getalgname(xar->opt_toc_sumalg)));
                if (r < 0) {
                        archive_set_error(&a->archive,
                            ARCHIVE_ERRNO_MISC,
@@ -1865,8 +1867,8 @@ static int
 file_cmp_node(const struct archive_rb_node *n1,
     const struct archive_rb_node *n2)
 {
-       struct file *f1 = (struct file *)n1;
-       struct file *f2 = (struct file *)n2;
+       const struct file *f1 = (const struct file *)n1;
+       const struct file *f2 = (const struct file *)n2;
 
        return (strcmp(f1->basename.s, f2->basename.s));
 }
@@ -1874,7 +1876,7 @@ file_cmp_node(const struct archive_rb_node *n1,
 static int
 file_cmp_key(const struct archive_rb_node *n, const void *key)
 {
-       struct file *f = (struct file *)n;
+       const struct file *f = (const struct file *)n;
 
        return (strcmp(f->basename.s, (const char *)key));
 }
@@ -2466,8 +2468,8 @@ static int
 file_hd_cmp_node(const struct archive_rb_node *n1,
     const struct archive_rb_node *n2)
 {
-       struct hardlink *h1 = (struct hardlink *)n1;
-       struct hardlink *h2 = (struct hardlink *)n2;
+       const struct hardlink *h1 = (const struct hardlink *)n1;
+       const struct hardlink *h2 = (const struct hardlink *)n2;
 
        return (strcmp(archive_entry_pathname(h1->file_list.first->entry),
                       archive_entry_pathname(h2->file_list.first->entry)));
@@ -2476,7 +2478,7 @@ file_hd_cmp_node(const struct archive_rb_node *n1,
 static int
 file_hd_cmp_key(const struct archive_rb_node *n, const void *key)
 {
-       struct hardlink *h = (struct hardlink *)n;
+       const struct hardlink *h = (const struct hardlink *)n;
 
        return (strcmp(archive_entry_pathname(h->file_list.first->entry),
                       (const char *)key));
index 3c7ed871b95044dac0db72c408b887cd68b226e7..1c8af20f8c3ecb0fd35e4d919414901f46f043ed 100644 (file)
@@ -40,8 +40,8 @@ test(int skip_explicitely)
        assertEqualInt(0, archive_errno(a));
        assertEqualString(NULL, archive_error_string(a));
 
-       assertEqualInt(ARCHIVE_OK, archive_read_open_memory(a, (void*) data,
-           sizeof(data)));
+       assertEqualInt(ARCHIVE_OK, archive_read_open_memory(a,
+           (void *)(uintptr_t) data, sizeof(data)));
        assertEqualString(NULL, archive_error_string(a));
 
        assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &e));