Skip to content

Commit

Permalink
extremely pedantic compiler warning fix, meson fix, typo fix
Browse files Browse the repository at this point in the history
  • Loading branch information
embg committed Dec 28, 2022
1 parent 4b15448 commit c2574e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
6 changes: 4 additions & 2 deletions build/meson/tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ fuzzer = executable('fuzzer',
dependencies: [ testcommon_dep, thread_dep ],
install: false)

zstreamtest_sources = [join_paths(zstd_rootdir, 'tests/seqgen.c'),
join_paths(zstd_rootdir, 'tests/zstreamtest.c')]
zstreamtest_sources = [
join_paths(zstd_rootdir, 'tests/seqgen.c'),
join_paths(zstd_rootdir, 'tests/zstreamtest.c'),
join_paths(zstd_rootdir, 'tests/external_matchfinder.c')]
zstreamtest = executable('zstreamtest',
zstreamtest_sources,
include_directories: test_includes,
Expand Down
24 changes: 17 additions & 7 deletions contrib/externalMatchfinder/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,23 @@ int main(int argc, char *argv[]) {

FILE *f = fopen(argv[1], "rb");
assert(f);
fseek(f, 0, SEEK_END);
long const srcSize = ftell(f);
fseek(f, 0, SEEK_SET);
{
int const ret = fseek(f, 0, SEEK_END);
assert(ret == 0);
}
size_t const srcSize = ftell(f);
{
int const ret = fseek(f, 0, SEEK_SET);
assert(ret == 0);
}

char* const src = malloc(srcSize + 1);
fread(src, srcSize, 1, f);
fclose(f);
{
size_t const ret = fread(src, srcSize, 1, f);
assert(ret == 1);
int const ret2 = fclose(f);
assert(ret2 == 0);
}

size_t const dstSize = ZSTD_compressBound(srcSize);
char* const dst = malloc(dstSize);
Expand All @@ -78,9 +88,9 @@ int main(int argc, char *argv[]) {
printf("Compressed size: %lu\n", cSize);
} else {
printf("ERROR: input and validation buffers don't match!\n");
for (int i = 0; i < srcSize; i++) {
for (size_t i = 0; i < srcSize; i++) {
if (src[i] != val[i]) {
printf("First bad index: %d\n", i);
printf("First bad index: %zu\n", i);
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/zstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -2764,12 +2764,12 @@ ZSTDLIB_STATIC_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* bloc
* compression operation.
*
* The user shall instruct zstd to use a particular ZSTD_externalMatchFinder_F
* function by calling ZSTD_refExternalMatchFinder(cctx, externalMatchState,
* function by calling ZSTD_registerExternalMatchFinder(cctx, externalMatchState,
* externalMatchFinder). This setting will persist until the next parameter reset
* of the CCtx.
*
* The externalMatchState must be initialized by the user before calling
* ZSTD_refExternalMatchFinder. The user is responsible for destroying the
* ZSTD_registerExternalMatchFinder. The user is responsible for destroying the
* externalMatchState.
*
* LIMITATIONS
Expand Down

0 comments on commit c2574e7

Please sign in to comment.