From 627e18fa8ad000ed92405cff3a88c36fd5f3027e Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Thu, 21 Oct 2021 09:41:13 +0200 Subject: passt: Add cppcheck target, test, and address resulting warnings ...mostly false positives, but a number of very relevant ones too, in tcp_get_sndbuf(), tcp_conn_from_tap(), and siphash PREAMBLE(). Signed-off-by: Stefano Brivio --- siphash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'siphash.c') diff --git a/siphash.c b/siphash.c index 88f8bd2..ec38848 100644 --- a/siphash.c +++ b/siphash.c @@ -65,7 +65,7 @@ int __i; \ \ do { \ - for (__i = sizeof(v) / sizeof(v[0]); __i >= 0; __i--) \ + for (__i = sizeof(v) / sizeof(v[0]) - 1; __i >= 0; __i--) \ v[__i] = k[__i % 2]; \ } while (0) @@ -152,13 +152,13 @@ __attribute__((__noinline__)) /* See comment in Makefile */ uint64_t siphash_20b(const uint8_t *in, const uint64_t *k) { uint32_t *in32 = (uint32_t *)in; - uint64_t combined; int i; PREAMBLE(20); for (i = 0; i < 2; i++, in32 += 2) { - combined = (uint64_t)(*(in32 + 1)) << 32 | *in32; + uint64_t combined = (uint64_t)(*(in32 + 1)) << 32 | *in32; + v[3] ^= combined; SIPROUND(2); v[0] ^= combined; @@ -205,13 +205,13 @@ uint32_t siphash_32b(const uint8_t *in, const uint64_t *k) uint32_t siphash_36b(const uint8_t *in, const uint64_t *k) { uint32_t *in32 = (uint32_t *)in; - uint64_t combined; int i; PREAMBLE(36); for (i = 0; i < 4; i++, in32 += 2) { - combined = (uint64_t)(*(in32 + 1)) << 32 | *in32; + uint64_t combined = (uint64_t)(*(in32 + 1)) << 32 | *in32; + v[3] ^= combined; SIPROUND(2); v[0] ^= combined; -- cgit v1.2.3