From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::141; helo=mail-it1-x141.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x141.google.com (mail-it1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 81B4521196801 for ; Thu, 29 Nov 2018 07:14:09 -0800 (PST) Received: by mail-it1-x141.google.com with SMTP id h193so4104465ita.5 for ; Thu, 29 Nov 2018 07:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HpNbNuL8vvTPFa6K7o9iIP3+YPMhL+T0VADtcejid9U=; b=KvCa5gDgitb2Ikz6wHVYnpMwFX4jqJCNPierSqPNcR9hRnrFTAtV3NqEFlDsZD/QnY XE9fDgt3Gbigz3TXHL1bBhYYCtSI5AUJxzi17A6cGsn0engCBxLMS9oB1BMxAVmrUxX6 rsOKuQ2SWaf3fUhDAOH93kTUhzSjEc2Xx2RuA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HpNbNuL8vvTPFa6K7o9iIP3+YPMhL+T0VADtcejid9U=; b=cEXbpowqJF/S66jt8f/ZcPdS0dlDwihZykObHI1UrGzzSk9b+tglIeRuxj+60XNXqn SiU6cstot1YU/nztAah+jc8ylcW6KFludVynEkLI/iJkFwwtxHURv9Nf6hW78Q4fw36C OXsac/Wp6cX6r0A8VJsTNGPIMe2WGTRY00C1it856V1L5zn5I5EMmHFtVGw/6ZCFeu+p q3PO8Qsqn2XTUUrkAXs6bDfewLqcZR+h4Oyf9Ra43UsO5YG/aB24r6I54zGwv3bBdwZ1 ijI/xLCqUWrylKD8Z7U1g2eZzPUGrbhb7YPigUYAKRj/9HR1BpS4bxk3SiA7MQa3Ag7y a+UQ== X-Gm-Message-State: AA+aEWbN94iiEkq130KyMDpjhYyGkfRdXOhCwa79e0qRb6C3dONW7n4S 9LhwINgyuxk4MFSlvXsO+gslVwHyP0OpcVm4cQfurA== X-Google-Smtp-Source: AFSGD/X0xDgs8GpNjrAbxFD1Z4s/fi5QKs5w6FTzZL7Be8VkK9algIXgtLdzyakJx3BCOlqUQ0/ZwofZ7HdsbpPqeEk= X-Received: by 2002:a24:edc4:: with SMTP id r187mr2013005ith.158.1543504448599; Thu, 29 Nov 2018 07:14:08 -0800 (PST) MIME-Version: 1.0 References: <20181129123129.25095-1-ard.biesheuvel@linaro.org> <20181129123129.25095-2-ard.biesheuvel@linaro.org> <4A89E2EF3DFEDB4C8BFDE51014F606A14E380C03@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E380C03@SHSMSX104.ccr.corp.intel.com> From: Ard Biesheuvel Date: Thu, 29 Nov 2018 16:13:57 +0100 Message-ID: To: "Gao, Liming" Cc: "edk2-devel@lists.01.org" , Laszlo Ersek , "Zhu, Yonghong" , "Feng, Bob C" 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:14:09 -0000 Content-Type: text/plain; charset="UTF-8" On Thu, 29 Nov 2018 at 16:11, Gao, Liming wrote: > > 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 'UINTN *' to 'UINT64 *' > NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe"' : return code '0x2' > Apologies, i missed this change at line 1624 - UINTN Uint64; + UINT64 Uint64; It builds fine with GCC though. > Below > + UINTN Uint64; ==> > + 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 > > > > 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. > > > > So update StrToIpv4Address() and StrToIpv6Address() to use UINT64 > > types instead of UINTN types when parsing strings. > > > > 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(-) > > > > diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/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 = StrDecimalToUintnS ((CONST CHAR16 *) Pointer, &Pointer, &Uintn); > > + Status = 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 = (UINT8) Uintn; > > + LocalPrefixLength = (UINT8) Uint64; > > } else { > > // > > // It's D. > > // > > - if (Uintn > MAX_UINT8) { > > + if (Uint64 > MAX_UINT8) { > > return RETURN_UNSUPPORTED; > > } > > - LocalAddress.Addr[AddressIndex] = (UINT8) Uintn; > > + LocalAddress.Addr[AddressIndex] = (UINT8) Uint64; > > AddressIndex++; > > } > > > > @@ -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 = StrHexToUintnS (Pointer, &End, &Uintn); > > + Status = 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 = 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] = (UINT8) ((UINT16) Uintn >> 8); > > - LocalAddress.Addr[AddressIndex + 1] = (UINT8) Uintn; > > + LocalAddress.Addr[AddressIndex] = (UINT8) ((UINT16) Uint64 >> 8); > > + LocalAddress.Addr[AddressIndex + 1] = (UINT8) Uint64; > > AddressIndex += 2; > > } else { > > // > > // Get P, then exit the loop. > > // > > - Status = StrDecimalToUintnS (Pointer, &End, &Uintn); > > - if (RETURN_ERROR (Status) || End == Pointer || Uintn > 128) { > > + Status = StrDecimalToUint64S (Pointer, &End, &Uint64); > > + if (RETURN_ERROR (Status) || End == Pointer || Uint64 > 128) { > > // > > // Prefix length should not exceed 128. > > // > > return RETURN_UNSUPPORTED; > > } > > - LocalPrefixLength = (UINT8) Uintn; > > + LocalPrefixLength = (UINT8) Uint64; > > Pointer = End; > > break; > > } > > -- > > 2.19.1 >