From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail04.groups.io (mail04.groups.io [45.79.224.9]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1A1C1D811C3 for ; Tue, 16 Apr 2024 07:37:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=T2CYghN/SwvCGCmBOv5iFuL7Y8i5h9zgOtxeWwGOsjU=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1713253040; v=1; b=wukXbJFv9mlm4ry7VPuoX26YaQmjBR/gDcY0Cfjz5475dLVqUVu+be2Dkj84BxpKugTVXUi/ fGj3JCaD9fDz2fz+GMdH9k80U8tz6FuPAdb3Ud2p09b+lVmIHex67qUb1hNk+a04DXPnEVW6GAq QmfANmx8AlHjvKOX1qsrf/cQvbaXfdGTDe8lJFN4jfcD9rIZAH1aGFUezBy7jqlw5v5rRTgslEy QKa79mAuUg4JtjlIMqA2Cd9O4H0eYimuU3sPHoqqr7Sd0TIaYQpVanoE4bBhyoPys0TXStafFTN viM7wIkB7TIWMH6KFK9KAUCZBni1gbaY5tcmxRbTy0knQ== X-Received: by 127.0.0.2 with SMTP id SSpLYY7687511xcMlyTgQHWl; Tue, 16 Apr 2024 00:37:20 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.14737.1713253039889889471 for ; Tue, 16 Apr 2024 00:37:20 -0700 X-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 93008339; Tue, 16 Apr 2024 00:37:47 -0700 (PDT) X-Received: from [192.168.1.13] (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C5483F792; Tue, 16 Apr 2024 00:37:17 -0700 (PDT) Message-ID: Date: Tue, 16 Apr 2024 09:37:14 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH 1/1] BaseTool/Ecc: Fix incorrect parsing of variable initialisation To: "levi.yun" , devel@edk2.groups.io Cc: sami.mujawar@arm.com, rebecca@bsdio.com, gaoliming@byosoft.com.cn, bob.c.feng@intel.com, yuwei.chen@intel.com, nd@arm.com References: <20240415185947.160172-1-yeoreum.yun@arm.com> From: "PierreGondois" In-Reply-To: <20240415185947.160172-1-yeoreum.yun@arm.com> 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 Resent-Date: Tue, 16 Apr 2024 00:37:20 -0700 Resent-From: pierre.gondois@arm.com Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: WuZcvvth2p4xpYT0XX9XebXBx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=wukXbJFv; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.9 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none) Tested-by: Pierre Gondois On 4/15/24 20:59, levi.yun wrote: > If a global variable is initialised using a macro with multiple > arguments, ECC incorrectly parses the statement and reports the > macro arguments as variable declarations. >=20 > Example: In the following statement: > STATIC INT WrongVariable =3D MACRO_VERSION(1, 0), NextVariable; > The logic in the ECC function GetIdentifierList() interprets the > above statement as declaration of three variables: > 1. 'WrongVariable =3D MACRO_VERSION(1,' > 2. '0)' > 3. 'NextVariable' > Following which NamingConventionCheckVariableName() reports an > error for "0)" stating an incorrect variable declaration as > below: > "ERROR - *The variable name [0)] does not follow the rules" >=20 > This patch fixes the parsing logic so that scenarios with macro > initialisations are handled correctly. >=20 > Cc: Rebecca Cran > Cc: Liming Gao > Cc: Bob Feng > Cc: Yuwei Chen > Cc: Sami Mujawar > Cc: Pierre Gondois > Signed-off-by: levi.yun > --- >=20 > The changes can be seen at https://github.com/LeviYeoReum/edk2/tree/levi/= 3057_fix_false_on_ecc_v2 >=20 > BaseTools/Source/Python/Ecc/c.py | 23 ++++++++++++++++++-- > 1 file changed, 21 insertions(+), 2 deletions(-) >=20 > diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/E= cc/c.py > index 61ad084fcc5b85b5a2194afd8bb1a4b4b65fdaee..71dc0fcf884ee3d45a527f208= 44b697958df366c 100644 > --- a/BaseTools/Source/Python/Ecc/c.py > +++ b/BaseTools/Source/Python/Ecc/c.py > @@ -182,8 +182,27 @@ def GetIdentifierList(): > continue > =20 > if var.Declarator.find('{') =3D=3D -1: > - for decl in var.Declarator.split(','): > - DeclList =3D decl.split('=3D') > + DeclText =3D var.Declarator > + while (len(DeclText) > 0): > + AllocatorPos =3D DeclText.find('=3D') > + SplitPos =3D DeclText.find(',') > + > + if (SplitPos =3D=3D -1): > + SplitPos =3D len(DeclText) > + elif (SplitPos > AllocatorPos): > + NextAllcatorPos =3D DeclText.find('=3D', AllocatorPo= s + 1) > + if (NextAllcatorPos =3D=3D -1): > + NextAllcatorPos =3D len(DeclText) > + ParPos =3D DeclText.rfind(')', SplitPos, NextAllcato= rPos) > + if (ParPos !=3D -1): > + SplitPos =3D DeclText.find(',', ParPos) > + if (SplitPos =3D=3D -1): > + SplitPos =3D ParPos + 1 > + > + SubDeclText =3D DeclText[:SplitPos] > + DeclText =3D DeclText[SplitPos + 1:] > + > + DeclList =3D SubDeclText.split('=3D') > Name =3D DeclList[0].strip() > if ArrayPattern.match(Name): > LSBPos =3D var.Declarator.find('[') > -- > Guid("CE165669-3EF3-493F-B85D-6190EE5B9759") >=20 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117855): https://edk2.groups.io/g/devel/message/117855 Mute This Topic: https://groups.io/mt/105542888/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-