]> git.sesse.net Git - fjl/commitdiff
Fix signedness warnings.
authorSteinar H. Gunderson <sesse@debian.org>
Sat, 3 Jan 2009 01:27:29 +0000 (02:27 +0100)
committerSteinar H. Gunderson <sesse@debian.org>
Sat, 3 Jan 2009 01:27:29 +0000 (02:27 +0100)
dehuff.c
input.c
input_test.c
unstuff.c
unstuff_test.c

index dd5c57dd940368f2f23481d909ac871d829e6f0a..a7254692dd4f90deae10bc2fb571baf9952f26bb 100644 (file)
--- a/dehuff.c
+++ b/dehuff.c
@@ -9,7 +9,7 @@ void reliable_read(raw_input_func_t* input_func, void* userdata, uint8_t* buf, s
 {
        while (len > 0) {
                ssize_t bytes_read = input_func(userdata, buf, len);
 {
        while (len > 0) {
                ssize_t bytes_read = input_func(userdata, buf, len);
-               assert(bytes_read <= len);
+               assert(bytes_read <= (ssize_t)len);
 
                // TODO: We need better error handling here. setjmp()/longjmp()
                // should hopefully do the trick, but we need to take care for
 
                // TODO: We need better error handling here. setjmp()/longjmp()
                // should hopefully do the trick, but we need to take care for
@@ -159,7 +159,7 @@ unsigned read_huffman_symbol_slow_path(const struct huffman_table* table,
        unsigned code = read_bits(source, 1);
        int i = 0;
 
        unsigned code = read_bits(source, 1);
        int i = 0;
 
-       while (code > table->maxcode[i] || table->maxcode[i] == -1) {
+       while (table->maxcode[i] == -1 || code > (unsigned)table->maxcode[i]) {
                possibly_refill(source, 1);
                code = (code << 1) | read_bits(source, 1);
                ++i;
                possibly_refill(source, 1);
                code = (code << 1) | read_bits(source, 1);
                ++i;
diff --git a/input.c b/input.c
index 7db6e1e3ae7ae7b569044ad450ab7295482edb1b..6c4630f075a4fee47751a149752ac415d10f7d6d 100644 (file)
--- a/input.c
+++ b/input.c
@@ -28,7 +28,7 @@ void possibly_refill_slow_path(struct bit_source* source, unsigned num_bits)
                        (*source->input_func)(source->userdata,
                                              source->bytes + source->bytes_available,
                                              bytes_to_read);
                        (*source->input_func)(source->userdata,
                                              source->bytes + source->bytes_available,
                                              bytes_to_read);
-               assert(bytes_read <= bytes_to_read);
+               assert(bytes_read <= (ssize_t)bytes_to_read);
                assert(bytes_read >= (ssize_t)-1);
 
                // TODO: We need better error handling here. setjmp()/longjmp()
                assert(bytes_read >= (ssize_t)-1);
 
                // TODO: We need better error handling here. setjmp()/longjmp()
index 3ff7ba097d657e4bab7100ea657b6702dc56d53d..57fae748621cfc5d2d4e0c87f1fe529773a91201 100644 (file)
@@ -42,7 +42,7 @@ void test_basic_reading()
        struct bit_source source;
        init_bit_source(&source, custom_read, &ud);
 
        struct bit_source source;
        init_bit_source(&source, custom_read, &ud);
 
-       for (int i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
+       for (unsigned i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
                possibly_refill(&source, 6);
                unsigned ret = read_bits(&source, 6);
                assert(ret == 0x2a);
                possibly_refill(&source, 6);
                unsigned ret = read_bits(&source, 6);
                assert(ret == 0x2a);
@@ -62,7 +62,7 @@ void test_slow_source()
        struct bit_source source;
        init_bit_source(&source, custom_read_slow, &ud);
 
        struct bit_source source;
        init_bit_source(&source, custom_read_slow, &ud);
 
-       for (int i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
+       for (unsigned i = 0; i < sizeof(bytes) * 8 / 6; ++i) {
                possibly_refill(&source, 6);
                unsigned ret = read_bits(&source, 6);
                assert(ret == 0x2a);
                possibly_refill(&source, 6);
                unsigned ret = read_bits(&source, 6);
                assert(ret == 0x2a);
index 4a69178133af7443dee7d6b2ecec275f8f7930f1..997a56241825016fd8a81a19800ddc98af812b05 100644 (file)
--- a/unstuff.c
+++ b/unstuff.c
@@ -34,7 +34,7 @@ int unstuff_fast(uint8_t* dst, const uint8_t* src, size_t len)
        size_t bytes_read = 0;
        size_t bytes_written = 0;
 
        size_t bytes_read = 0;
        size_t bytes_written = 0;
 
-       while (len - bytes_read >= 0) {
+       while (bytes_read < len) {
                // Find the first marker byte in the rest of the stream.
                const uint8_t* ptr = memchr(src, MARKER_CHAR, len - bytes_read);
                if (ptr == NULL) {
                // Find the first marker byte in the rest of the stream.
                const uint8_t* ptr = memchr(src, MARKER_CHAR, len - bytes_read);
                if (ptr == NULL) {
index 754f8bf9d1398401cae1227c9800151588170302..863aef500c041f198d84482e81cae128a56b3b14 100644 (file)
@@ -51,7 +51,7 @@ void gen_random_stuffed_data(uint8_t* dst, size_t len)
 {
        // Standard NR LCG (we avoid rand() to get consistent behavior across platforms).
        uint32_t seed = 1234;
 {
        // Standard NR LCG (we avoid rand() to get consistent behavior across platforms).
        uint32_t seed = 1234;
-       for (int i = 0; i < len; ++i) {
+       for (unsigned i = 0; i < len; ++i) {
                seed = seed * 1664525 + 1013904223;
                uint8_t byte = (uint8_t)(seed & 0xff);
                if (byte != 0xff) {
                seed = seed * 1664525 + 1013904223;
                uint8_t byte = (uint8_t)(seed & 0xff);
                if (byte != 0xff) {
@@ -84,7 +84,7 @@ void test_performance(unstuff_func_t* unstuff)
        struct timeval start, now;
        gettimeofday(&start, NULL);
 
        struct timeval start, now;
        gettimeofday(&start, NULL);
 
-       for (int i = 0; i < num_runs; ++i) {
+       for (unsigned i = 0; i < num_runs; ++i) {
                int ret = unstuff(dst, src, len);
                assert(ret != -1);
        }
                int ret = unstuff(dst, src, len);
                assert(ret != -1);
        }