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 --- udp.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'udp.c') diff --git a/udp.c b/udp.c index 2f79297..3b8a70a 100644 --- a/udp.c +++ b/udp.c @@ -616,9 +616,9 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref, if (ref.r.p.udp.udp.splice == UDP_TO_NS || ref.r.p.udp.udp.splice == UDP_TO_INIT) { for (i = 0; i < n; i++) { - struct msghdr *mh = &udp_splice_mmh_send[i].msg_hdr; + struct msghdr *mh_s = &udp_splice_mmh_send[i].msg_hdr; - mh->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len; + mh_s->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len; } sendmmsg(s, udp_splice_mmh_send, n, MSG_NOSIGNAL); @@ -626,9 +626,9 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref, } for (i = 0; i < n; i++) { - struct msghdr *mh = &udp_splice_mmh_sendto[i].msg_hdr; + struct msghdr *mh_s = &udp_splice_mmh_sendto[i].msg_hdr; - mh->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len; + mh_s->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len; } if (v6) { @@ -710,8 +710,6 @@ void udp_sock_handler(struct ctx *c, union epoll_ref ref, uint32_t events, else b->ip6h.saddr = c->addr6_ll; - b->ip6h.saddr = c->gw6; - udp_tap_map[V6][src].ts_local = now->tv_sec; if (IN6_IS_ADDR_LOOPBACK(&b->s_in6.sin6_addr)) @@ -1000,11 +998,11 @@ int udp_tap_handler(struct ctx *c, int af, void *addr, } for (i = 0; i < count; i++) { - struct udphdr *uh; + struct udphdr *uh_send; - uh = (struct udphdr *)(msg[i].pkt_buf_offset + pkt_buf); - m[i].iov_base = (char *)(uh + 1); - m[i].iov_len = msg[i].l4_len - sizeof(*uh); + uh_send = (struct udphdr *)(msg[i].pkt_buf_offset + pkt_buf); + m[i].iov_base = (char *)(uh_send + 1); + m[i].iov_len = msg[i].l4_len - sizeof(*uh_send); mm[i].msg_hdr.msg_name = sa; mm[i].msg_hdr.msg_namelen = sl; -- cgit v1.2.3