From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 378D921196801 for ; Thu, 29 Nov 2018 07:11:17 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2018 07:11:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,295,1539673200"; d="scan'208";a="97799439" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 29 Nov 2018 07:11:10 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 29 Nov 2018 07:11:08 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 29 Nov 2018 07:11:07 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.203]) by shsmsx102.ccr.corp.intel.com ([169.254.2.182]) with mapi id 14.03.0415.000; Thu, 29 Nov 2018 23:11:05 +0800 From: "Gao, Liming" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: Laszlo Ersek , "Zhu, Yonghong" , "Feng, Bob C" Thread-Topic: [PATCH 1/6] BaseTools/CommonLib: avoid using 'native' word size in IP address handling Thread-Index: AQHUh998Ih91k0p+GEawE1FGmnf3VaVm22pw Date: Thu, 29 Nov 2018 15:11:05 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E380C03@SHSMSX104.ccr.corp.intel.com> References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> <20181129123129.25095-2-ard.biesheuvel@linaro.org> In-Reply-To: <20181129123129.25095-2-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGE1ZGZkZjEtZGY5Yi00MDUzLWJjNTktYWQxMjcyNDEzNDU0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiTmJZVlwvK3d2MkxtQm81VERHQlpEa0JoY1V1aUx4U2pFYnNXeVFHTkRRN3g1WFIyTVdPdzU5U3ZvN0k5U2Y3Z2YifQ== dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/6] BaseTools/CommonLib: avoid using 'native' word size in IP address handling X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2018 15:11:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ard: I mean the build error. Besides, what test have you done with this patch = set? CommonLib.c(1651): error C2220: warning treated as error - no 'object' file= generated CommonLib.c(1651): warning C4133: 'function': incompatible types - from 'UI= NTN *' to 'UINT64 *' NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio= 14.0\VC\BIN\cl.exe"' : return code '0x2' Below > + UINTN Uint64; =3D=3D> > + UINT64 = Uint64; > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Thursday, November 29, 2018 8:31 PM > To: edk2-devel@lists.01.org > Cc: Ard Biesheuvel ; Laszlo Ersek ; Zhu, Yonghong ; Gao, > Liming ; Feng, Bob C > Subject: [PATCH 1/6] BaseTools/CommonLib: avoid using 'native' word size = in IP address handling >=20 > In the context of the BaseTools, there is no such thing as a native word > size, given that the same set of tools may be used to build a firmware > image consisting of both 32-bit and 64-bit modules. >=20 > So update StrToIpv4Address() and StrToIpv6Address() to use UINT64 > types instead of UINTN types when parsing strings. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > BaseTools/Source/C/Common/CommonLib.c | 28 ++++++++++---------- > 1 file changed, 14 insertions(+), 14 deletions(-) >=20 > diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/C= ommon/CommonLib.c > index 618aadac781a..bea6af0a45b1 100644 > --- a/BaseTools/Source/C/Common/CommonLib.c > +++ b/BaseTools/Source/C/Common/CommonLib.c > @@ -1785,7 +1785,7 @@ StrToIpv4Address ( > { > RETURN_STATUS Status; > UINTN AddressIndex; > - UINTN Uintn; > + UINTN Uint64; > EFI_IPv4_ADDRESS LocalAddress; > UINT8 LocalPrefixLength; > CHAR16 *Pointer; > @@ -1812,7 +1812,7 @@ StrToIpv4Address ( > // > // Get D or P. > // > - Status =3D StrDecimalToUintnS ((CONST CHAR16 *) Pointer, &Pointer, &= Uintn); > + Status =3D StrDecimalToUint64S ((CONST CHAR16 *) Pointer, &Pointer, = &Uint64); > if (RETURN_ERROR (Status)) { > return RETURN_UNSUPPORTED; > } > @@ -1820,18 +1820,18 @@ StrToIpv4Address ( > // > // It's P. > // > - if (Uintn > 32) { > + if (Uint64 > 32) { > return RETURN_UNSUPPORTED; > } > - LocalPrefixLength =3D (UINT8) Uintn; > + LocalPrefixLength =3D (UINT8) Uint64; > } else { > // > // It's D. > // > - if (Uintn > MAX_UINT8) { > + if (Uint64 > MAX_UINT8) { > return RETURN_UNSUPPORTED; > } > - LocalAddress.Addr[AddressIndex] =3D (UINT8) Uintn; > + LocalAddress.Addr[AddressIndex] =3D (UINT8) Uint64; > AddressIndex++; > } >=20 > @@ -1888,7 +1888,7 @@ StrToIpv6Address ( > { > RETURN_STATUS Status; > UINTN AddressIndex; > - UINTN Uintn; > + UINT64 Uint64; > EFI_IPv6_ADDRESS LocalAddress; > UINT8 LocalPrefixLength; > CONST CHAR16 *Pointer; > @@ -1969,7 +1969,7 @@ StrToIpv6Address ( > // > // Get X. > // > - Status =3D StrHexToUintnS (Pointer, &End, &Uintn); > + Status =3D StrHexToUint64S (Pointer, &End, &Uint64); > if (RETURN_ERROR (Status) || End - Pointer > 4) { > // > // Number of hexadecimal digit characters is no more than 4. > @@ -1978,24 +1978,24 @@ StrToIpv6Address ( > } > Pointer =3D End; > // > - // Uintn won't exceed MAX_UINT16 if number of hexadecimal digit = characters is no more than 4. > + // Uint64 won't exceed MAX_UINT16 if number of hexadecimal digit= characters is no more than 4. > // > ASSERT (AddressIndex + 1 < ARRAY_SIZE (Address->Addr)); > - LocalAddress.Addr[AddressIndex] =3D (UINT8) ((UINT16) Uintn >> 8= ); > - LocalAddress.Addr[AddressIndex + 1] =3D (UINT8) Uintn; > + LocalAddress.Addr[AddressIndex] =3D (UINT8) ((UINT16) Uint64 >> = 8); > + LocalAddress.Addr[AddressIndex + 1] =3D (UINT8) Uint64; > AddressIndex +=3D 2; > } else { > // > // Get P, then exit the loop. > // > - Status =3D StrDecimalToUintnS (Pointer, &End, &Uintn); > - if (RETURN_ERROR (Status) || End =3D=3D Pointer || Uintn > 128) = { > + Status =3D StrDecimalToUint64S (Pointer, &End, &Uint64); > + if (RETURN_ERROR (Status) || End =3D=3D Pointer || Uint64 > 128)= { > // > // Prefix length should not exceed 128. > // > return RETURN_UNSUPPORTED; > } > - LocalPrefixLength =3D (UINT8) Uintn; > + LocalPrefixLength =3D (UINT8) Uint64; > Pointer =3D End; > break; > } > -- > 2.19.1