diff mbox series

[edk2,v2,3/6] BaseTools/DevicePath: use explicit 64-bit number parsing routines

Message ID 20181130224537.18936-4-ard.biesheuvel@linaro.org
State Accepted
Commit 6e2d15e3c4ab24ce94a36aab5e2b67715d42f958
Headers show
Series BaseTools: get rid of MAX_UINTN | expand

Commit Message

Ard Biesheuvel Nov. 30, 2018, 10:45 p.m. UTC
Replace invocations of StrHexToUintn() with StrHexToUint64(), so
that we can drop the former.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

---
 BaseTools/Source/C/DevicePath/DevicePathFromText.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.19.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Philippe Mathieu-Daudé Dec. 3, 2018, 10:25 a.m. UTC | #1
On 30/11/18 23:45, Ard Biesheuvel wrote:
> Replace invocations of StrHexToUintn() with StrHexToUint64(), so
> that we can drop the former.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  BaseTools/Source/C/DevicePath/DevicePathFromText.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> index 555efa1acdde..6151926af9aa 100644
> --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
> @@ -520,7 +520,7 @@ EisaIdFromText (
>    return (((Text[0] - 'A' + 1) & 0x1f) << 10)
>         + (((Text[1] - 'A' + 1) & 0x1f) <<  5)
>         + (((Text[2] - 'A' + 1) & 0x1f) <<  0)
> -       + (UINT32) (StrHexToUintn (&Text[3]) << 16)
> +       + (UINT32) (StrHexToUint64 (&Text[3]) << 16)
>         ;
>  }
>  
> @@ -1506,7 +1506,7 @@ DevPathFromTextNVMe (
>  
>    Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
>    while (Index-- != 0) {
> -    Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));
> +    Uuid[Index] = (UINT8) StrHexToUint64 (SplitStr (&NamespaceUuidStr, L'-'));
>    }
>  
>    return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;
>
Laszlo Ersek Dec. 3, 2018, 12:55 p.m. UTC | #2
On 11/30/18 23:45, Ard Biesheuvel wrote:
> Replace invocations of StrHexToUintn() with StrHexToUint64(), so

> that we can drop the former.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> ---

>  BaseTools/Source/C/DevicePath/DevicePathFromText.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c

> index 555efa1acdde..6151926af9aa 100644

> --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c

> +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c

> @@ -520,7 +520,7 @@ EisaIdFromText (

>    return (((Text[0] - 'A' + 1) & 0x1f) << 10)

>         + (((Text[1] - 'A' + 1) & 0x1f) <<  5)

>         + (((Text[2] - 'A' + 1) & 0x1f) <<  0)

> -       + (UINT32) (StrHexToUintn (&Text[3]) << 16)

> +       + (UINT32) (StrHexToUint64 (&Text[3]) << 16)

>         ;

>  }

>  


This (theoretically) introduces a bit-shift on a UINT64 value, which
might result in a compiler intrinsic call on 32-bit build hosts. But
that's fine, because this is not firmware code, but hosted code.

> @@ -1506,7 +1506,7 @@ DevPathFromTextNVMe (

>  

>    Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);

>    while (Index-- != 0) {

> -    Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));

> +    Uuid[Index] = (UINT8) StrHexToUint64 (SplitStr (&NamespaceUuidStr, L'-'));

>    }

>  

>    return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;

> 


Reviewed-by: Laszlo Ersek <lersek@redhat.com>


Thanks
Laszlo
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox series

Patch

diff --git a/BaseTools/Source/C/DevicePath/DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
index 555efa1acdde..6151926af9aa 100644
--- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c
+++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c
@@ -520,7 +520,7 @@  EisaIdFromText (
   return (((Text[0] - 'A' + 1) & 0x1f) << 10)
        + (((Text[1] - 'A' + 1) & 0x1f) <<  5)
        + (((Text[2] - 'A' + 1) & 0x1f) <<  0)
-       + (UINT32) (StrHexToUintn (&Text[3]) << 16)
+       + (UINT32) (StrHexToUint64 (&Text[3]) << 16)
        ;
 }
 
@@ -1506,7 +1506,7 @@  DevPathFromTextNVMe (
 
   Index = sizeof (Nvme->NamespaceUuid) / sizeof (UINT8);
   while (Index-- != 0) {
-    Uuid[Index] = (UINT8) StrHexToUintn (SplitStr (&NamespaceUuidStr, L'-'));
+    Uuid[Index] = (UINT8) StrHexToUint64 (SplitStr (&NamespaceUuidStr, L'-'));
   }
 
   return (EFI_DEVICE_PATH_PROTOCOL *) Nvme;