From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C5A68221EA0DE for ; Thu, 7 Dec 2017 16:48:47 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 16:53:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,375,1508828400"; d="scan'208";a="14121909" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by orsmga001.jf.intel.com with ESMTP; 07 Dec 2017 16:53:20 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 7 Dec 2017 16:53:20 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.218]) with mapi id 14.03.0319.002; Fri, 8 Dec 2017 08:52:57 +0800 From: "Gao, Liming" To: Leif Lindholm , "edk2-devel@lists.01.org" Thread-Topic: [edk2] [PATCH v2] BaseTools: align ERROR/WARNING/RETURN macros with MdePkg versions Thread-Index: AQHTb4IrzNx4woiwLUuoKf2PdncduqM4nrsw Date: Fri, 8 Dec 2017 00:52:56 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E18C4B5@SHSMSX104.ccr.corp.intel.com> References: <20171207173800.26730-1-leif.lindholm@linaro.org> In-Reply-To: <20171207173800.26730-1-leif.lindholm@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2] BaseTools: align ERROR/WARNING/RETURN macros with MdePkg versions X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Dec 2017 00:48:48 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Le= if Lindholm > Sent: Friday, December 8, 2017 1:38 AM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [PATCH v2] BaseTools: align ERROR/WARNING/RETURN macros w= ith MdePkg versions >=20 > BaseTools' BaseTypes.h defined the ENCODE_ERROR macro as > #define ENCODE_ERROR(a) ((RETURN_STATUS)(MAX_BIT | (a))) > whereas MdePkg defines it as > #define ENCODE_ERROR(StatusCode) ((RETURN_STATUS)(MAX_BIT | (StatusC= ode))) >=20 > When building with GCC 6.3 (at least) the former triggers > "error: overflow in implicit constant conversion [-Werror=3Doverflow]" > Resolve this by aligning it with the latter one. >=20 > This also requires aligning the BaseTools typedef of RETURN_STATUS with > the MdePkg one: INTN -> UINTN. >=20 > While at it, update adjacent ENCODE_WARNING and RETURN_ERROR as well. >=20 > Add an explicit initialization of *Alignment to 0 in GenFfs.c > GetAlignmentFromFile to get rid of a warning occuring with GCC after > this change (-Werror=3Dmaybe-uninitialized). >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Leif Lindholm > --- >=20 > v2 updated for ENCODE_WARNING and RETURN_ERROR, as requested > by Liming. >=20 > BaseTools/Source/C/GenFfs/GenFfs.c | 1 + > BaseTools/Source/C/Include/Common/BaseTypes.h | 8 ++++---- > 2 files changed, 5 insertions(+), 4 deletions(-) >=20 > diff --git a/BaseTools/Source/C/GenFfs/GenFfs.c b/BaseTools/Source/C/GenF= fs/GenFfs.c > index e2fb3e0d1e..3b4a9b7761 100644 > --- a/BaseTools/Source/C/GenFfs/GenFfs.c > +++ b/BaseTools/Source/C/GenFfs/GenFfs.c > @@ -529,6 +529,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment) >=20 > InFileHandle =3D NULL; > PeFileBuffer =3D NULL; > + *Alignment =3D 0; >=20 > memset (&ImageContext, 0, sizeof (ImageContext)); >=20 > diff --git a/BaseTools/Source/C/Include/Common/BaseTypes.h b/BaseTools/So= urce/C/Include/Common/BaseTypes.h > index 198647ab95..08b60bae11 100644 > --- a/BaseTools/Source/C/Include/Common/BaseTypes.h > +++ b/BaseTools/Source/C/Include/Common/BaseTypes.h > @@ -170,15 +170,15 @@ > // EFI Error Codes common to all execution phases > // >=20 > -typedef INTN RETURN_STATUS; > +typedef UINTN RETURN_STATUS; >=20 > /// > /// Set the upper bit to indicate EFI Error. > /// > -#define ENCODE_ERROR(a) (MAX_BIT | (a)) > +#define ENCODE_ERROR(a) ((RETURN_STATUS)(MAX_BIT | (a))) >=20 > -#define ENCODE_WARNING(a) (a) > -#define RETURN_ERROR(a) ((a) < 0) > +#define ENCODE_WARNING(a) ((RETURN_STATUS)(a)) > +#define RETURN_ERROR(a) (((INTN)(RETURN_STATUS)(a)) < 0) >=20 > #define RETURN_SUCCESS 0 > #define RETURN_LOAD_ERROR ENCODE_ERROR (1) > -- > 2.11.0 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel