From e6b16a22f53632e1a6a2e622e792818b193e77f5 Mon Sep 17 00:00:00 2001 From: "josh.macdonald" Date: Mon, 21 Jan 2013 06:22:47 +0000 Subject: fix main_getblk_lru for decode --- xdelta3/xdelta3-blkcache.h | 1 + xdelta3/xdelta3-main.h | 6 +++--- xdelta3/xdelta3-test.h | 4 ++-- xdelta3/xdelta3.c | 21 +++++++++++---------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h index f9f3d8a..bc8e27f 100644 --- a/xdelta3/xdelta3-blkcache.h +++ b/xdelta3/xdelta3-blkcache.h @@ -159,6 +159,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, source->blksize = option_srcwinsz; lru_size = 1; + lru[0].blkno = 0; if ((ret = main_getblk_func (stream, source, 0)) != 0) { diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 3ae24cd..b0bf370 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h @@ -2415,7 +2415,7 @@ main_secondary_decompress_check (main_file *file, { int ret; usize_t i; - usize_t try_read = min (input_size, XD3_ALLOCSIZE); + size_t try_read = min (input_size, XD3_ALLOCSIZE); size_t check_nread = 0; uint8_t check_buf[XD3_ALLOCSIZE]; /* TODO: stack limit */ const main_extcomp *decompressor = NULL; @@ -3227,8 +3227,8 @@ main_input (xd3_cmd cmd, main_get_appheader (& stream, ifile, ofile, sfile); /* Now open the source file. */ - if ((sfile->filename != NULL) && - (ret = main_set_source (& stream, cmd, sfile, & source))) + if ((sfile->filename != NULL) && + (ret = main_set_source (& stream, cmd, sfile, & source))) { return EXIT_FAILURE; } diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h index fe62a4b..a602a41 100644 --- a/xdelta3/xdelta3-test.h +++ b/xdelta3/xdelta3-test.h @@ -669,13 +669,13 @@ test_forward_match (xd3_stream *stream, int unused) for (i = 0; i < 256; i++) { - CHECK(xd3_forward_match(buf1, buf2, i) == (int)i); + CHECK(xd3_forward_match(buf1, buf2, i) == i); } for (i = 0; i < 255; i++) { buf2[i] = 1; - CHECK(xd3_forward_match(buf1, buf2, 256) == (int)i); + CHECK(xd3_forward_match(buf1, buf2, 256) == i); buf2[i] = 0; } diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 1703f94..f58dc99 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c @@ -4561,19 +4561,20 @@ xd3_source_match_setup (xd3_stream *stream, xoff_t srcpos) } static inline xoff_t -xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, xoff_t n) +xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, size_t n) { - int i = 0; -#if UNALIGNED_OK - const int isize = sizeof(int); - int nint = (int) (n / isize); + size_t i = 0; +#if UNALIGNED_OK + const size_t ssize = sizeof(size_t); + const size_t nint = n / ssize; + /* If there are at least 8 elements */ if (nint >> 3) { - int j = 0; - const int *s1 = (const int*)s1c; - const int *s2 = (const int*)s2c; - int nint_8 = nint - 8; + usize_t j = 0; + const size_t *s1 = (const size_t*)s1c; + const size_t *s2 = (const size_t*)s2c; + const size_t nint_8 = nint - 8; while (i <= nint_8 && s1[i++] == s2[j++] && @@ -4585,7 +4586,7 @@ xd3_forward_match(const uint8_t *s1c, const uint8_t *s2c, xoff_t n) s1[i++] == s2[j++] && s1[i++] == s2[j++]) { } - i = (i - 1) * isize; + i = (i - 1) * ssize; } #endif -- cgit v1.2.3