]> 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>
Thu, 9 Feb 2012 00:38:37 +0000 (09:38 +0900)
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 bc58013a45887c229d947525504b8a9993132a3c..c1bcd6ad8ca3e229154e4274ff4244b2a2ed0ee7 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! */
@@ -2694,7 +2694,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 8b07aaa0d6d8de17ee6d1d2e70d8b56dfcd9f331..9820f130032381af11d84f1816e0942cf1be1105 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 1a567f82af0858641e34116c3f8e9fd6c45ca4f1..d6e9bcb1e84254c400fdeba32891443f0b15af90 100644 (file)
@@ -101,6 +101,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
@@ -625,11 +627,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) {
@@ -760,7 +762,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,
@@ -769,7 +771,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,
@@ -778,7 +780,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,
@@ -805,7 +807,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,
@@ -813,7 +815,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,
@@ -1066,7 +1068,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,
@@ -1561,7 +1563,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,
@@ -1869,8 +1871,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));
 }
@@ -1878,7 +1880,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));
 }
@@ -2470,8 +2472,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)));
@@ -2480,7 +2482,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));