diff options
Diffstat (limited to 'tools/lz')
-rw-r--r-- | tools/lz/nullcomp.c | 2 | ||||
-rw-r--r-- | tools/lz/output.c | 12 | ||||
-rw-r--r-- | tools/lz/packing.c | 1 | ||||
-rw-r--r-- | tools/lz/repcomp.c | 2 | ||||
-rw-r--r-- | tools/lz/spcomp.c | 6 | ||||
-rw-r--r-- | tools/lz/uncomp.c | 4 |
6 files changed, 10 insertions, 17 deletions
diff --git a/tools/lz/nullcomp.c b/tools/lz/nullcomp.c index 33d0b726..d4535bd3 100644 --- a/tools/lz/nullcomp.c +++ b/tools/lz/nullcomp.c @@ -6,7 +6,7 @@ Flags values: 0 = split a trailing 33-to-64-byte block at the end into two short blocks; 1 = don't */ -struct command * store_uncompressed (const unsigned char * data, const unsigned char * bitflipped, unsigned short * size, unsigned flags) { +struct command * store_uncompressed (__attribute__((unused)) const unsigned char * data, __attribute__((unused)) const unsigned char * bitflipped, unsigned short * size, unsigned flags) { unsigned short position, block, remainder = *size; struct command * result = NULL; *size = 0; diff --git a/tools/lz/output.c b/tools/lz/output.c index 484a9516..43e7ba92 100644 --- a/tools/lz/output.c +++ b/tools/lz/output.c @@ -28,16 +28,8 @@ void write_commands_and_padding_to_textfile (const char * file, const struct com if (fputs("\tlzend\n", fp) < 0) error_exit(1, "could not write terminator to compressed output"); if (padding_size) { input_stream += padding_offset; - int rv = 0; - unsigned pos; - const char * prefix = "\tdb"; - for (pos = 0; (rv >= 0) && (pos < padding_size); pos ++) { - if (input_stream[pos]) - rv = fprintf(fp, "%s $%02hhx", prefix, input_stream[pos]); - else - rv = fprintf(fp, "%s 0", prefix); - prefix = ","; - } + int rv = fprintf(fp, "\tdb $%02hhx", *(input_stream ++)); + while ((rv >= 0) && (-- padding_size)) rv = fprintf(fp, ", $%02hhx", *(input_stream ++)); if (rv >= 0) rv = -(putc('\n', fp) == EOF); if (rv < 0) error_exit(1, "could not write padding to compressed output"); } diff --git a/tools/lz/packing.c b/tools/lz/packing.c index 3623be96..0cb9fae9 100644 --- a/tools/lz/packing.c +++ b/tools/lz/packing.c @@ -31,6 +31,7 @@ void optimize (struct command * commands, unsigned short count) { break; case 1: if (commands -> value != next -> value) break; + // fallthrough case 3: if ((commands -> count + next -> count) <= MAX_COMMAND_COUNT) { commands -> count += next -> count; diff --git a/tools/lz/repcomp.c b/tools/lz/repcomp.c index 754529e8..f2bbad8a 100644 --- a/tools/lz/repcomp.c +++ b/tools/lz/repcomp.c @@ -7,7 +7,7 @@ (lowest bit to highest: repeat single byte (1), repeat two bytes (2), repeat zeros (3)). */ -struct command * try_compress_repetitions (const unsigned char * data, const unsigned char * bitflipped, unsigned short * size, unsigned flags) { +struct command * try_compress_repetitions (const unsigned char * data, __attribute__((unused)) const unsigned char * bitflipped, unsigned short * size, unsigned flags) { unsigned short pos = 0, skipped = 0; struct command * result = malloc(*size * sizeof(struct command)); struct command * current = result; diff --git a/tools/lz/spcomp.c b/tools/lz/spcomp.c index ab33dbbc..b6184836 100644 --- a/tools/lz/spcomp.c +++ b/tools/lz/spcomp.c @@ -62,11 +62,11 @@ struct command find_best_copy (const unsigned char * data, unsigned short positi struct command simple = {.command = 7}; struct command flipped = simple, backwards = simple; short count, offset; - if (count = scan_forwards(data + position, length - position, data, position, &offset)) + if ((count = scan_forwards(data + position, length - position, data, position, &offset))) simple = (struct command) {.command = 4, .count = count, .value = offset}; - if (count = scan_forwards(data + position, length - position, bitflipped, position, &offset)) + if ((count = scan_forwards(data + position, length - position, bitflipped, position, &offset))) flipped = (struct command) {.command = 5, .count = count, .value = offset}; - if (count = scan_backwards(data, length - position, position, &offset)) + if ((count = scan_backwards(data, length - position, position, &offset))) backwards = (struct command) {.command = 6, .count = count, .value = offset}; struct command command; switch (flags / 24) { diff --git a/tools/lz/uncomp.c b/tools/lz/uncomp.c index b22fc75f..3544cd93 100644 --- a/tools/lz/uncomp.c +++ b/tools/lz/uncomp.c @@ -49,7 +49,7 @@ struct command * get_commands_from_file (const unsigned char * data, unsigned sh } if (slack) *slack = *size - (rp - data); *size = current - result; - return realloc(result, (*size ? *size : 1) * sizeof(struct command)); + return realloc(result, *size * sizeof(struct command)); error: free(result); return NULL; @@ -88,5 +88,5 @@ unsigned char * get_uncompressed_data (const struct command * commands, const un } } *size = current - result; - return realloc(result, *size ? *size : 1); + return result; } |