From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.16860.1606473939581693142 for ; Fri, 27 Nov 2020 02:45:40 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: vijayenthiran.subramaniam@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0E75F1516 for ; Fri, 27 Nov 2020 02:45:39 -0800 (PST) Received: from mail-yb1-f169.google.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F04653F71F for ; Fri, 27 Nov 2020 02:45:38 -0800 (PST) Received: by mail-yb1-f169.google.com with SMTP id 10so4125779ybx.9 for ; Fri, 27 Nov 2020 02:45:38 -0800 (PST) X-Gm-Message-State: AOAM533xKjcfLrRdf5Aib1G4eTjDErhvey+zTRaxfcZRZVYtyLHP01ea z8EOc4Hg0xEwnrVJ0A/5b2XATFNDj9AA5HNbyes= X-Google-Smtp-Source: ABdhPJwHs/0XLrlXA7JfyndqZSWKmHFfyBXQvwJgjLs6h4H3CFvUsJrVoxFZts9Fxx4YUcGurCcyjqQ2IAQmtYo0oeY= X-Received: by 2002:a5b:48a:: with SMTP id n10mr8052699ybp.455.1606473938541; Fri, 27 Nov 2020 02:45:38 -0800 (PST) MIME-Version: 1.0 References: <1606314630-13316-1-git-send-email-vijayenthiran.subramaniam@arm.com> <61896e63-567a-bb9f-aa23-62d99b559d00@arm.com> In-Reply-To: <61896e63-567a-bb9f-aa23-62d99b559d00@arm.com> From: "Vijayenthiran Subramaniam" Date: Fri, 27 Nov 2020 10:45:25 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] [edk2-platforms] [PATCH v3] Platform/ARM/SgiPkg: Fix constant-logical-operand clang error To: devel@edk2.groups.io, ard.biesheuvel@arm.com Cc: Vijayenthiran Subramaniam , leif@nuviainc.com, thomas.abraham@arm.com Content-Type: text/plain; charset="UTF-8" Hi Ard, On Wed, Nov 25, 2020 at 3:05 PM Ard Biesheuvel wrote: > > On 11/25/20 3:30 PM, Vijayenthiran Subramaniam wrote: > > Fix "use of logical '&&' with constant operand" error when built with > > CLANG38 toolchain. > > > > Reviewed-by: Thomas Abraham > > Signed-off-by: Vijayenthiran Subramaniam > > --- > > > > Changes since v2: > > - Reviewed-bys added from: > > https://edk2.groups.io/g/devel/topic/71391950#55868 > > - Rebased to latest master and repost. > > > > Changes since v1: > > - Fix Copyright year > > > > Note: > > Fix Clan error reported by Leif in > > https://edk2.groups.io/g/devel/message/54586 > > > > Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c | 10 +++++----- > > 1 file changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c > > index 9e5f7e70..f91724b9 100644 > > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c > > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioDevices.c > > @@ -1,6 +1,6 @@ > > /** @file > > > > - Copyright (c) 2018, ARM Ltd. All rights reserved.
> > + Copyright (c) 2018-2020, ARM Limited. All rights reserved. > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -81,8 +81,8 @@ InitVirtioDevices ( > > STATIC EFI_HANDLE mVirtIoNetController = NULL; > > > > // Install protocol interface for storage device > > - if ((FeaturePcdGet (PcdVirtioBlkSupported)) && > > - (FixedPcdGet32 (PcdVirtioBlkBaseAddress))) { > > + if ((FeaturePcdGet (PcdVirtioBlkSupported) == TRUE) && > > + (FixedPcdGet32 (PcdVirtioBlkBaseAddress) != 0)) { > > Nack > > Please fix this by disabling this bogus warning in the compiler. The > original code is perfectly reasonable, and comparing a boolean > expression to TRUE could equally trigger a diagnostic in another > compiler for being redundant. (The != 0 check for a UINT32 is fine) As you suggested, Boolean comparison with TRUE is not required for CLANG as well. But != 0 check for UINT32 is required to fix the error while building with the CLANG toolchain profile. Would it be ok if I post another version with just != 0 check with UNT32? Regards, Vijayenthiran > > > Status = gBS->InstallProtocolInterface (&mVirtIoBlkController, > > &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, > > &mVirtioBlockDevicePath); > > @@ -110,8 +110,8 @@ InitVirtioDevices ( > > } > > > > // Install protocol interface for network device > > - if ((FeaturePcdGet (PcdVirtioNetSupported)) && > > - (FixedPcdGet32 (PcdVirtioNetBaseAddress))) { > > + if ((FeaturePcdGet (PcdVirtioNetSupported) == TRUE) && > > + (FixedPcdGet32 (PcdVirtioNetBaseAddress) != 0)) { > > Status = gBS->InstallProtocolInterface (&mVirtIoNetController, > > &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, > > &mVirtioNetDevicePath); > >