From nobody Fri May 3 23:43:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1630499435; cv=none; d=zohomail.com; s=zohoarc; b=bC0ND+VST8YvCfL2jx3wFezzlg8seggUHs/2TUX2DnBFLG8L9rbJil5Qwm2r4JvE1+4SSzzTkQplo7FA9TawnaOeJP3zFkiWcCi/uhvODeG2b+/BSjgphNxE47tIfiQOCybZQPziJrYZIZ5c+IuNGXhjFv8Oda4P0lx3Cju2Fro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630499435; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+GLlyX0LgVEN1Mm07+KeoOtsecs+REUlPsBQ1rlHVHE=; b=Gl5h4GZsj1lLil8vJ2CkAR2mHMr5IQugIBtxhsNS38GAhk3eHlY0QorTmZ05tPvlWh2bWLhmD6kSZmh2W8vwEQ8hg3hS/70G0MjhjfpUC84GyAWJBAuu0OlgcpMv3ynmpSS8kqO4IcJRH3NbJQPRQK8W6lam0CkQ2PcpIdubCDw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1630499435572142.7244733805935; Wed, 1 Sep 2021 05:30:35 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-OHwzIyZBPPWnHbM-fQh1Mg-1; Wed, 01 Sep 2021 08:30:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A38CE802921; Wed, 1 Sep 2021 12:30:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5B8025C232; Wed, 1 Sep 2021 12:30:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A88304EEA2; Wed, 1 Sep 2021 12:30:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 181CTWDJ026421 for ; Wed, 1 Sep 2021 08:29:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id D3FC818B42; Wed, 1 Sep 2021 12:29:32 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD84A5B826; Wed, 1 Sep 2021 12:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630499434; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+GLlyX0LgVEN1Mm07+KeoOtsecs+REUlPsBQ1rlHVHE=; b=Rz95MnUeNnGf7nBLf9QmgwrTgwo0drNNfMtNtY88xENChegVOp5SGmvXZQSaQRfHeWZDrF XZacV0yUWKGaK58bYiXwLQFbHCUd//iK6f8/347tBs2hEdxkv3XOcNftzgzaR5OtEah0ll R88EQg3DfAj1h/Y+c29jE0J4r2IrSdQ= X-MC-Unique: OHwzIyZBPPWnHbM-fQh1Mg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2] meson: avoid bogus warnings from clang and g_autoptr Date: Wed, 1 Sep 2021 13:29:25 +0100 Message-Id: <20210901122925.197152-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1630499437096100005 Clang has previously had trouble with G_DEFINE_AUTOPTR_CLEANUP_FUNC generated code, thinking it was unused. We turn off -Wunused-function to avoid tripping up on that with CLang. New Clang has started having trouble with g_autoptr now too. In usage scenarios where the variable is set, but never again read, it thinks it is unused not realizing the destructor has useful side effects. For this we have to skip -Wunused-but-set-variable on CLang. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrang=C3=A9 --- build-aux/syntax-check.mk | 2 +- meson.build | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 2058af0b77..5c5a2a8771 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1589,7 +1589,7 @@ exclude_file_name_regexp--sc_prohibit_canonicalize_fi= le_name =3D \ ^(build-aux/syntax-check\.mk|tests/virfilemock\.c)$$ =20 exclude_file_name_regexp--sc_prohibit_raw_allocation =3D \ - ^(docs/advanced-tests\.rst|src/util/viralloc\.[ch]|examples/.*|tests/(se= curityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tools/wireshark/s= rc/packet-libvirt\.c|tools/nss/libvirt_nss(_leases|_macs)?\.c)$$ + ^(meson\.build|docs/advanced-tests\.rst|src/util/viralloc\.[ch]|examples= /.*|tests/(securityselinuxhelper|(vircgroup|nss)mock|commandhelper)\.c|tool= s/wireshark/src/packet-libvirt\.c|tools/nss/libvirt_nss(_leases|_macs)?\.c)= $$ =20 exclude_file_name_regexp--sc_prohibit_readlink =3D \ ^src/(util/virutil|lxc/lxc_container)\.c$$ diff --git a/meson.build b/meson.build index 5af09d319a..ae2e672c1d 100644 --- a/meson.build +++ b/meson.build @@ -470,6 +470,27 @@ if get_option('warning_level') =3D=3D '2' supported_cc_flags +=3D [ '-Wno-unused-function' ] endif =20 + if supported_cc_flags.contains('-Wunused-but-set-variable') + # Clang complains about unused variables in many scenarios related + # to attribute((cleanup)) aka g_auto* + w_unused_but_set_var_args =3D [ '-Wunused-but-set-variable', '-Werror'= ] + w_unused_but_set_var_code =3D ''' + static inline void free_pointer (void *p) { + void **pp =3D (void**)p; + free (*pp); + } + + int main(void) { + __attribute__((cleanup(free_pointer))) char *buffer =3D 0x0; + buffer =3D 0x1; + } + ''' + # We previously turned on unused-but-set-variable, so we must turn + # it off again explicitly now. + if not cc.compiles(w_unused_but_set_var_code, args: w_unused_but_set_v= ar_args) + supported_cc_flags +=3D [ '-Wno-unused-but-set-variable' ] + endif + endif endif add_project_arguments(supported_cc_flags, language: 'c') =20 --=20 2.31.1