Skip to content

Commit

Permalink
Add 'cppcheck' target.
Browse files Browse the repository at this point in the history
Fix cppcheck warnings.
  • Loading branch information
eloj committed Feb 16, 2023
1 parent 8bf7764 commit 5844db9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ fuzz: fuzz-roundtrip-driver
test: lzw-eddy
${TEST_PREFIX} ./run-tests.sh

cppcheck:
@cppcheck --verbose --error-exitcode=1 --enable=warning,performance,portability .

backup:
@echo -e $(YELLOW)Making backup$(NC)
tar -cJf ../$(notdir $(CURDIR))-`date +"%Y-%m"`.tar.xz ../$(notdir $(CURDIR))
Expand Down
4 changes: 2 additions & 2 deletions fuzzing/afl_roundtrip_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ int main(int argc, char *argv[]) {
if (input && slen > 0) {
// Compress input from fuzzer.
while ((res = lzw_compress(&statec0, input, slen, comp, dest_size)) > 0) { comp_size += res; };
printf("compressed:%zd (res=%zd)\n", comp_size, res);
printf("compressed:%zu (res=%zd)\n", comp_size, res);
if (res < 0) {
abort();
}

// Decompress the compressed data...
while ((res = lzw_decompress(&stated0, comp, comp_size, decomp, dest_size)) > 0) { decomp_size += res; };
printf("decompressed:%zd (res=%zd)\n", decomp_size, res);
printf("decompressed:%zu (res=%zd)\n", decomp_size, res);
if (res < 0) {
abort();
}
Expand Down
6 changes: 3 additions & 3 deletions lzw-eddy.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static void lzw_compress_file(const char *srcfile, const char *destfile) {
if (ofile) {
uint8_t *src = malloc(slen);
if (!src) {
fprintf(stderr, "ERROR: memory allocation of %lu bytes failed.\n", slen);
fprintf(stderr, "ERROR: memory allocation of %ld bytes failed.\n", slen);
exit(1);
}
uint8_t dest[4096];
Expand Down Expand Up @@ -144,7 +144,7 @@ static void lzw_decompress_file(const char *srcfile, const char *destfile) {
}
uint8_t *src = malloc(slen);
if (!src) {
fprintf(stderr, "ERROR: memory allocation of %lu bytes failed.\n", slen);
fprintf(stderr, "ERROR: memory allocation of %ld bytes failed.\n", slen);
exit(1);
}

Expand Down Expand Up @@ -185,7 +185,7 @@ int main(int argc, char *argv []) {

if (!infile || !outfile) {
printf("Usage: %s -c file|-d file -o outfile\n", argv[0]);
printf("Compiled Configuration:\n LZW_MIN_CODE_WIDTH=%d, LZW_MAX_CODE_WIDTH=%d, LZW_MAX_CODES=%ld, sizeof(lzw_state)=%zu\n",
printf("Compiled Configuration:\n LZW_MIN_CODE_WIDTH=%d, LZW_MAX_CODE_WIDTH=%d, LZW_MAX_CODES=%lu, sizeof(lzw_state)=%zu\n",
LZW_MIN_CODE_WIDTH,
LZW_MAX_CODE_WIDTH,
LZW_MAX_CODES,
Expand Down

0 comments on commit 5844db9

Please sign in to comment.