From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 8187FAC06DD for ; Wed, 13 Dec 2023 00:36:44 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=7iX5U32BDnVN8VMO2IDprD4rjSicXCCRBfKe+FGr68E=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type; s=20140610; t=1702427803; v=1; b=fgs/U6vflKZPxf1srUF31Bxs/QCKD3GXvOzXTN0jdeQI0C/gbmO+HpVB5lurH2N+6Bsv6JEg GNsxGvZFxYFGaGj4R7p44+PqnDnfMqfuMtIfacOt8OyT+0KQ2WI9OrKRAkKLglbnioIYKy2NdYd AmHGbVA1mcWHdGVY+xOyD5mk= X-Received: by 127.0.0.2 with SMTP id uIJ3YY7687511xJ5BpI9iaDo; Tue, 12 Dec 2023 16:36:43 -0800 X-Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by mx.groups.io with SMTP id smtpd.web11.12508.1702427802291608181 for ; Tue, 12 Dec 2023 16:36:42 -0800 X-Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-3333a3a599fso3945179f8f.0 for ; Tue, 12 Dec 2023 16:36:42 -0800 (PST) X-Gm-Message-State: fZfhtV50YSGxyb2lFnRMkiVqx7686176AA= X-Google-Smtp-Source: AGHT+IEvoXu/7qAMlgLi0aJY4DSjViViZlpcnyqmjVOf443fOSZSF11eKVURHHxwstTte90DwlLXlrtjAPlMCO52l7Q= X-Received: by 2002:a05:6000:8c:b0:333:2fd7:95fd with SMTP id m12-20020a056000008c00b003332fd795fdmr3861232wrx.56.1702427800477; Tue, 12 Dec 2023 16:36:40 -0800 (PST) MIME-Version: 1.0 References: <20231212214524.49914-1-mjsbeaton@gmail.com> In-Reply-To: From: "Mike Beaton" Date: Wed, 13 Dec 2023 00:36:29 +0000 Message-ID: Subject: Re: [edk2-devel] [PATCH V2] DebugLib: Allow -Wunneeded-internal-declaration with clang To: Ard Biesheuvel Cc: devel@edk2.groups.io, ardb@google.com, lersek@redhat.com, Mikhail Krichanov Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,mjsbeaton@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="fgs/U6vf"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io > > +#define DEBUG(Expression) \ > > + do { \ > > + _Pragma("GCC diagnostic push") \ > > + _Pragma("GCC diagnostic ignored \"-Wunused-value\"") \ > > + if ((FALSE)) { \ > > + (VOID) Expression; \ > > So what is the point of the VOID cast here? Usually, these are added > to avoid unused value warnings, but these are disabled explicitly via > the pragma. ``` $ cat test.c static int a = 0; void foo() { if ((0)) { (void)((void *)(long)0, a); } } $ clang -c -Wall test.c -o test.o test.c:6:12: warning: expression result unused; should this cast be to 'void'? [-Wunused-value] (void)((void *)(long)0, a); ^ ~ 1 warning generated. ``` Without the pragmas, various DEBUG statements sent into the macro generate unused *value* warnings exactly such as the above. Once we suppress these unused value warnings, the existence of the comma-operator separated list of values, cast to void, avoids unused *variable* warnings, such as the unused variable warning that would otherwise occur about `a` above - allowing `a` to instead just be optimised away when it becomes unused in this way, as we want. For the other questions, let me get back to you! Thank you. -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112461): https://edk2.groups.io/g/devel/message/112461 Mute This Topic: https://groups.io/mt/103138778/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-