From c1d2a070f282a95316e8f045e8959856518ab2f0 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 21 Sep 2023 14:49:39 +1000 Subject: util: Consolidate and improve workarounds for clang-tidy issue 58992 We have several workarounds for a clang-tidy bug where the checker doesn't recognize that a number of system calls write to - and therefore initialise - a socket address. We can't neatly use a suppression, because the bogus warning shows up some time after the actual system call, when we access a field of the socket address which clang-tidy erroneously thinks is uninitialised. Consolidate these workarounds into one place by using macros to implement wrappers around affected system calls which add a memset() of the sockaddr to silence clang-tidy. This removes the need for the individual memset() workarounds at the callers - and the somewhat longwinded explanatory comments. We can then use a #define to not include the hack in "real" builds, but only consider it for clang-tidy. Signed-off-by: David Gibson Signed-off-by: Stefano Brivio --- icmp.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'icmp.c') diff --git a/icmp.c b/icmp.c index f2cc4d6..41b9f8b 100644 --- a/icmp.c +++ b/icmp.c @@ -76,11 +76,6 @@ void icmp_sock_handler(const struct ctx *c, union epoll_ref ref) if (c->no_icmp) return; - /* FIXME: Workaround clang-tidy not realizing that recvfrom() - * writes the socket address. See - * https://github.com/llvm/llvm-project/issues/58992 - */ - memset(&sr, 0, sizeof(sr)); n = recvfrom(ref.fd, buf, sizeof(buf), 0, (struct sockaddr *)&sr, &sl); if (n < 0) return; -- cgit v1.2.3