From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 9C2F35A0272 for ; Mon, 18 Sep 2023 10:16:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695024974; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3CF1N8QzeQ1SpD+aDmDOV2ZklWySdT8axZKRP1HEMuc=; b=LX6F7hofr4UFoWNIfl2c/S6SLQeL4GJ/OVcgueDS/0nmNISOpkBpwvp/4QkJ6op1ghMqfd XFwaC90LHsLqN+O2wurf6vXN5oND5TERtQuaD62/ybNok8RE3MHxrRT918ML8TzqAImVdM OZFmlBOdsD2eyjwiWgrQI/U3yH9KyTU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-179-XMCxpSN1MdC9nliJP1amjA-1; Mon, 18 Sep 2023 04:16:11 -0400 X-MC-Unique: XMCxpSN1MdC9nliJP1amjA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D689A1C0512F; Mon, 18 Sep 2023 08:16:10 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.36]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25B7F2156702; Mon, 18 Sep 2023 08:16:09 +0000 (UTC) Date: Mon, 18 Sep 2023 10:16:08 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/2] util: Consolidate and improve workarounds for clang-tidy issue 58992 Message-ID: <20230918101608.00434c15@elisabeth> In-Reply-To: <20230915064337.2380211-3-david@gibson.dropbear.id.au> References: <20230915064337.2380211-1-david@gibson.dropbear.id.au> <20230915064337.2380211-3-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: CIZUQZTNYH2OSYRKWDWXRE2SINDRBQY5 X-Message-ID-Hash: CIZUQZTNYH2OSYRKWDWXRE2SINDRBQY5 X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 15 Sep 2023 16:43:37 +1000 David Gibson wrote: > 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. I'm probably missing something, but wouldn't it be more obvious to conditionally define the wrapper itself? That is, #ifdef CLANG_TIDY_58992 # define recvfrom(s, buf, len, flags, src, addrlen) \ wrap_recvfrom((s), (buf), (len), (flags), (src), (addrlen)) #endif instead of doing that in sa_init()? -- Stefano