From nobody Tue May 7 07:57:57 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=1630419264; cv=none; d=zohomail.com; s=zohoarc; b=jNdrI4ONSq3Fp5vVN7EGVoEtEF79KuqnM5hQgpR0kK/Z4Czl8nN4sPM2kqXeiTU3qtY/USZVxdCI0A9eYW6nzJSc7ENBw0mNp60D/oQEvB/K8y38qYEQTB+Lb5THj/H5Ub3J3YJ9LA/gql+CMagyO7a1X8MH8zOEhKS7XnjCmCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1630419264; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=yG6ysyJBMuKQKJHuHUd78CobuqzBiDHuqcf/DGQXMoA=; b=ZwWIhZxZRhUQ+Vri6kv4ly71PoYDlye/6Qeeykmjvaih3c5I4k6hUrSzdxTtioiaGD1RVXjRy2lOwWUwNDO272fMSk9OGMot1rbW06MuceCJe3vMgtYaf7q1yEA+MKx8WlDSXoqIaRZSONtkjTgI3ILq3x4zA1NykUz1xzRH0oc= 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 1630419264616339.81757623409294; Tue, 31 Aug 2021 07:14:24 -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-210-tYbg9YZENEGSiDGO4HA36w-1; Tue, 31 Aug 2021 10:14:21 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 35349106F6EA; Tue, 31 Aug 2021 14:14:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8D6427CB1; Tue, 31 Aug 2021 14:14:15 +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 7B17F181A2A6; Tue, 31 Aug 2021 14:14:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 17VE8PbT010941 for ; Tue, 31 Aug 2021 10:08:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id AEB316A916; Tue, 31 Aug 2021 14:08:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.192.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8A646A908; Tue, 31 Aug 2021 14:08:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1630419263; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=yG6ysyJBMuKQKJHuHUd78CobuqzBiDHuqcf/DGQXMoA=; b=VoNr380tf1oAjD1gaqyYgjoVFNgSRMphpYR5tn9muP9WZuPElT+4V6y3yOaoJidcP4LhKu jNhDH6QfFeTfuxcnM5o61UGrSutRdK5L4+as1mcABVcC9JYWLo+YFBAEulC9HkenwXSa63 wcz2UdS45el3XABbBif3r51H3tw60Kc= X-MC-Unique: tYbg9YZENEGSiDGO4HA36w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH] meson: avoid bogus warnings from clang and g_autoptr Date: Tue, 31 Aug 2021 15:08:19 +0100 Message-Id: <20210831140819.126155-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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.84 on 10.5.11.23 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: 1630419265479100001 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. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Pavel Hrdina --- meson.build | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/meson.build b/meson.build index 5af09d319a..dbd70b6483 100644 --- a/meson.build +++ b/meson.build @@ -470,6 +470,26 @@ if get_option('warning_level') =3D=3D '2' supported_cc_flags +=3D [ '-Wno-unused-function' ] endif =20 + # Clang complains about unused variables in many scenarios arelated + # 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_var= _args) + supported_cc_flags +=3D [ '-Wno-unused-but-set-variable' ] + endif + endif add_project_arguments(supported_cc_flags, language: 'c') =20 --=20 2.31.1