aboutgitcodebugslistschat
path: root/siphash.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2021-10-21 09:41:13 +0200
committerStefano Brivio <sbrivio@redhat.com>2021-10-21 09:41:13 +0200
commit627e18fa8ad000ed92405cff3a88c36fd5f3027e (patch)
tree5caf72002139dd6bc80cd424de1730f8602cbb9d /siphash.c
parentc3f8e4d2cd55e57419478ff849265d1e342e7990 (diff)
downloadpasst-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.gz
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.bz2
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.lz
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.xz
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.tar.zst
passt-627e18fa8ad000ed92405cff3a88c36fd5f3027e.zip
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 <sbrivio@redhat.com>
Diffstat (limited to 'siphash.c')
-rw-r--r--siphash.c10
1 files changed, 5 insertions, 5 deletions
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;