]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
test_token_bucket: negate after casting to signed type.
authorNick Mathewson <nickm@torproject.org>
Tue, 6 Aug 2019 15:42:04 +0000 (11:42 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 6 Aug 2019 15:42:04 +0000 (11:42 -0400)
Previously we tried multiplying by -1 before casting to int32_t,
which would cause us to cast the -1 to an unsigned before we
multiplied.  This gave us compiler warnings on windows.

Fixes bug 31353; bug not in any released Tor.

src/test/test_token_bucket.c

index d3ce5913885b4cc62c4ea2f6dfb42bdc5a2b2d4b..31670718d9f628c8227853d3b007a10c5f92017b 100644 (file)
@@ -93,7 +93,7 @@ test_token_bucket_ctr_dec(void *arg)
 
   /* Keep underflowing shouldn't flag the bucket as empty. */
   tt_uint_op(false, OP_EQ, token_bucket_ctr_dec(&tb, BURST));
-  tt_int_op(tb.counter.bucket, OP_EQ, (int32_t) ((BURST + 1) * -1));
+  tt_int_op(tb.counter.bucket, OP_EQ, - (int32_t) (BURST + 1));
 
  done:
   ;