]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Arithmetic with void * pointers is a bad idea
authorTim Kientzle <kientzle@acm.org>
Mon, 25 Apr 2016 01:45:58 +0000 (18:45 -0700)
committerTim Kientzle <kientzle@acm.org>
Mon, 25 Apr 2016 01:45:58 +0000 (18:45 -0700)
libarchive/test/test_sparse_basic.c

index e5dd2f73010c947c27a87f6c9ac2094176b31ed9..3cea4595c95fd7980f1cce90e05abe49deaba4c8 100644 (file)
@@ -301,7 +301,7 @@ verify_sparse_file(struct archive *a, const char *path,
                /* Block that overlaps beginning of data */
                if (expected_offset < offset
                    && expected_offset + (int64_t)sparse->size <= offset + (int64_t)bytes_read) {
-                       const char *end = buff + (expected_offset - offset) + (size_t)sparse->size;
+                       const char *end = (const char *)buff + (expected_offset - offset) + (size_t)sparse->size;
 #if DEBUG
                        fprintf(stderr, "    overlapping hole expected_offset=%d, size=%d\n", (int)expected_offset, (int)sparse->size);
 #endif
@@ -315,7 +315,7 @@ verify_sparse_file(struct archive *a, const char *path,
                }
                /* Blocks completely contained in data we just read. */
                while (expected_offset + (int64_t)sparse->size <= offset + (int64_t)bytes_read) {
-                       const char *end = buff + (expected_offset - offset) + (size_t)sparse->size;
+                       const char *end = (const char *)buff + (expected_offset - offset) + (size_t)sparse->size;
                        if (sparse->type == HOLE) {
 #if DEBUG
                                fprintf(stderr, "    contained hole expected_offset=%d, size=%d\n", (int)expected_offset, (int)sparse->size);
@@ -323,7 +323,7 @@ verify_sparse_file(struct archive *a, const char *path,
 
                                /* verify data corresponding to hole is '\0' */
                                if (end > (const char *)buff + bytes_read) {
-                                       end = buff + bytes_read;
+                                       end = (const char *)buff + bytes_read;
                                }
                                assertMemoryFilledWith(start, end - start, '\0');
                                start = end;
@@ -335,7 +335,7 @@ verify_sparse_file(struct archive *a, const char *path,
 #endif
                                /* verify data corresponding to hole is ' ' */
                                if (assert(expected_offset + sparse->size <= offset + bytes_read)) {
-                                       assert(start == buff + (size_t)(expected_offset - offset));
+                                       assert(start == (const char *)buff + (size_t)(expected_offset - offset));
                                        assertMemoryFilledWith(start, end - start, ' ');
                                }
                                start = end;
@@ -347,7 +347,7 @@ verify_sparse_file(struct archive *a, const char *path,
                }
                /* Block that overlaps end of data */
                if (expected_offset < offset + (int64_t)bytes_read) {
-                       const char *end = buff + bytes_read;
+                       const char *end = (const char *)buff + bytes_read;
 #if DEBUG
                        fprintf(stderr, "    trailing overlap expected_offset=%d, size=%d\n", (int)expected_offset, (int)sparse->size);
 #endif