diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-09-11 08:28:46 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-11 08:28:46 -0400 |
commit | d02937a20399a3b1c49a3503cabc5b07dc6b5e99 (patch) | |
tree | b3dcd7b54f3b4dc407f3ff50c184ca828abd6d07 /src | |
parent | 2491eadf002e993bee11aa76597ec7f361d8f6e5 (diff) | |
download | tor-d02937a20399a3b1c49a3503cabc5b07dc6b5e99.tar.gz tor-d02937a20399a3b1c49a3503cabc5b07dc6b5e99.zip |
Fix "comparison is always false" warnings in new test_util_di_ops
Having a constant zero means that unsigned < 0 is always false.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_util.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index e105435f05..09a27b7024 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -3278,20 +3278,24 @@ test_util_di_ops(void) * against each possible (single-byte) bit difference * some arithmetic bugs only appear with certain bit patterns */ { - const uint8_t z = 0; + uint8_t zz = 0; uint8_t ii = 0; + int z; for (i = 0; i < 256; i++) { ii = (uint8_t)i; - test_eq(tor_memeq(&z, &ii, 1), z == ii); + test_eq(tor_memeq(&zz, &ii, 1), zz == ii); } /* exhaustively white-box test tor_memcmp * against each possible single-byte numeric difference * some arithmetic bugs only appear with certain bit patterns */ - for (i = 0; i < 256; i++) { - ii = (uint8_t)i; - test_eq(tor_memcmp(&z, &ii, 1) > 0 ? GT : EQ, z > ii ? GT : EQ); - test_eq(tor_memcmp(&ii, &z, 1) < 0 ? LT : EQ, ii < z ? LT : EQ); + for (z = 0; z < 256; z++) { + for (i = 0; i < 256; i++) { + ii = (uint8_t)i; + zz = (uint8_t)z; + test_eq(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ, zz > ii ? GT : EQ); + test_eq(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ, ii < zz ? LT : EQ); + } } } |