diff options
author | Josh MacDonald <josh.macdonald@gmail.com> | 2016-01-04 23:08:10 -0800 |
---|---|---|
committer | Josh MacDonald <josh.macdonald@gmail.com> | 2016-01-04 23:08:10 -0800 |
commit | f9f0e902b6f3a0f5eead5ac06aaf81eca3d25950 (patch) | |
tree | 294da7c4359c123a403a7e5e0b68fd19a82bd8da /xdelta3 | |
parent | 323299bb0189f64ada2aa16107699f9684138106 (diff) |
Build fixes w/ XD3_DEBUG=9 and Clang -Weverything
Diffstat (limited to 'xdelta3')
-rw-r--r-- | xdelta3/Makefile.am | 20 | ||||
-rwxr-xr-x | xdelta3/run_release.sh | 2 | ||||
-rw-r--r-- | xdelta3/testing/delta.h | 38 | ||||
-rw-r--r-- | xdelta3/testing/file.h | 30 | ||||
-rw-r--r-- | xdelta3/testing/regtest.cc | 37 | ||||
-rw-r--r-- | xdelta3/xdelta3-decode.h | 12 | ||||
-rw-r--r-- | xdelta3/xdelta3-internal.h | 9 | ||||
-rw-r--r-- | xdelta3/xdelta3-lzma.h | 10 | ||||
-rw-r--r-- | xdelta3/xdelta3-main.h | 6 | ||||
-rw-r--r-- | xdelta3/xdelta3-merge.h | 4 | ||||
-rw-r--r-- | xdelta3/xdelta3-test.h | 4 | ||||
-rw-r--r-- | xdelta3/xdelta3.c | 15 | ||||
-rw-r--r-- | xdelta3/xdelta3.h | 4 |
13 files changed, 102 insertions, 89 deletions
diff --git a/xdelta3/Makefile.am b/xdelta3/Makefile.am index f437764..056b200 100644 --- a/xdelta3/Makefile.am +++ b/xdelta3/Makefile.am | |||
@@ -45,12 +45,26 @@ xdelta3checksum_SOURCES = $(common_SOURCES) \ | |||
45 | # Note: for extra sanity checks, enable -Wconversion. Note there | 45 | # Note: for extra sanity checks, enable -Wconversion. Note there |
46 | # are a lot of false positives. | 46 | # are a lot of false positives. |
47 | WFLAGS = -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare \ | 47 | WFLAGS = -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare \ |
48 | -Wno-unused-parameter -Wformat -Wno-unused-function # -Wconversion | 48 | -Wformat=2 -Wno-format-nonliteral \ |
49 | -Wno-unused-parameter -Wno-unused-function | ||
50 | |||
51 | # -Weverything \ | ||
52 | # -Wc++11-compat-reserved-user-defined-literal \ | ||
53 | # -Wno-padded \ | ||
54 | # -Wno-format-nonliteral \ | ||
55 | # -Wno-cast-align \ | ||
56 | # -Wno-unused-parameter \ | ||
57 | # -Wno-sign-conversion \ | ||
58 | # -Wno-conversion \ | ||
59 | # -Wno-switch-enum \ | ||
60 | # -Wno-covered-switch-default \ | ||
61 | # -Wno-disabled-macro-expansion \ | ||
62 | # -Wno-variadic-macros \ | ||
63 | # -Wno-c++98-compat-pedantic | ||
49 | 64 | ||
50 | C_WFLAGS = $(WFLAGS) -pedantic -std=c99 | 65 | C_WFLAGS = $(WFLAGS) -pedantic -std=c99 |
51 | CXX_WFLAGS = $(WFLAGS) | 66 | CXX_WFLAGS = $(WFLAGS) -pedantic -std=c++11 |
52 | 67 | ||
53 | # TODO add -O3 | ||
54 | common_CFLAGS = \ | 68 | common_CFLAGS = \ |
55 | -DREGRESSION_TEST=1 \ | 69 | -DREGRESSION_TEST=1 \ |
56 | -DSECONDARY_DJW=1 \ | 70 | -DSECONDARY_DJW=1 \ |
diff --git a/xdelta3/run_release.sh b/xdelta3/run_release.sh index eb08afc..a6933b5 100755 --- a/xdelta3/run_release.sh +++ b/xdelta3/run_release.sh | |||
@@ -82,6 +82,8 @@ function buildlzma { | |||
82 | --host=${host} \ | 82 | --host=${host} \ |
83 | --prefix=${target} \ | 83 | --prefix=${target} \ |
84 | --disable-shared \ | 84 | --disable-shared \ |
85 | "CC=${CC}" \ | ||
86 | "CXX=${CXX}" \ | ||
85 | "CFLAGS=${march}" \ | 87 | "CFLAGS=${march}" \ |
86 | "CXXFLAGS=${march}" \ | 88 | "CXXFLAGS=${march}" \ |
87 | "LDFLAGS=${march}" | 89 | "LDFLAGS=${march}" |
diff --git a/xdelta3/testing/delta.h b/xdelta3/testing/delta.h index f874bf2..deac217 100644 --- a/xdelta3/testing/delta.h +++ b/xdelta3/testing/delta.h | |||
@@ -30,7 +30,7 @@ public: | |||
30 | case XD3_WINFINISH: | 30 | case XD3_WINFINISH: |
31 | break; | 31 | break; |
32 | default: | 32 | default: |
33 | DP(RINT "error code %s\n", xd3_strerror (ret)); | 33 | cerr << "decode: " << done; |
34 | abort(); | 34 | abort(); |
35 | } | 35 | } |
36 | } | 36 | } |
@@ -48,23 +48,25 @@ public: | |||
48 | return stream_.whole_target.wininfolen; | 48 | return stream_.whole_target.wininfolen; |
49 | } | 49 | } |
50 | 50 | ||
51 | void Print() const { | 51 | // Note: This does not benefit from -Wformat= checking, due to the |
52 | for (size_t i = 0; i < stream_.whole_target.instlen; i++) { | 52 | // enclosing template. Further, it was not used. |
53 | xd3_winst &winst = stream_.whole_target.inst[i]; | 53 | // void Print() const { |
54 | switch (winst.type) { | 54 | // for (size_t i = 0; i < stream_.whole_target.instlen; i++) { |
55 | case XD3_RUN: | 55 | // xd3_winst &winst = stream_.whole_target.inst[i]; |
56 | DP(RINT "%"Q" run %u\n", winst.position, winst.size); | 56 | // switch (winst.type) { |
57 | break; | 57 | // case XD3_RUN: |
58 | case XD3_ADD: | 58 | // DP(RINT, "%" Q "u run %" W "u\n", winst.position, winst.size); |
59 | DP(RINT "%"Q" add %u\n", winst.position, winst.size); | 59 | // break; |
60 | break; | 60 | // case XD3_ADD: |
61 | default: | 61 | // DP(RINT "%" Q "u add %" W "u\n", winst.position, winst.size); |
62 | DP(RINT "%"Q" copy %u @ %"Q" (mode %u)\n", | 62 | // break; |
63 | winst.position, winst.size, winst.addr, winst.mode); | 63 | // default: |
64 | break; | 64 | // DP(RINT "%" Q "u copy %" W "u @ %" Q "u (mode %u)\n", |
65 | } | 65 | // winst.position, winst.size, winst.addr, winst.mode); |
66 | } | 66 | // break; |
67 | } | 67 | // } |
68 | // } | ||
69 | // } | ||
68 | 70 | ||
69 | private: | 71 | private: |
70 | xd3_stream stream_; | 72 | xd3_stream stream_; |
diff --git a/xdelta3/testing/file.h b/xdelta3/testing/file.h index c6f3c7b..eb40e51 100644 --- a/xdelta3/testing/file.h +++ b/xdelta3/testing/file.h | |||
@@ -62,20 +62,22 @@ public: | |||
62 | size_ = 0; | 62 | size_ = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | void Print() const { | 65 | // Note: This does not benefit from -Wformat= checking, due to the |
66 | xoff_t pos = 0; | 66 | // enclosing template. Further, it was not used. |
67 | for (size_t i = 0; i < Size(); i++) { | 67 | // void Print() const { |
68 | if (pos % 16 == 0) { | 68 | // xoff_t pos = 0; |
69 | DP(RINT "%5"Q"x: ", pos); | 69 | // for (size_t i = 0; i < Size(); i++) { |
70 | } | 70 | // if (pos % 16 == 0) { |
71 | DP(RINT "%02x ", (*this)[i]); | 71 | // DP(RINT "%5" Q "x: ", pos); |
72 | if (pos % 16 == 15) { | 72 | // } |
73 | DP(RINT "\n"); | 73 | // DP(RINT "%02x ", (*this)[i]); |
74 | } | 74 | // if (pos % 16 == 15) { |
75 | pos++; | 75 | // DP(RINT "\n"); |
76 | } | 76 | // } |
77 | DP(RINT "\n"); | 77 | // pos++; |
78 | } | 78 | // } |
79 | // DP(RINT "\n"); | ||
80 | // } | ||
79 | 81 | ||
80 | void WriteTmpFile(TmpFile *f) const { | 82 | void WriteTmpFile(TmpFile *f) const { |
81 | f->Append(this); | 83 | f->Append(this); |
diff --git a/xdelta3/testing/regtest.cc b/xdelta3/testing/regtest.cc index e83af4b..e5895e0 100644 --- a/xdelta3/testing/regtest.cc +++ b/xdelta3/testing/regtest.cc | |||
@@ -92,22 +92,24 @@ public: | |||
92 | bool done = false; | 92 | bool done = false; |
93 | bool done_after_input = false; | 93 | bool done_after_input = false; |
94 | 94 | ||
95 | IF_DEBUG1 (XPR(NTR "source %"Q"u[%"Q"u] target %"Q"u winsize %"Z"u\n", | 95 | IF_DEBUG1 (XPR(NTR "source %" Q "u[%" Z "u] target %" Q "u winsize %" Z "u\n", |
96 | source_file.Size(), options.block_size, | 96 | source_file.Size(), options.block_size, |
97 | target_file.Size(), | 97 | target_file.Size(), |
98 | Constants::WINDOW_SIZE)); | 98 | Constants::WINDOW_SIZE)); |
99 | 99 | ||
100 | while (!done) { | 100 | while (!done) { |
101 | target_iterator.Get(&target_block); | 101 | target_iterator.Get(&target_block); |
102 | 102 | ||
103 | xoff_t blks = target_iterator.Blocks(); | 103 | xoff_t blks = target_iterator.Blocks(); |
104 | 104 | ||
105 | IF_DEBUG2(XPR(NTR "target in %s: %"Q"..%"Q" %"Q"(%"Q") " | 105 | IF_DEBUG2(XPR(NTR "target in %s: %" Q "u..%" Q "u %" Q "u(%" Q "u) " |
106 | "verified %"Q"\n", | 106 | "verified %" Q "u\n", |
107 | encoding ? "encoding" : "decoding", | 107 | encoding ? "encoding" : "decoding", |
108 | target_iterator.Offset(), | 108 | target_iterator.Offset(), |
109 | target_iterator.Offset() + target_block.Size(), | 109 | target_iterator.Offset() + target_block.Size(), |
110 | target_iterator.Blkno(), blks, verified_bytes)); | 110 | target_iterator.Blkno(), |
111 | blks, | ||
112 | verified_bytes)); | ||
111 | 113 | ||
112 | if (blks == 0 || target_iterator.Blkno() == (blks - 1)) { | 114 | if (blks == 0 || target_iterator.Blkno() == (blks - 1)) { |
113 | xd3_set_flags(&encode_stream, XD3_FLUSH | encode_stream.flags); | 115 | xd3_set_flags(&encode_stream, XD3_FLUSH | encode_stream.flags); |
@@ -153,8 +155,8 @@ public: | |||
153 | xd3_source *src = (encoding ? &encode_source : &decode_source); | 155 | xd3_source *src = (encoding ? &encode_source : &decode_source); |
154 | Block *block = (encoding ? &encode_source_block : &decode_source_block); | 156 | Block *block = (encoding ? &encode_source_block : &decode_source_block); |
155 | if (encoding) { | 157 | if (encoding) { |
156 | IF_DEBUG2(XPR(NTR "[srcblock] %"Q"u last srcpos %"Q"u " | 158 | IF_DEBUG2(XPR(NTR "[srcblock] %" Q "u last srcpos %" Q "u " |
157 | "encodepos %"Q"u\n", | 159 | "encodepos %" Q "u\n", |
158 | encode_source.getblkno, | 160 | encode_source.getblkno, |
159 | encode_stream.match_last_srcpos, | 161 | encode_stream.match_last_srcpos, |
160 | encode_stream.input_position + encode_stream.total_in)); | 162 | encode_stream.input_position + encode_stream.total_in)); |
@@ -231,7 +233,7 @@ public: | |||
231 | const Options &options) { | 233 | const Options &options) { |
232 | vector<const char*> ecmd; | 234 | vector<const char*> ecmd; |
233 | char bbuf[16]; | 235 | char bbuf[16]; |
234 | snprintf(bbuf, sizeof(bbuf), "-B%"Q"u", options.encode_srcwin_maxsz); | 236 | snprintf(bbuf, sizeof(bbuf), "-B%" Q "u", options.encode_srcwin_maxsz); |
235 | ecmd.push_back("xdelta3"); | 237 | ecmd.push_back("xdelta3"); |
236 | ecmd.push_back(bbuf); | 238 | ecmd.push_back(bbuf); |
237 | ecmd.push_back("-s"); | 239 | ecmd.push_back("-s"); |
@@ -371,7 +373,7 @@ public: | |||
371 | void TestPrintf() { | 373 | void TestPrintf() { |
372 | char buf[64]; | 374 | char buf[64]; |
373 | xoff_t x = XOFF_T_MAX; | 375 | xoff_t x = XOFF_T_MAX; |
374 | snprintf_func (buf, sizeof(buf), "%"Q"u", x); | 376 | snprintf_func (buf, sizeof(buf), "%" Q "u", x); |
375 | const char *expect = XD3_USE_LARGEFILE64 ? | 377 | const char *expect = XD3_USE_LARGEFILE64 ? |
376 | "18446744073709551615" : "4294967295"; | 378 | "18446744073709551615" : "4294967295"; |
377 | XD3_ASSERT(strcmp (buf, expect) == 0); | 379 | XD3_ASSERT(strcmp (buf, expect) == 0); |
@@ -696,8 +698,9 @@ void TestOverwriteMutator() { | |||
696 | CHECK(memcmp(b0.Data() + 30, b1.Data() + 30, | 698 | CHECK(memcmp(b0.Data() + 30, b1.Data() + 30, |
697 | Constants::BLOCK_SIZE - 30) == 0); | 699 | Constants::BLOCK_SIZE - 30) == 0); |
698 | 700 | ||
701 | xoff_t zero = 0; | ||
699 | cl1.clear(); | 702 | cl1.clear(); |
700 | cl1.push_back(Change(Change::COPYOVER, 10, 20, (xoff_t)0)); | 703 | cl1.push_back(Change(Change::COPYOVER, 10, 20, zero)); |
701 | spec0.ModifyTo(ChangeListMutator(cl1), &spec1); | 704 | spec0.ModifyTo(ChangeListMutator(cl1), &spec1); |
702 | CHECK_EQ(spec0.Size(), spec1.Size()); | 705 | CHECK_EQ(spec0.Size(), spec1.Size()); |
703 | 706 | ||
@@ -813,7 +816,7 @@ void TestSmallStride() { | |||
813 | InMemoryEncodeDecode(spec0, spec1, &block, options); | 816 | InMemoryEncodeDecode(spec0, spec1, &block, options); |
814 | Delta delta(block); | 817 | Delta delta(block); |
815 | 818 | ||
816 | IF_DEBUG1(DP(RINT "[stride=%d] changes=%u adds=%"Q"u\n", | 819 | IF_DEBUG1(DP(RINT "[stride=%d] changes=%u adds=%" Q "u\n", |
817 | s, changes, delta.AddedBytes())); | 820 | s, changes, delta.AddedBytes())); |
818 | double allowance = Constants::BLOCK_SIZE < 8192 || s < 30 ? 3.0 : 1.1; | 821 | double allowance = Constants::BLOCK_SIZE < 8192 || s < 30 ? 3.0 : 1.1; |
819 | CHECK_GE(allowance * changes, (double)delta.AddedBytes()); | 822 | CHECK_GE(allowance * changes, (double)delta.AddedBytes()); |
@@ -1259,7 +1262,7 @@ void UnitTest() { | |||
1259 | // These are Xdelta tests. | 1262 | // These are Xdelta tests. |
1260 | template <class T> | 1263 | template <class T> |
1261 | void MainTest() { | 1264 | void MainTest() { |
1262 | XPR(NT "Blocksize %"Q"u windowsize %"Z"u\n", | 1265 | XPR(NT "Blocksize %" Q "u windowsize %" Z "u\n", |
1263 | T::BLOCK_SIZE, T::WINDOW_SIZE); | 1266 | T::BLOCK_SIZE, T::WINDOW_SIZE); |
1264 | Regtest<T> regtest; | 1267 | Regtest<T> regtest; |
1265 | TEST(TestEmptyInMemory); | 1268 | TEST(TestEmptyInMemory); |
diff --git a/xdelta3/xdelta3-decode.h b/xdelta3/xdelta3-decode.h index e71b624..bce5956 100644 --- a/xdelta3/xdelta3-decode.h +++ b/xdelta3/xdelta3-decode.h | |||
@@ -288,8 +288,8 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
288 | { | 288 | { |
289 | IF_DEBUG2 ({ | 289 | IF_DEBUG2 ({ |
290 | static int cnt = 0; | 290 | static int cnt = 0; |
291 | XPR(NT "DECODE:%u: COPY at %"Q" (winoffset %"Z") " | 291 | XPR(NT "DECODE:%u: COPY at %"Q"u (winoffset %"W"u) " |
292 | "size %"Z" winaddr %"Z"\n", | 292 | "size %"W"u winaddr %"W"u\n", |
293 | cnt++, | 293 | cnt++, |
294 | stream->total_out + (stream->dec_position - | 294 | stream->total_out + (stream->dec_position - |
295 | stream->dec_cpylen), | 295 | stream->dec_cpylen), |
@@ -330,7 +330,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
330 | if (inst->type == XD3_ADD) | 330 | if (inst->type == XD3_ADD) |
331 | { | 331 | { |
332 | static int cnt; | 332 | static int cnt; |
333 | XPR(NT "DECODE:%d: ADD at %"Q" (winoffset %"Z") size %"Z"\n", | 333 | XPR(NT "DECODE:%d: ADD at %"Q"u (winoffset %"W"u) size %"W"u\n", |
334 | cnt++, | 334 | cnt++, |
335 | (stream->total_out + stream->dec_position - stream->dec_cpylen), | 335 | (stream->total_out + stream->dec_position - stream->dec_cpylen), |
336 | stream->dec_position - stream->dec_cpylen, | 336 | stream->dec_position - stream->dec_cpylen, |
@@ -340,7 +340,7 @@ xd3_decode_parse_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
340 | { | 340 | { |
341 | static int cnt; | 341 | static int cnt; |
342 | XD3_ASSERT (inst->type == XD3_RUN); | 342 | XD3_ASSERT (inst->type == XD3_RUN); |
343 | XPR(NT "DECODE:%d: RUN at %"Q" (winoffset %"Z") size %"Z"\n", | 343 | XPR(NT "DECODE:%d: RUN at %"Q"u (winoffset %"W"u) size %"W"u\n", |
344 | cnt++, | 344 | cnt++, |
345 | stream->total_out + stream->dec_position - stream->dec_cpylen, | 345 | stream->total_out + stream->dec_position - stream->dec_cpylen, |
346 | stream->dec_position - stream->dec_cpylen, | 346 | stream->dec_position - stream->dec_cpylen, |
@@ -526,8 +526,8 @@ xd3_decode_output_halfinst (xd3_stream *stream, xd3_hinst *inst) | |||
526 | if ((source->onblk != blksize) && | 526 | if ((source->onblk != blksize) && |
527 | (blkoff + take > source->onblk)) | 527 | (blkoff + take > source->onblk)) |
528 | { | 528 | { |
529 | IF_DEBUG1 (XPR(NT "[srcfile] short at blkno %"Q" onblk " | 529 | IF_DEBUG1 (XPR(NT "[srcfile] short at blkno %"Q"u onblk " |
530 | "%"Z" blksize %"Z" blkoff %"Z" take %"Z"\n", | 530 | "%"W"u blksize %"W"u blkoff %"W"u take %"W"u\n", |
531 | block, | 531 | block, |
532 | source->onblk, | 532 | source->onblk, |
533 | blksize, | 533 | blksize, |
diff --git a/xdelta3/xdelta3-internal.h b/xdelta3/xdelta3-internal.h index e9fc5f3..e0c561f 100644 --- a/xdelta3/xdelta3-internal.h +++ b/xdelta3/xdelta3-internal.h | |||
@@ -64,7 +64,7 @@ xd3_output* xd3_alloc_output (xd3_stream *stream, | |||
64 | 64 | ||
65 | int xd3_encode_init_full (xd3_stream *stream); | 65 | int xd3_encode_init_full (xd3_stream *stream); |
66 | usize_t xd3_pow2_roundup (usize_t x); | 66 | usize_t xd3_pow2_roundup (usize_t x); |
67 | long get_millisecs_now (); | 67 | long get_millisecs_now (void); |
68 | int xd3_process_stream (int is_encode, | 68 | int xd3_process_stream (int is_encode, |
69 | xd3_stream *stream, | 69 | xd3_stream *stream, |
70 | int (*func) (xd3_stream *), | 70 | int (*func) (xd3_stream *), |
@@ -153,15 +153,12 @@ typedef struct { | |||
153 | 153 | ||
154 | /* Prior to SVN 303 this function was only defined in DJGPP and WIN32 | 154 | /* Prior to SVN 303 this function was only defined in DJGPP and WIN32 |
155 | * environments and other platforms would use the builtin snprintf() | 155 | * environments and other platforms would use the builtin snprintf() |
156 | * with an arrangement of macros below. In OS X 10.6, Apply made | 156 | * with an arrangement of macros below. In OS X 10.6, Apple made |
157 | * snprintf() a macro, which defeated those macros (since snprintf | 157 | * snprintf() a macro, which defeated those macros (since snprintf |
158 | * would be evaluated before its argument macros were expanded, | 158 | * would be evaluated before its argument macros were expanded, |
159 | * therefore always define xsnprintf_func. */ | 159 | * therefore always define xsnprintf_func. */ |
160 | #undef PRINTF_ATTRIBUTE | 160 | #ifndef PRINTF_ATTRIBUTE |
161 | #ifdef __GNUC__ | ||
162 | #define PRINTF_ATTRIBUTE(x,y) __attribute__ ((__format__ (__printf__, x, y))) | 161 | #define PRINTF_ATTRIBUTE(x,y) __attribute__ ((__format__ (__printf__, x, y))) |
163 | #else | ||
164 | #define PRINTF_ATTRIBUTE(x,y) | ||
165 | #endif | 162 | #endif |
166 | 163 | ||
167 | /* Underlying xprintf() */ | 164 | /* Underlying xprintf() */ |
diff --git a/xdelta3/xdelta3-lzma.h b/xdelta3/xdelta3-lzma.h index de317ee..6c16a7e 100644 --- a/xdelta3/xdelta3-lzma.h +++ b/xdelta3/xdelta3-lzma.h | |||
@@ -32,13 +32,13 @@ struct _xd3_lzma_stream { | |||
32 | lzma_filter filters[2]; | 32 | lzma_filter filters[2]; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | xd3_sec_stream* | 35 | static xd3_sec_stream* |
36 | xd3_lzma_alloc (xd3_stream *stream) | 36 | xd3_lzma_alloc (xd3_stream *stream) |
37 | { | 37 | { |
38 | return (xd3_sec_stream*) xd3_alloc (stream, sizeof (xd3_lzma_stream), 1); | 38 | return (xd3_sec_stream*) xd3_alloc (stream, sizeof (xd3_lzma_stream), 1); |
39 | } | 39 | } |
40 | 40 | ||
41 | void | 41 | static void |
42 | xd3_lzma_destroy (xd3_stream *stream, xd3_sec_stream *sec_stream) | 42 | xd3_lzma_destroy (xd3_stream *stream, xd3_sec_stream *sec_stream) |
43 | { | 43 | { |
44 | xd3_lzma_stream *ls = (xd3_lzma_stream*) sec_stream; | 44 | xd3_lzma_stream *ls = (xd3_lzma_stream*) sec_stream; |
@@ -46,7 +46,7 @@ xd3_lzma_destroy (xd3_stream *stream, xd3_sec_stream *sec_stream) | |||
46 | xd3_free (stream, ls); | 46 | xd3_free (stream, ls); |
47 | } | 47 | } |
48 | 48 | ||
49 | int | 49 | static int |
50 | xd3_lzma_init (xd3_stream *stream, xd3_lzma_stream *sec, int is_encode) | 50 | xd3_lzma_init (xd3_stream *stream, xd3_lzma_stream *sec, int is_encode) |
51 | { | 51 | { |
52 | int ret; | 52 | int ret; |
@@ -84,7 +84,7 @@ xd3_lzma_init (xd3_stream *stream, xd3_lzma_stream *sec, int is_encode) | |||
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | 86 | ||
87 | int xd3_decode_lzma (xd3_stream *stream, xd3_lzma_stream *sec, | 87 | static int xd3_decode_lzma (xd3_stream *stream, xd3_lzma_stream *sec, |
88 | const uint8_t **input_pos, | 88 | const uint8_t **input_pos, |
89 | const uint8_t *const input_end, | 89 | const uint8_t *const input_end, |
90 | uint8_t **output_pos, | 90 | uint8_t **output_pos, |
@@ -125,7 +125,7 @@ int xd3_decode_lzma (xd3_stream *stream, xd3_lzma_stream *sec, | |||
125 | 125 | ||
126 | #if XD3_ENCODER | 126 | #if XD3_ENCODER |
127 | 127 | ||
128 | int xd3_encode_lzma (xd3_stream *stream, | 128 | static int xd3_encode_lzma (xd3_stream *stream, |
129 | xd3_lzma_stream *sec, | 129 | xd3_lzma_stream *sec, |
130 | xd3_output *input, | 130 | xd3_output *input, |
131 | xd3_output *output, | 131 | xd3_output *output, |
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index 1a3d95e..69330ca 100644 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -320,7 +320,7 @@ static int xd3_merge_input_output (xd3_stream *stream, | |||
320 | * comments there. */ | 320 | * comments there. */ |
321 | #include "xdelta3-blkcache.h" | 321 | #include "xdelta3-blkcache.h" |
322 | 322 | ||
323 | void (*xprintf_message_func)(const char*msg) = NULL; | 323 | static void (*xprintf_message_func)(const char*msg) = NULL; |
324 | 324 | ||
325 | void | 325 | void |
326 | xprintf (const char *fmt, ...) | 326 | xprintf (const char *fmt, ...) |
@@ -1985,8 +1985,8 @@ main_merge_output (xd3_stream *stream, main_file *ofile) | |||
1985 | addr = inst->addr - window_start; | 1985 | addr = inst->addr - window_start; |
1986 | } | 1986 | } |
1987 | IF_DEBUG2 ({ | 1987 | IF_DEBUG2 ({ |
1988 | XPR(NTR "[merge copy] winpos %"W" take %"W" " | 1988 | XPR(NTR "[merge copy] winpos %"W"u take %"W"u " |
1989 | "addr %"Q" mode %u\n", | 1989 | "addr %"Q"u mode %u\n", |
1990 | window_pos, take, addr, inst->mode); | 1990 | window_pos, take, addr, inst->mode); |
1991 | }); | 1991 | }); |
1992 | if ((ret = xd3_found_match (recode_stream, window_pos, take, | 1992 | if ((ret = xd3_found_match (recode_stream, window_pos, take, |
diff --git a/xdelta3/xdelta3-merge.h b/xdelta3/xdelta3-merge.h index a09f814..6e46a3d 100644 --- a/xdelta3/xdelta3-merge.h +++ b/xdelta3/xdelta3-merge.h | |||
@@ -258,8 +258,8 @@ xd3_whole_append_window (xd3_stream *stream) | |||
258 | 258 | ||
259 | /* xd3_merge_input_output applies *source to *stream, returns the | 259 | /* xd3_merge_input_output applies *source to *stream, returns the |
260 | * result in stream. */ | 260 | * result in stream. */ |
261 | int xd3_merge_input_output (xd3_stream *stream, | 261 | static int xd3_merge_input_output (xd3_stream *stream, |
262 | xd3_whole_state *source) | 262 | xd3_whole_state *source) |
263 | { | 263 | { |
264 | int ret; | 264 | int ret; |
265 | xd3_stream tmp_stream; | 265 | xd3_stream tmp_stream; |
diff --git a/xdelta3/xdelta3-test.h b/xdelta3/xdelta3-test.h index 335de28..7ecaaaf 100644 --- a/xdelta3/xdelta3-test.h +++ b/xdelta3/xdelta3-test.h | |||
@@ -1588,7 +1588,7 @@ static int | |||
1588 | test_checksum_step (xd3_stream *stream, int ignore) | 1588 | test_checksum_step (xd3_stream *stream, int ignore) |
1589 | { | 1589 | { |
1590 | const int bufsize = 128; | 1590 | const int bufsize = 128; |
1591 | uint8_t buf[bufsize]; | 1591 | uint8_t buf[128]; |
1592 | for (int i = 0; i < bufsize; i++) | 1592 | for (int i = 0; i < bufsize; i++) |
1593 | { | 1593 | { |
1594 | buf[i] = mt_random (&static_mtrand) & 0xff; | 1594 | buf[i] = mt_random (&static_mtrand) & 0xff; |
@@ -2095,7 +2095,7 @@ test_recode_command (xd3_stream *stream, int ignore) | |||
2095 | } | 2095 | } |
2096 | 2096 | ||
2097 | #if SECONDARY_LZMA | 2097 | #if SECONDARY_LZMA |
2098 | int test_secondary_lzma_default (xd3_stream *stream, int ignore) | 2098 | static int test_secondary_lzma_default (xd3_stream *stream, int ignore) |
2099 | { | 2099 | { |
2100 | char ecmd[TESTBUFSIZE]; | 2100 | char ecmd[TESTBUFSIZE]; |
2101 | int ret; | 2101 | int ret; |
diff --git a/xdelta3/xdelta3.c b/xdelta3/xdelta3.c index 9253d68..b0c9b30 100644 --- a/xdelta3/xdelta3.c +++ b/xdelta3/xdelta3.c | |||
@@ -369,10 +369,6 @@ XD3_MAKELIST(xd3_rlist, xd3_rinst, link); | |||
369 | #define VCD_SELF 0 /* 1st address mode */ | 369 | #define VCD_SELF 0 /* 1st address mode */ |
370 | #define VCD_HERE 1 /* 2nd address mode */ | 370 | #define VCD_HERE 1 /* 2nd address mode */ |
371 | 371 | ||
372 | #define CODE_TABLE_STRING_SIZE (6 * 256) /* Should fit a code table string. */ | ||
373 | #define CODE_TABLE_VCDIFF_SIZE (6 * 256) /* Should fit a compressed code | ||
374 | * table string */ | ||
375 | |||
376 | #define SECONDARY_ANY (SECONDARY_DJW || SECONDARY_FGK || SECONDARY_LZMA) | 372 | #define SECONDARY_ANY (SECONDARY_DJW || SECONDARY_FGK || SECONDARY_LZMA) |
377 | 373 | ||
378 | #define ALPHABET_SIZE 256 /* Used in test code--size of the secondary | 374 | #define ALPHABET_SIZE 256 /* Used in test code--size of the secondary |
@@ -381,9 +377,6 @@ XD3_MAKELIST(xd3_rlist, xd3_rinst, link); | |||
381 | #define HASH_CKOFFSET 1U /* Table entries distinguish "no-entry" from | 377 | #define HASH_CKOFFSET 1U /* Table entries distinguish "no-entry" from |
382 | * offset 0 using this offset. */ | 378 | * offset 0 using this offset. */ |
383 | 379 | ||
384 | #define MIN_SMALL_LOOK 2U /* Match-optimization stuff. */ | ||
385 | #define MIN_LARGE_LOOK 2U | ||
386 | #define MIN_MATCH_OFFSET 1U | ||
387 | #define MAX_MATCH_SPLIT 18U /* VCDIFF code table: 18 is the default limit | 380 | #define MAX_MATCH_SPLIT 18U /* VCDIFF code table: 18 is the default limit |
388 | * for direct-coded ADD sizes */ | 381 | * for direct-coded ADD sizes */ |
389 | 382 | ||
@@ -395,7 +388,6 @@ XD3_MAKELIST(xd3_rlist, xd3_rinst, link); | |||
395 | * between them. 0. */ | 388 | * between them. 0. */ |
396 | 389 | ||
397 | #define MIN_MATCH 4U /* VCDIFF code table: MIN_MATCH=4 */ | 390 | #define MIN_MATCH 4U /* VCDIFF code table: MIN_MATCH=4 */ |
398 | #define MIN_ADD 1U /* 1 */ | ||
399 | #define MIN_RUN 8U /* The shortest run, if it is shorter than this | 391 | #define MIN_RUN 8U /* The shortest run, if it is shorter than this |
400 | * an immediate add/copy will be just as good. | 392 | * an immediate add/copy will be just as good. |
401 | * ADD1/COPY6 = 1I+1D+1A bytes, RUN18 = | 393 | * ADD1/COPY6 = 1I+1D+1A bytes, RUN18 = |
@@ -416,8 +408,6 @@ XD3_MAKELIST(xd3_rlist, xd3_rinst, link); | |||
416 | #define INST_HEAD(s) ((s)->enc_heads[2]) | 408 | #define INST_HEAD(s) ((s)->enc_heads[2]) |
417 | #define ADDR_HEAD(s) ((s)->enc_heads[3]) | 409 | #define ADDR_HEAD(s) ((s)->enc_heads[3]) |
418 | 410 | ||
419 | #define TOTAL_MODES(x) (2+(x)->acache.s_same+(x)->acache.s_near) | ||
420 | |||
421 | /* Template instances. */ | 411 | /* Template instances. */ |
422 | #if XD3_BUILD_SLOW | 412 | #if XD3_BUILD_SLOW |
423 | #define IF_BUILD_SLOW(x) x | 413 | #define IF_BUILD_SLOW(x) x |
@@ -4482,10 +4472,9 @@ xd3_srcwin_move_point (xd3_stream *stream, usize_t *next_move_point) | |||
4482 | } | 4472 | } |
4483 | 4473 | ||
4484 | IF_DEBUG1 (DP(RINT | 4474 | IF_DEBUG1 (DP(RINT |
4485 | "[srcwin_move_point] exited loop T=%"Q"{%"Q"} " | 4475 | "[srcwin_move_point] exited loop T=%"Q"u " |
4486 | "S=%"Q" EOF=%"Q" %s\n", | 4476 | "S=%"Q" EOF=%"Q" %s\n", |
4487 | stream->total_in + stream->input_position, | 4477 | stream->total_in + stream->input_position, |
4488 | logical_input_cksum_pos, | ||
4489 | stream->srcwin_cksum_pos, | 4478 | stream->srcwin_cksum_pos, |
4490 | xd3_source_eof (stream->src), | 4479 | xd3_source_eof (stream->src), |
4491 | stream->src->eof_known ? "known" : "unknown")); | 4480 | stream->src->eof_known ? "known" : "unknown")); |
@@ -4577,7 +4566,7 @@ XD3_TEMPLATE(xd3_string_match_) (xd3_stream *stream) | |||
4577 | int ret; | 4566 | int ret; |
4578 | usize_t match_length; | 4567 | usize_t match_length; |
4579 | usize_t match_offset = 0; | 4568 | usize_t match_offset = 0; |
4580 | usize_t next_move_point; | 4569 | usize_t next_move_point = 0; |
4581 | 4570 | ||
4582 | IF_DEBUG2(DP(RINT "[string_match] initial entry %u\n", stream->input_position)); | 4571 | IF_DEBUG2(DP(RINT "[string_match] initial entry %u\n", stream->input_position)); |
4583 | 4572 | ||
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index 1b134eb..e440f70 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -298,6 +298,10 @@ typedef uint32_t usize_t; | |||
298 | #define SWIG_MODULE 0 | 298 | #define SWIG_MODULE 0 |
299 | #endif | 299 | #endif |
300 | 300 | ||
301 | #ifndef NOT_MAIN | ||
302 | #define NOT_MAIN 0 | ||
303 | #endif | ||
304 | |||
301 | /* There are three string matching functions supplied: one fast, one | 305 | /* There are three string matching functions supplied: one fast, one |
302 | * slow (default), and one soft-configurable. To disable any of | 306 | * slow (default), and one soft-configurable. To disable any of |
303 | * these, use the following definitions. */ | 307 | * these, use the following definitions. */ |