Skip to content

Commit

Permalink
Fixed compiler warnings in fuzzers. #454
Browse files Browse the repository at this point in the history
  • Loading branch information
nmoinvaz authored and Dead2 committed Oct 22, 2019
1 parent 30131c5 commit f3be38d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions test/fuzz/checksum_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataLen) {
assert(crc1 == crc2);
(void)crc1;
(void)crc2;
assert(PREFIX(crc32_combine)(crc1, crc2, dataLen) ==
PREFIX(crc32_combine)(crc1, crc1, dataLen));
assert(PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen) ==
PREFIX(crc32_combine)(crc1, crc1, (z_off_t)dataLen));

/* Fast CRC32 combine. */
PREFIX(crc32_combine_gen)(op, dataLen);
PREFIX(crc32_combine_gen)(op, (z_off_t)dataLen);
assert(PREFIX(crc32_combine_op)(crc1, crc2, op) ==
PREFIX(crc32_combine_op)(crc2, crc1, op));
assert(PREFIX(crc32_combine)(crc1, crc2, dataLen) ==
assert(PREFIX(crc32_combine)(crc1, crc2, (z_off_t)dataLen) ==
PREFIX(crc32_combine_op)(crc2, crc1, op));

/* Adler32 */
Expand All @@ -71,8 +71,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t dataLen) {
assert(adler1 == adler2);
(void)adler1;
(void)adler2;
assert(PREFIX(adler32_combine)(adler1, adler2, dataLen) ==
PREFIX(adler32_combine)(adler1, adler1, dataLen));
assert(PREFIX(adler32_combine)(adler1, adler2, (z_off_t)dataLen) ==
PREFIX(adler32_combine)(adler1, adler1, (z_off_t)dataLen));

/* This function must return 0. */
return 0;
Expand Down
8 changes: 4 additions & 4 deletions test/fuzz/compress_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
static const uint8_t *data;
static size_t dataLen;

static void check_compress_level(uint8_t *compr, size_t comprLen,
uint8_t *uncompr, size_t uncomprLen,
static void check_compress_level(uint8_t *compr, z_size_t comprLen,
uint8_t *uncompr, z_size_t uncomprLen,
int level) {
PREFIX(compress2)(compr, &comprLen, data, dataLen, level);
PREFIX(uncompress)(uncompr, &uncomprLen, compr, comprLen);
Expand Down Expand Up @@ -57,8 +57,8 @@ static void check_decompress(uint8_t *compr, size_t comprLen) {

int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) {
/* compressBound does not provide enough space for low compression levels. */
size_t comprLen = 100 + 2 * PREFIX(compressBound)(size);
size_t uncomprLen = size;
z_size_t comprLen = 100 + 2 * PREFIX(compressBound)(size);
z_size_t uncomprLen = (z_size_t)size;
uint8_t *compr, *uncompr;

/* Discard inputs larger than 1Mb. */
Expand Down
8 changes: 4 additions & 4 deletions test/fuzz/example_dict_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static const uint8_t *data;
static size_t dataLen;
static alloc_func zalloc = NULL;
static free_func zfree = NULL;
static size_t dictionaryLen = 0;
static unsigned int dictionaryLen = 0;
static unsigned long dictId; /* Adler32 value of the dictionary */

/* ===========================================================================
Expand Down Expand Up @@ -73,15 +73,15 @@ void test_dict_deflate(unsigned char **compr, size_t *comprLen)
CHECK_ERR(err, "deflateSetDictionary");

/* deflateBound does not provide enough space for low compression levels. */
*comprLen = 100 + 2 * PREFIX(deflateBound)(&c_stream, dataLen);
*comprLen = 100 + 2 * PREFIX(deflateBound)(&c_stream, (unsigned long)dataLen);
*compr = (uint8_t *)calloc(1, *comprLen);

dictId = c_stream.adler;
c_stream.next_out = *compr;
c_stream.avail_out = (unsigned int)(*comprLen);

c_stream.next_in = data;
c_stream.avail_in = dataLen;
c_stream.avail_in = (uint32_t)dataLen;

err = PREFIX(deflate)(&c_stream, Z_FINISH);
if (err != Z_STREAM_END) {
Expand Down Expand Up @@ -158,7 +158,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) {
cases, the size of the dictionary is read from the input data. */
dictionaryLen = data[0];
if (dictionaryLen > dataLen)
dictionaryLen = dataLen;
dictionaryLen = (unsigned int)dataLen;

test_dict_deflate(&compr, &comprLen);
test_dict_inflate(compr, comprLen);
Expand Down
6 changes: 3 additions & 3 deletions test/fuzz/example_flush_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static free_func zfree = NULL;
void test_flush(unsigned char *compr, z_size_t *comprLen) {
PREFIX3(stream) c_stream; /* compression stream */
int err;
unsigned int len = dataLen;
unsigned int len = (unsigned int)dataLen;

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
Expand Down Expand Up @@ -97,8 +97,8 @@ void test_sync(unsigned char *compr, size_t comprLen, unsigned char *uncompr, si
}

int LLVMFuzzerTestOneInput(const uint8_t *d, size_t size) {
size_t comprLen = 100 + 2 * PREFIX(compressBound)(size);
size_t uncomprLen = size;
z_size_t comprLen = 100 + 2 * PREFIX(compressBound)(size);
z_size_t uncomprLen = (z_size_t)size;
uint8_t *compr, *uncompr;

/* Discard inputs larger than 1Mb. */
Expand Down
2 changes: 1 addition & 1 deletion test/fuzz/example_small_fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static free_func zfree = NULL;
void test_deflate(unsigned char *compr, size_t comprLen) {
PREFIX3(stream) c_stream; /* compression stream */
int err;
unsigned long len = dataLen;
unsigned long len = (unsigned long)dataLen;

c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
Expand Down

0 comments on commit f3be38d

Please sign in to comment.