From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by mx.groups.io with SMTP id smtpd.web11.5225.1675911175603628044 for ; Wed, 08 Feb 2023 18:52:55 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="signature has expired" header.i=@bsdio.com header.s=fm2 header.b=hL1Ov97L; spf=pass (domain: bsdio.com, ip: 66.111.4.29, mailfrom: rebecca@bsdio.com) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id BFFAC5C02EF; Wed, 8 Feb 2023 21:52:54 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 08 Feb 2023 21:52:54 -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=1675911174; x= 1675997574; bh=BmTMDwkyzJaPxuckORzKLoabLa4egnwhMLSK3suDxfU=; b=h L1Ov97L6FH2mYRapWBYVbCBI+kuTg76o/lTzL4Y0c7XZpkJXK9mNrmqR5WqW7jlY 1SiELiG/OqUjO4O3AtuTEM9Qy4FHocoaiAeFu+1H4Wz6tFbyxdA968ladncb1lOs +jhEYvwR343/mw7/4wFGjPS+WyxQtCVcOFy/5P90bsejhKuyJwuwLGIKfGMNoAaS ffz+AqYMY/4w7iXt2oRji9Nq/3jlKHo3Al9Z9yWNOOPrp9pfUu/DR29tn7bOYodT Rhdntn6G/1a/t5tHUWlgGlEqIg7jek8FQfWo8lzJLShVq9rjY75bn+5OM9Tnc1Ru DtR5u+KZ2QuS0AQyBdTtw== 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=1675911174; x=1675997574; bh=B mTMDwkyzJaPxuckORzKLoabLa4egnwhMLSK3suDxfU=; b=iDbHlp/wJNUiHqrD/ LWUlCX9bzw8f5dISFwcWkjXX2QUxgK+J4kRQvUkNwMPO4FAP6P38OBDq0bxOripq vxOUeSFnU/183DrBWXNxsHrfA1XlCfyDfkKUuqMV0QFAGDA2bS+2XTFRWllrNq3b qSxmXAHHPbubf3cpyNo/KJn94acbllquS2JG594ClLZWofHlY1ETaSdoQ0YXnf7X BB9slXavvm6728gTNoxEfTDtnsR7PgqkwdMOG7FL/6Y/GqubPOGSOHAyjA7VFu3L wZWUkPfA+jL473gdiYnZ76T0S6qwkHru6O9fTNYewztTZVlIzC9u5gIz4+4NnrEM 5wnDQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudehuddgudehtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeftvggs vggttggrucevrhgrnhcuoehrvggsvggttggrsegsshguihhordgtohhmqeenucggtffrrg htthgvrhhnpeefkedvteevgfekgeevhfduudejueelvdfgvedujedvhfdtudefjeekjeei tddvgfenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomheprhgvsggvtggtrgessghsughiohdrtgho mh X-ME-Proxy: Feedback-ID: i5b994698:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 8 Feb 2023 21:52:53 -0500 (EST) Message-ID: <87b5aa8a-3917-b775-a22e-896a560d5bbe@bsdio.com> Date: Wed, 8 Feb 2023 19:52:52 -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 Given the comment above it, I was looking in the 2.3 specification: mention of UINT32 was only introduced in UEFI 2.3.1 Errata C. The revision history states: 913 Enum definition does not match what our current compilers implement. I'll send a patch to fix it. -- Rebecca Cran 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