diff options
Diffstat (limited to 'xdelta3')
-rw-r--r-- | xdelta3/Makefile.am | 2 | ||||
-rw-r--r-- | xdelta3/xdelta3-blkcache.h | 4 | ||||
-rw-r--r-- | xdelta3/xdelta3-decode.h | 4 | ||||
-rw-r--r-- | xdelta3/xdelta3-fgk.h | 6 | ||||
-rw-r--r-- | xdelta3/xdelta3-hash.h | 13 | ||||
-rw-r--r-- | xdelta3/xdelta3-list.h | 4 | ||||
-rw-r--r-- | xdelta3/xdelta3-second.h | 4 | ||||
-rw-r--r-- | xdelta3/xdelta3.c | 35 | ||||
-rw-r--r-- | xdelta3/xdelta3.h | 19 |
9 files changed, 47 insertions, 44 deletions
diff --git a/xdelta3/Makefile.am b/xdelta3/Makefile.am index 8283663..dd2f2d5 100644 --- a/xdelta3/Makefile.am +++ b/xdelta3/Makefile.am | |||
@@ -35,6 +35,8 @@ xdelta3regtest_SOURCES = $(common_SOURCES) \ | |||
35 | testing/sizes.h \ | 35 | testing/sizes.h \ |
36 | testing/test.h | 36 | testing/test.h |
37 | 37 | ||
38 | # Note: for extra sanity checks, enable -Wconversion. Note there | ||
39 | # are a lot of false positives. | ||
38 | WFLAGS = -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare \ | 40 | WFLAGS = -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare \ |
39 | -Wextra -Wno-unused-parameter | 41 | -Wextra -Wno-unused-parameter |
40 | 42 | ||
diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h index 27263ed..f9f3d8a 100644 --- a/xdelta3/xdelta3-blkcache.h +++ b/xdelta3/xdelta3-blkcache.h | |||
@@ -303,7 +303,7 @@ main_getblk_lru (xd3_source *source, xoff_t blkno, | |||
303 | lru_filled += 1; | 303 | lru_filled += 1; |
304 | (*is_new) = 1; | 304 | (*is_new) = 1; |
305 | (*blrup) = blru; | 305 | (*blrup) = blru; |
306 | blru->blkno = -1; | 306 | blru->blkno = (xoff_t) -1; |
307 | return 0; | 307 | return 0; |
308 | } | 308 | } |
309 | 309 | ||
@@ -384,7 +384,7 @@ main_read_seek_source (xd3_stream *stream, | |||
384 | while (sfile->source_position < pos) | 384 | while (sfile->source_position < pos) |
385 | { | 385 | { |
386 | xoff_t skip_blkno; | 386 | xoff_t skip_blkno; |
387 | usize_t skip_offset; | 387 | xoff_t skip_offset; |
388 | 388 | ||
389 | xd3_blksize_div (sfile->source_position, source, | 389 | xd3_blksize_div (sfile->source_position, source, |
390 | &skip_blkno, &skip_offset); | 390 | &skip_blkno, &skip_offset); |
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h index d468669..24665df 100644 --- a/xdelta3/xdelta3-decode.h +++ b/xdelta3/xdelta3-decode.h | |||
@@ -428,7 +428,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
428 | * copy. */ | 428 | * copy. */ |
429 | xd3_source *source = stream->src; | 429 | xd3_source *source = stream->src; |
430 | xoff_t block = source->cpyoff_blocks; | 430 | xoff_t block = source->cpyoff_blocks; |
431 | usize_t blkoff = source->cpyoff_blkoff; | 431 | xoff_t blkoff = source->cpyoff_blkoff; |
432 | const xoff_t blksize = source->blksize; | 432 | const xoff_t blksize = source->blksize; |
433 | int ret; | 433 | int ret; |
434 | 434 | ||
@@ -475,7 +475,7 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
475 | } | 475 | } |
476 | else | 476 | else |
477 | { | 477 | { |
478 | take = blksize - blkoff; | 478 | take = (usize_t) (blksize - blkoff); |
479 | inst->size -= take; | 479 | inst->size -= take; |
480 | inst->addr += take; | 480 | inst->addr += take; |
481 | 481 | ||
diff --git a/xdelta3/xdelta3-fgk.h b/xdelta3/xdelta3-fgk.h index f145cc9..b85e2c2 100644 --- a/xdelta3/xdelta3-fgk.h +++ b/xdelta3/xdelta3-fgk.h | |||
@@ -191,7 +191,7 @@ static fgk_stream* fgk_alloc (xd3_stream *stream /*, int alphabet_size0 */) | |||
191 | static int fgk_init (xd3_stream *stream, fgk_stream *h, int is_encode) | 191 | static int fgk_init (xd3_stream *stream, fgk_stream *h, int is_encode) |
192 | { | 192 | { |
193 | usize_t ui; | 193 | usize_t ui; |
194 | size_t si; | 194 | int si; |
195 | 195 | ||
196 | h->root_node = h->alphabet; | 196 | h->root_node = h->alphabet; |
197 | h->decode_ptr = h->root_node; | 197 | h->decode_ptr = h->root_node; |
@@ -217,7 +217,7 @@ static int fgk_init (xd3_stream *stream, fgk_stream *h, int is_encode) | |||
217 | /* Zero frequency nodes are inserted in the first alphabet_size | 217 | /* Zero frequency nodes are inserted in the first alphabet_size |
218 | * positions, with Value, weight, and a pointer to the next zero | 218 | * positions, with Value, weight, and a pointer to the next zero |
219 | * frequency node. */ | 219 | * frequency node. */ |
220 | for (si = h->alphabet_size - 1; si >= 0; si -= 1) | 220 | for (si = (int)(h->alphabet_size - 1U); si >= 0; si -= 1) |
221 | { | 221 | { |
222 | fgk_init_node (h->alphabet + si, (usize_t) si, h->alphabet_size); | 222 | fgk_init_node (h->alphabet + si, (usize_t) si, h->alphabet_size); |
223 | } | 223 | } |
@@ -655,7 +655,7 @@ static void fgk_factor_remaining (fgk_stream *h) | |||
655 | i >>= 1; | 655 | i >>= 1; |
656 | } | 656 | } |
657 | 657 | ||
658 | i = 1 << h->zero_freq_exp; | 658 | i = 1U << h->zero_freq_exp; |
659 | 659 | ||
660 | h->zero_freq_rem = h->zero_freq_count - i; | 660 | h->zero_freq_rem = h->zero_freq_count - i; |
661 | } | 661 | } |
diff --git a/xdelta3/xdelta3-hash.h b/xdelta3/xdelta3-hash.h index e359436..cd579af 100644 --- a/xdelta3/xdelta3-hash.h +++ b/xdelta3/xdelta3-hash.h | |||
@@ -134,10 +134,10 @@ xd3_lcksum (const uint8_t *seg, const usize_t ln) | |||
134 | 134 | ||
135 | #if XD3_ENCODER | 135 | #if XD3_ENCODER |
136 | static usize_t | 136 | static usize_t |
137 | xd3_size_log2 (usize_t slots) | 137 | xd3_size_log2 (size_t slots) |
138 | { | 138 | { |
139 | int bits = 28; /* This should not be an unreasonable limit. */ | 139 | usize_t bits = 31; |
140 | int i; | 140 | usize_t i; |
141 | 141 | ||
142 | for (i = 3; i <= bits; i += 1) | 142 | for (i = 3; i <= bits; i += 1) |
143 | { | 143 | { |
@@ -155,13 +155,12 @@ xd3_size_log2 (usize_t slots) | |||
155 | 155 | ||
156 | static void | 156 | static void |
157 | xd3_size_hashtable (xd3_stream *stream, | 157 | xd3_size_hashtable (xd3_stream *stream, |
158 | usize_t slots, | 158 | size_t slots, |
159 | xd3_hash_cfg *cfg) | 159 | xd3_hash_cfg *cfg) |
160 | { | 160 | { |
161 | int bits = xd3_size_log2 (slots); | 161 | usize_t bits = xd3_size_log2 (slots); |
162 | 162 | ||
163 | /* TODO: there's a 32-bit assumption here */ | 163 | cfg->size = (1U << bits); |
164 | cfg->size = (1 << bits); | ||
165 | cfg->mask = (cfg->size - 1); | 164 | cfg->mask = (cfg->size - 1); |
166 | cfg->shift = 32 - bits; | 165 | cfg->shift = 32 - bits; |
167 | } | 166 | } |
diff --git a/xdelta3/xdelta3-list.h b/xdelta3/xdelta3-list.h index 6e3125f..9b3bc2b 100644 --- a/xdelta3/xdelta3-list.h +++ b/xdelta3/xdelta3-list.h | |||
@@ -111,11 +111,11 @@ LTYPE ## _next (ETYPE *f) \ | |||
111 | return LTYPE ## _entry (f->LNAME.next); \ | 111 | return LTYPE ## _entry (f->LNAME.next); \ |
112 | } \ | 112 | } \ |
113 | \ | 113 | \ |
114 | static inline usize_t \ | 114 | static inline size_t \ |
115 | LTYPE ## _length (LTYPE *l) \ | 115 | LTYPE ## _length (LTYPE *l) \ |
116 | { \ | 116 | { \ |
117 | LTYPE *p; \ | 117 | LTYPE *p; \ |
118 | int c = 0; \ | 118 | size_t c = 0; \ |
119 | \ | 119 | \ |
120 | for (p = l->next; p != l; p = p->next) \ | 120 | for (p = l->next; p != l; p = p->next) \ |
121 | { \ | 121 | { \ |
diff --git a/xdelta3/xdelta3-second.h b/xdelta3/xdelta3-second.h index b9830ab..5fc93ed 100644 --- a/xdelta3/xdelta3-second.h +++ b/xdelta3/xdelta3-second.h | |||
@@ -33,7 +33,7 @@ static inline int xd3_decode_bits (xd3_stream *stream, | |||
33 | usize_t *valuep) | 33 | usize_t *valuep) |
34 | { | 34 | { |
35 | usize_t value = 0; | 35 | usize_t value = 0; |
36 | usize_t vmask = 1 << nbits; | 36 | usize_t vmask = 1U << nbits; |
37 | 37 | ||
38 | if (bits->cur_mask == 0x100) { goto next_byte; } | 38 | if (bits->cur_mask == 0x100) { goto next_byte; } |
39 | 39 | ||
@@ -215,7 +215,7 @@ static inline int xd3_encode_bits (xd3_stream *stream, | |||
215 | usize_t value) | 215 | usize_t value) |
216 | { | 216 | { |
217 | int ret; | 217 | int ret; |
218 | usize_t mask = 1 << nbits; | 218 | usize_t mask = 1U << nbits; |
219 | 219 | ||
220 | XD3_ASSERT (nbits > 0); | 220 | XD3_ASSERT (nbits > 0); |
221 | XD3_ASSERT (nbits < sizeof (usize_t) * 8); | 221 | XD3_ASSERT (nbits < sizeof (usize_t) * 8); |
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 2d6f926..319d8c1 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -533,7 +533,7 @@ static int xd3_srcwin_move_point (xd3_stream *stream, | |||
533 | static int xd3_emit_run (xd3_stream *stream, usize_t pos, | 533 | static int xd3_emit_run (xd3_stream *stream, usize_t pos, |
534 | usize_t size, uint8_t *run_c); | 534 | usize_t size, uint8_t *run_c); |
535 | static usize_t xd3_checksum_hash (const xd3_hash_cfg *cfg, | 535 | static usize_t xd3_checksum_hash (const xd3_hash_cfg *cfg, |
536 | const usize_t cksum); | 536 | const usize_t cksum); |
537 | static xoff_t xd3_source_cksum_offset(xd3_stream *stream, usize_t low); | 537 | static xoff_t xd3_source_cksum_offset(xd3_stream *stream, usize_t low); |
538 | static void xd3_scksum_insert (xd3_stream *stream, | 538 | static void xd3_scksum_insert (xd3_stream *stream, |
539 | usize_t inx, | 539 | usize_t inx, |
@@ -999,7 +999,7 @@ static void | |||
999 | xd3_build_code_table (const xd3_code_table_desc *desc, xd3_dinst *tbl) | 999 | xd3_build_code_table (const xd3_code_table_desc *desc, xd3_dinst *tbl) |
1000 | { | 1000 | { |
1001 | usize_t size1, size2, mode; | 1001 | usize_t size1, size2, mode; |
1002 | usize_t cpy_modes = 2 + desc->near_modes + desc->same_modes; | 1002 | usize_t cpy_modes = 2U + desc->near_modes + desc->same_modes; |
1003 | xd3_dinst *d = tbl; | 1003 | xd3_dinst *d = tbl; |
1004 | 1004 | ||
1005 | (d++)->type1 = XD3_RUN; | 1005 | (d++)->type1 = XD3_RUN; |
@@ -1015,7 +1015,8 @@ xd3_build_code_table (const xd3_code_table_desc *desc, xd3_dinst *tbl) | |||
1015 | { | 1015 | { |
1016 | (d++)->type1 = XD3_CPY + mode; | 1016 | (d++)->type1 = XD3_CPY + mode; |
1017 | 1017 | ||
1018 | for (size1 = MIN_MATCH; size1 < MIN_MATCH + desc->cpy_sizes; size1 += 1, d += 1) | 1018 | for (size1 = MIN_MATCH; size1 < MIN_MATCH + desc->cpy_sizes; |
1019 | size1 += 1, d += 1) | ||
1019 | { | 1020 | { |
1020 | d->type1 = XD3_CPY + mode; | 1021 | d->type1 = XD3_CPY + mode; |
1021 | d->size1 = size1; | 1022 | d->size1 = size1; |
@@ -1593,17 +1594,16 @@ xd3_round_blksize (usize_t sz, usize_t blksz) | |||
1593 | #define A32_DO8(buf,i) A32_DO4(buf,i); A32_DO4(buf,i+4); | 1594 | #define A32_DO8(buf,i) A32_DO4(buf,i); A32_DO4(buf,i+4); |
1594 | #define A32_DO16(buf) A32_DO8(buf,0); A32_DO8(buf,8); | 1595 | #define A32_DO16(buf) A32_DO8(buf,0); A32_DO8(buf,8); |
1595 | 1596 | ||
1596 | static unsigned long adler32 (unsigned long adler, const uint8_t *buf, | 1597 | static uint32_t adler32 (uint32_t adler, const uint8_t *buf, size_t len) |
1597 | usize_t len) | ||
1598 | { | 1598 | { |
1599 | unsigned long s1 = adler & 0xffff; | 1599 | uint32_t s1 = adler & 0xffff; |
1600 | unsigned long s2 = (adler >> 16) & 0xffff; | 1600 | uint32_t s2 = (adler >> 16) & 0xffff; |
1601 | int k; | 1601 | int k; |
1602 | 1602 | ||
1603 | while (len > 0) | 1603 | while (len > 0) |
1604 | { | 1604 | { |
1605 | k = (len < A32_NMAX) ? len : A32_NMAX; | 1605 | k = (len < A32_NMAX) ? (int) len : A32_NMAX; |
1606 | len -= k; | 1606 | len -= (size_t) k; |
1607 | 1607 | ||
1608 | while (k >= 16) | 1608 | while (k >= 16) |
1609 | { | 1609 | { |
@@ -2669,7 +2669,7 @@ xd3_set_source (xd3_stream *stream, | |||
2669 | } | 2669 | } |
2670 | 2670 | ||
2671 | src->shiftby = shiftby; | 2671 | src->shiftby = shiftby; |
2672 | src->maskby = (1 << shiftby) - 1; | 2672 | src->maskby = (1U << shiftby) - 1; |
2673 | 2673 | ||
2674 | if (xd3_check_pow2 (src->max_winsize, NULL) != 0) | 2674 | if (xd3_check_pow2 (src->max_winsize, NULL) != 0) |
2675 | { | 2675 | { |
@@ -3697,7 +3697,7 @@ xd3_encode_init (xd3_stream *stream, int full_init) | |||
3697 | if (large_comp) | 3697 | if (large_comp) |
3698 | { | 3698 | { |
3699 | usize_t hash_values = (stream->src->max_winsize / | 3699 | usize_t hash_values = (stream->src->max_winsize / |
3700 | stream->smatcher.large_step); | 3700 | stream->smatcher.large_step); |
3701 | 3701 | ||
3702 | xd3_size_hashtable (stream, | 3702 | xd3_size_hashtable (stream, |
3703 | hash_values, | 3703 | hash_values, |
@@ -4565,7 +4565,8 @@ xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, int n) | |||
4565 | { | 4565 | { |
4566 | int i = 0; | 4566 | int i = 0; |
4567 | #if UNALIGNED_OK | 4567 | #if UNALIGNED_OK |
4568 | int nint = n / sizeof(int); | 4568 | const int isize = sizeof(int); |
4569 | int nint = n / isize; | ||
4569 | 4570 | ||
4570 | if (nint >> 3) | 4571 | if (nint >> 3) |
4571 | { | 4572 | { |
@@ -4584,7 +4585,7 @@ xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, int n) | |||
4584 | s1[i++] == s2[j++] && | 4585 | s1[i++] == s2[j++] && |
4585 | s1[i++] == s2[j++]) { } | 4586 | s1[i++] == s2[j++]) { } |
4586 | 4587 | ||
4587 | i = (i - 1) * sizeof(int); | 4588 | i = (i - 1) * isize; |
4588 | } | 4589 | } |
4589 | #endif | 4590 | #endif |
4590 | 4591 | ||
@@ -5094,9 +5095,9 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5094 | { | 5095 | { |
5095 | xoff_t blkno; | 5096 | xoff_t blkno; |
5096 | xoff_t blkbaseoffset; | 5097 | xoff_t blkbaseoffset; |
5097 | usize_t blkrem; | 5098 | xoff_t blkrem; |
5098 | size_t oldpos; /* Using ssize_t because of a */ | 5099 | ssize_t oldpos; /* Using ssize_t because of a */ |
5099 | size_t blkpos; /* do { blkpos-- } | 5100 | ssize_t blkpos; /* do { blkpos-- } |
5100 | while (blkpos >= oldpos); */ | 5101 | while (blkpos >= oldpos); */ |
5101 | int ret; | 5102 | int ret; |
5102 | xd3_blksize_div (stream->srcwin_cksum_pos, | 5103 | xd3_blksize_div (stream->srcwin_cksum_pos, |
@@ -5126,7 +5127,7 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
5126 | 5127 | ||
5127 | blkpos = xd3_bytes_on_srcblk (stream->src, blkno); | 5128 | blkpos = xd3_bytes_on_srcblk (stream->src, blkno); |
5128 | 5129 | ||
5129 | if (blkpos < (size_t) stream->smatcher.large_look) | 5130 | if (blkpos < (ssize_t) stream->smatcher.large_look) |
5130 | { | 5131 | { |
5131 | stream->srcwin_cksum_pos = (blkno + 1) * stream->src->blksize; | 5132 | stream->srcwin_cksum_pos = (blkno + 1) * stream->src->blksize; |
5132 | IF_DEBUG1 (DP(RINT "[srcwin_move_point] continue (end-of-block)\n")); | 5133 | IF_DEBUG1 (DP(RINT "[srcwin_move_point] continue (end-of-block)\n")); |
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index ec971b9..661a7ed 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -126,6 +126,7 @@ | |||
126 | #include <windows.h> | 126 | #include <windows.h> |
127 | #ifdef _MSC_VER | 127 | #ifdef _MSC_VER |
128 | #define inline | 128 | #define inline |
129 | typedef signed long ssize_t; | ||
129 | #if _MSC_VER < 1600 | 130 | #if _MSC_VER < 1600 |
130 | typedef unsigned char uint8_t; | 131 | typedef unsigned char uint8_t; |
131 | typedef unsigned short uint16_t; | 132 | typedef unsigned short uint16_t; |
@@ -631,9 +632,9 @@ struct _xd3_smatcher | |||
631 | /* hash table size & power-of-two hash function. */ | 632 | /* hash table size & power-of-two hash function. */ |
632 | struct _xd3_hash_cfg | 633 | struct _xd3_hash_cfg |
633 | { | 634 | { |
634 | usize_t size; | 635 | usize_t size; |
635 | usize_t shift; | 636 | usize_t shift; |
636 | usize_t mask; | 637 | usize_t mask; |
637 | }; | 638 | }; |
638 | 639 | ||
639 | /* the sprev list */ | 640 | /* the sprev list */ |
@@ -733,13 +734,13 @@ struct _xd3_source | |||
733 | sets after getblk request */ | 734 | sets after getblk request */ |
734 | 735 | ||
735 | /* xd3 sets */ | 736 | /* xd3 sets */ |
736 | usize_t srclen; /* length of this source window */ | 737 | usize_t srclen; /* length of this source window */ |
737 | xoff_t srcbase; /* offset of this source window | 738 | xoff_t srcbase; /* offset of this source window |
738 | in the source itself */ | 739 | in the source itself */ |
739 | int shiftby; /* for power-of-two blocksizes */ | 740 | int shiftby; /* for power-of-two blocksizes */ |
740 | int maskby; /* for power-of-two blocksizes */ | 741 | usize_t maskby; /* for power-of-two blocksizes */ |
741 | xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ | 742 | xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ |
742 | usize_t cpyoff_blkoff; /* offset of copy window in | 743 | xoff_t cpyoff_blkoff; /* offset of copy window in |
743 | blocks, remainder */ | 744 | blocks, remainder */ |
744 | xoff_t getblkno; /* request block number: xd3 sets | 745 | xoff_t getblkno; /* request block number: xd3 sets |
745 | current getblk request */ | 746 | current getblk request */ |
@@ -752,7 +753,7 @@ struct _xd3_source | |||
752 | * source position to be read. | 753 | * source position to be read. |
753 | * Otherwise, equal to | 754 | * Otherwise, equal to |
754 | * max_blkno. */ | 755 | * max_blkno. */ |
755 | xoff_t onlastblk; /* Number of bytes on max_blkno */ | 756 | xoff_t onlastblk; /* Number of bytes on max_blkno */ |
756 | int eof_known; /* Set to true when the first | 757 | int eof_known; /* Set to true when the first |
757 | * partial block is read. */ | 758 | * partial block is read. */ |
758 | }; | 759 | }; |
@@ -1322,11 +1323,11 @@ void xd3_blksize_div (const xoff_t offset, | |||
1322 | 1323 | ||
1323 | static inline | 1324 | static inline |
1324 | void xd3_blksize_add (xoff_t *blkno, | 1325 | void xd3_blksize_add (xoff_t *blkno, |
1325 | usize_t *blkoff, | 1326 | xoff_t *blkoff, |
1326 | const xd3_source *source, | 1327 | const xd3_source *source, |
1327 | const usize_t add) | 1328 | const usize_t add) |
1328 | { | 1329 | { |
1329 | usize_t blkdiff; | 1330 | xoff_t blkdiff; |
1330 | 1331 | ||
1331 | /* Does not check for overflow, checked in xdelta3-decode.h. */ | 1332 | /* Does not check for overflow, checked in xdelta3-decode.h. */ |
1332 | *blkoff += add; | 1333 | *blkoff += add; |