From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by mx.groups.io with SMTP id smtpd.web10.19341.1675958226623633194 for ; Thu, 09 Feb 2023 07:57:06 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@bsdio.com header.s=fm2 header.b=MYChbnjI; spf=pass (domain: bsdio.com, ip: 66.111.4.26, mailfrom: rebecca@bsdio.com) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 78C295C00E4; Thu, 9 Feb 2023 10:57:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 09 Feb 2023 10:57:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdio.com; h=cc :content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1675958225; x= 1676044625; bh=IizRdmaq+eiT93p73Rs4J8IVB602QBYdn20PhSqxons=; b=M YChbnjIT8Nw4eqhBTuwvPUwN8YgUNRqD8AIgvOi6/kYxoG+emgPbip53geo5ed/S FPXRGOTqpzdDRuKPzuHeoH7vHdJO+BRQrs+UHUVGMmyKGqynIk+GH1SLwMq2tdRq UgDDFiC8tmJW7lbcNHQfHvN1/taNPMOObbK1EDTEewL9jEvJqr0Xa0aur1tWl79M HN92AKcuBbLEiil5+IafFt6PX31ifwzVhzbx007PnGGoQ+OiKP04yv4Yzs9uuUag 1BfyZxY+WVnuD+i4AaI2UPiyC/m6Dv+rnl0Ek93tEaxp7LtL9uWOGjq35RstHGc+ OtxCCJXT1zRJbT/Z+vDjQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1675958225; x=1676044625; bh=I izRdmaq+eiT93p73Rs4J8IVB602QBYdn20PhSqxons=; b=WEZRuF/SnNluJS1gh VEmBFsGSCeBTgM7fAhsfIt0AKDtXqWY9xl/+urPUKlOkWm1m/iIPPG8VAdJg4zFk HH6o3C8O8cbGp4DyKoXZrnmcKDxVjlUaqFAA1saFOfLTf0QNM5YQjPUHK0vlry/j QxRNUYwO2wt4IKtkzHSmR7/XjqoCL9RTc4rCv3IgpfGvo4yzFKoKOB3KYkxsh58f yZGokE5K3RSfaEL6Kkgn384oJ1o6dAWYJrGi97kwAdrU8OpVO9eJcFIUCfe50LHF YxrA4DtzrsHwV6PoASDMsxwyxzccLhZJQbBu6R2/PSZtTuRI6lUAS4iH19ep6Qrf UyXiw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehfedgkedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttdefjeenucfhrhhomheptfgvsggv tggtrgcuvehrrghnuceorhgvsggvtggtrgessghsughiohdrtghomheqnecuggftrfgrth htvghrnhepiefhheefgeeghfefuedukeehjeeuhfdvtedvudetleffueduuddukefhhffh tdejnecuffhomhgrihhnpehgrhhouhhpshdrihhopdhgihhthhhusgdrtghomhenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrvggsvggttggr segsshguihhordgtohhm X-ME-Proxy: Feedback-ID: i5b994698:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Feb 2023 10:57:04 -0500 (EST) Message-ID: <3fb1769f-8666-ec1b-50c3-725bbd73b68a@bsdio.com> Date: Thu, 9 Feb 2023 08:57:03 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: Enum size checks in Base.h (UINT32 not ISO C compatible) To: "Kinney, Michael D" , "devel@edk2.groups.io" , "Gao, Liming" References: <36f37eb3-05de-64c3-833e-f625376b6f70@bsdio.com> From: "Rebecca Cran" In-Reply-To: Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit I've sent a patch (https://edk2.groups.io/g/devel/message/99903). On 2/8/23 19:28, Kinney, Michael D wrote: > Hi Rebecca, > > Great catch!!! I think the static assert verifier is incorrect. > > The UEFI Spec does clearly state in Section 2.3.1 that enum values > can be type INT32 or UINT32. The use of 0xFFFFFFFF assumes use of > only UINT32. I agree that the correct value to assign to the 32-bit > enum value for this size check should be 0x7FFFFFFFF. > > Mike > >> -----Original Message----- >> From: Rebecca Cran >> Sent: Wednesday, February 8, 2023 6:20 PM >> To: devel@edk2.groups.io; Kinney, Michael D ; Gao, Liming >> Subject: Enum size checks in Base.h (UINT32 not ISO C compatible) >> >> In commit 6440385b17def888544c2454ffba58384b929a22 >> (https://github.com/tianocore/edk2/commit/6440385b17def888544c2454ffba58384b929a22) >> enum size checks were added. >> >> However, according to gcc, ISO C restricts the size of enum values to >> int; building with -std=c11 -pedantic results in the error: >> >> MdePkg/Include/Base.h:812:28: error: ISO C restricts enumerator values >> to range of ‘int’ [-Werror=pedantic] >> 812 | __VerifyInt32EnumValue = 0xffffffff >> >> Replacing 0xffffffff with 0x7fffffff fixes the problem. >> >> It looks like this might change in C23, but since the use of >> _Static_assert in Base.h we require at least C11 (and I suspect most >> compilers aren't C23 compliant) which states: >> >> "The expression that defines the value of an enumeration constant shall >> be an integer constant expression that has a value representable as an int. >> [Section 6.7.2.2]" >> >> The UEFI Specification appears to say we require an INT32 (i.e. a signed >> int) so is the existing code wrong? >> >> -- >> Rebecca Cran