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.133.124]) by passt.top (Postfix) with ESMTP id 627105A026F for ; Wed, 20 Sep 2023 00:17:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695161829; 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=tvj5JBe1s07kyPMjE8UOCZeczFMvMYP4nfaFzsGRVAA=; b=YYQQv7Gm88zbBKM8kzfS5Fv2pmx9I0MXaPfyGDrSIrtCltz/nPlV3nLsDN43EJFP01vXwB CCombSW8QRzkebtm/hIuBA3vNzpnttL1IF37DNvUn1X5kG4huxPrNVo1fQ5Mk0XGqFBf5R VGZDf2i81/R8TlhVG+lK1mC0+Q5TEdE= 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-590-3oJDw1qHOAu0tkrlp7Y_pA-1; Tue, 19 Sep 2023 18:17:07 -0400 X-MC-Unique: 3oJDw1qHOAu0tkrlp7Y_pA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 CA1193806627; Tue, 19 Sep 2023 22:17:06 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A1B2492B16; Tue, 19 Sep 2023 22:17:05 +0000 (UTC) Date: Wed, 20 Sep 2023 00:17:04 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/2] util: Consolidate and improve workarounds for clang-tidy issue 58992 Message-ID: <20230920001704.2bd34f7d@elisabeth> In-Reply-To: References: <20230915064337.2380211-1-david@gibson.dropbear.id.au> <20230915064337.2380211-3-david@gibson.dropbear.id.au> <20230918101608.00434c15@elisabeth> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: V5KO7XWVSIGLJ5ERYUFVL23NUJPM7CMW X-Message-ID-Hash: V5KO7XWVSIGLJ5ERYUFVL23NUJPM7CMW 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 Tue, 19 Sep 2023 11:08:51 +1000 David Gibson wrote: > On Mon, Sep 18, 2023 at 10:16:08AM +0200, Stefano Brivio wrote: > > 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()? > > Eh.. maybe? I was going for minimal differences in the preprocessed > code between the two cases, to reduce the chances of missing some > unrelated real problem due to the fact we're kind of lying to our > static checker. Ah, okay, I see your point -- in both cases we'd call a function (even though one is going to be inlined, the other one not necessarily)... sure, it makes sense. -- Stefano