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>
This commit is contained in:
Stefano Brivio
2021-10-21 09:41:13 +02:00
parent c3f8e4d2cd
commit 627e18fa8a
17 changed files with 159 additions and 118 deletions

8
ndp.c
View File

@@ -91,7 +91,7 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len)
memcpy(p, c->mac, ETH_ALEN);
p += 6;
} else if (ih->icmp6_type == RS) {
size_t len = 0;
size_t dns_s_len = 0;
int i, n;
if (c->no_ra)
@@ -139,7 +139,7 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len)
}
for (n = 0; *c->dns_search[n].n; n++)
len += strlen(c->dns_search[n].n) + 2;
dns_s_len += strlen(c->dns_search[n].n) + 2;
if (len) {
*p++ = 31; /* DNSSL */
*p++ = (len + 8 - 1) / 8 + 1; /* length */
@@ -163,8 +163,8 @@ int ndp(struct ctx *c, struct ethhdr *eh, size_t len)
*(p++) = 0;
}
memset(p, 0, 8 - len % 8); /* padding */
p += 8 - len % 8;
memset(p, 0, 8 - dns_s_len % 8); /* padding */
p += 8 - dns_s_len % 8;
}
*p++ = 1; /* source ll */