public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit
@ 2024-11-03 22:42 Heinrich Schuchardt
  2024-11-03 22:42 ` [PATCH v2 1/4] lib: provide function hextoull() Heinrich Schuchardt
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2024-11-03 22:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot, Heinrich Schuchardt

The lib_test_uuid_to_le and lib lib_test_dynamic_uuid tests fail on
32-bit systems. But we never caught this in our CI because we never
ran any of our C unit tests on 32-bit.

Enable CONFIG_UNIT_TEST on qemu_arm_defconfig.

hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
Use the new function hextoull() instead.

v2:
	fix uuid_str_to_bin() too

Heinrich Schuchardt (4):
  lib: provide function hextoull()
  lib: uuid: fix uuid_str_to_le_bin() on 32-bit
  lib: uuid: fix uuid_str_to_bin() on 32-bit
  configs: enable UNIT_TEST on qemu_arm_defconfig

 configs/qemu_arm_defconfig |  1 +
 include/vsprintf.h         | 13 +++++++++++++
 lib/strto.c                |  5 +++++
 lib/uuid.c                 |  5 +++--
 4 files changed, 22 insertions(+), 2 deletions(-)

-- 
2.45.2


^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-03 22:42 [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
@ 2024-11-03 22:42 ` Heinrich Schuchardt
  2024-11-07  9:45   ` Ilias Apalodimas
                     ` (2 more replies)
  2024-11-03 22:42 ` [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2024-11-03 22:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot, Heinrich Schuchardt

We often convert hexadecimal strings to hextoull(). Provide a wrapper
function to simple_strtoull() that does not require specifying the radix.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	no change
---
 include/vsprintf.h | 13 +++++++++++++
 lib/strto.c        |  5 +++++
 2 files changed, 18 insertions(+)

diff --git a/include/vsprintf.h b/include/vsprintf.h
index fe951471426..9da6ce7cc4d 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -44,6 +44,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
  */
 unsigned long hextoul(const char *cp, char **endp);
 
+/**
+ * hex_strtoull - convert a string in hex to an unsigned long long
+ *
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
+ * Return: value decoded from string (0 if invalid)
+ *
+ * Converts a hex string to an unsigned long long. If there are invalid
+ * characters at the end these are ignored. In the worst case, if all characters
+ * are invalid, 0 is returned
+ */
+unsigned long long hextoull(const char *cp, char **endp);
+
 /**
  * dec_strtoul - convert a string in decimal to an unsigned long
  *
diff --git a/lib/strto.c b/lib/strto.c
index f83ac67c666..206d1e91847 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -78,6 +78,11 @@ ulong hextoul(const char *cp, char **endp)
 	return simple_strtoul(cp, endp, 16);
 }
 
+unsigned long long hextoull(const char *cp, char **endp)
+{
+	return simple_strtoull(cp, endp, 16);
+}
+
 ulong dectoul(const char *cp, char **endp)
 {
 	return simple_strtoul(cp, endp, 10);
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit
  2024-11-03 22:42 [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
  2024-11-03 22:42 ` [PATCH v2 1/4] lib: provide function hextoull() Heinrich Schuchardt
@ 2024-11-03 22:42 ` Heinrich Schuchardt
  2024-11-06 10:42   ` Caleb Connolly
                     ` (2 more replies)
  2024-11-03 22:42 ` [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() " Heinrich Schuchardt
                   ` (2 subsequent siblings)
  4 siblings, 3 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2024-11-03 22:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot, Heinrich Schuchardt,
	Patrick Delaunay

hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
Use function hextoull() instead.

Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	no change
---
 lib/uuid.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/uuid.c b/lib/uuid.c
index c6a27b7d044..19f33dd1477 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -35,6 +35,7 @@
 #ifdef USE_HOSTCC
 /* polyfill hextoul to avoid pulling in strto.c */
 #define hextoul(cp, endp) strtoul(cp, endp, 16)
+#define hextoull(cp, endp) strtoull(cp, endp, 16)
 #endif

 int uuid_str_valid(const char *uuid)
@@ -339,7 +340,7 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
 	tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
 	memcpy(uuid_bin + 8, &tmp16, 2);
 
-	tmp64 = cpu_to_le64(hextoul(uuid_str + 24, NULL));
+	tmp64 = cpu_to_le64(hextoull(uuid_str + 24, NULL));
 	memcpy(uuid_bin + 10, &tmp64, 6);
 
 	return 0;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() on 32-bit
  2024-11-03 22:42 [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
  2024-11-03 22:42 ` [PATCH v2 1/4] lib: provide function hextoull() Heinrich Schuchardt
  2024-11-03 22:42 ` [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
@ 2024-11-03 22:42 ` Heinrich Schuchardt
  2024-11-06 10:42   ` Caleb Connolly
                     ` (2 more replies)
  2024-11-03 22:42 ` [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig Heinrich Schuchardt
  2024-11-13 17:40 ` [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Tom Rini
  4 siblings, 3 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2024-11-03 22:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot, Heinrich Schuchardt,
	Patrick Delaunay

hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
Use function hextoull() instead.

Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	new patch
---
 lib/uuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/uuid.c b/lib/uuid.c
index 19f33dd1477..538a1ba6aa8 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -313,7 +313,7 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
 	tmp16 = cpu_to_be16(hextoul(uuid_str + 19, NULL));
 	memcpy(uuid_bin + 8, &tmp16, 2);
 
-	tmp64 = cpu_to_be64(hextoul(uuid_str + 24, NULL));
+	tmp64 = cpu_to_be64(hextoull(uuid_str + 24, NULL));
 	memcpy(uuid_bin + 10, (char *)&tmp64 + 2, 6);
 
 	return 0;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig
  2024-11-03 22:42 [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
                   ` (2 preceding siblings ...)
  2024-11-03 22:42 ` [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() " Heinrich Schuchardt
@ 2024-11-03 22:42 ` Heinrich Schuchardt
  2024-11-03 22:46   ` Tom Rini
                     ` (2 more replies)
  2024-11-13 17:40 ` [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Tom Rini
  4 siblings, 3 replies; 22+ messages in thread
From: Heinrich Schuchardt @ 2024-11-03 22:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot, Heinrich Schuchardt

The lib_test_uuid_to_le test fails on 32-bit systems. But we never caught
this in our CI because we never ran any of our C unit tests on 32-bit.

Enable CONFIG_UNIT_TEST on qemu_arm_defconfig.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
v2:
	no change
---
 configs/qemu_arm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
index d042aea49bb..cc4f4540fd5 100644
--- a/configs/qemu_arm_defconfig
+++ b/configs/qemu_arm_defconfig
@@ -67,3 +67,4 @@ CONFIG_TPM2_MMIO=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_PCI=y
 CONFIG_TPM=y
+CONFIG_UNIT_TEST=y
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig
  2024-11-03 22:42 ` [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig Heinrich Schuchardt
@ 2024-11-03 22:46   ` Tom Rini
  2024-11-07  9:52   ` Ilias Apalodimas
  2024-11-12 11:00   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2024-11-03 22:46 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot

[-- Attachment #1: Type: text/plain, Size: 413 bytes --]

On Sun, Nov 03, 2024 at 11:42:23PM +0100, Heinrich Schuchardt wrote:

> The lib_test_uuid_to_le test fails on 32-bit systems. But we never caught
> this in our CI because we never ran any of our C unit tests on 32-bit.
> 
> Enable CONFIG_UNIT_TEST on qemu_arm_defconfig.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Tom Rini <trini@konsulko.com>

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit
  2024-11-03 22:42 ` [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
@ 2024-11-06 10:42   ` Caleb Connolly
  2024-11-11 12:34   ` Ilias Apalodimas
  2024-11-12 10:51   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Caleb Connolly @ 2024-11-06 10:42 UTC (permalink / raw)
  To: Heinrich Schuchardt, Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Marek Vasut, u-boot, Patrick Delaunay

Hi Heinrich,

Thanks a lot for figuring this out.

On 03/11/2024 23:42, Heinrich Schuchardt wrote:
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
> 
> Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>

> ---
> v2:
> 	no change
> ---
>   lib/uuid.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/uuid.c b/lib/uuid.c
> index c6a27b7d044..19f33dd1477 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -35,6 +35,7 @@
>   #ifdef USE_HOSTCC
>   /* polyfill hextoul to avoid pulling in strto.c */
>   #define hextoul(cp, endp) strtoul(cp, endp, 16)
> +#define hextoull(cp, endp) strtoull(cp, endp, 16)
>   #endif
> 
>   int uuid_str_valid(const char *uuid)
> @@ -339,7 +340,7 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
>   	tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
>   	memcpy(uuid_bin + 8, &tmp16, 2);
>   
> -	tmp64 = cpu_to_le64(hextoul(uuid_str + 24, NULL));
> +	tmp64 = cpu_to_le64(hextoull(uuid_str + 24, NULL));
>   	memcpy(uuid_bin + 10, &tmp64, 6);
>   
>   	return 0;

-- 
// Caleb (they/them)


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() on 32-bit
  2024-11-03 22:42 ` [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() " Heinrich Schuchardt
@ 2024-11-06 10:42   ` Caleb Connolly
  2024-11-11 12:33   ` Ilias Apalodimas
  2024-11-12 10:52   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Caleb Connolly @ 2024-11-06 10:42 UTC (permalink / raw)
  To: Heinrich Schuchardt, Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Marek Vasut, u-boot, Patrick Delaunay



On 03/11/2024 23:42, Heinrich Schuchardt wrote:
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
> 
> Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Caleb Connolly <caleb.connolly@linaro.org>

> ---
> v2:
> 	new patch
> ---
>   lib/uuid.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 19f33dd1477..538a1ba6aa8 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -313,7 +313,7 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
>   	tmp16 = cpu_to_be16(hextoul(uuid_str + 19, NULL));
>   	memcpy(uuid_bin + 8, &tmp16, 2);
>   
> -	tmp64 = cpu_to_be64(hextoul(uuid_str + 24, NULL));
> +	tmp64 = cpu_to_be64(hextoull(uuid_str + 24, NULL));
>   	memcpy(uuid_bin + 10, (char *)&tmp64 + 2, 6);
>   
>   	return 0;

-- 
// Caleb (they/them)


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-03 22:42 ` [PATCH v2 1/4] lib: provide function hextoull() Heinrich Schuchardt
@ 2024-11-07  9:45   ` Ilias Apalodimas
  2024-11-07 10:51     ` Marek Vasut
  2024-11-12 11:00   ` Patrick DELAUNAY
  2024-11-13 13:39   ` Simon Glass
  2 siblings, 1 reply; 22+ messages in thread
From: Ilias Apalodimas @ 2024-11-07  9:45 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tom Rini, Tuomas Tynkkynen, Raymond Mao, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot

On Sun, 3 Nov 2024 at 22:42, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> We often convert hexadecimal strings to hextoull(). Provide a wrapper
> function to simple_strtoull() that does not require specifying the radix.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         no change
> ---
>  include/vsprintf.h | 13 +++++++++++++
>  lib/strto.c        |  5 +++++
>  2 files changed, 18 insertions(+)
>
> diff --git a/include/vsprintf.h b/include/vsprintf.h
> index fe951471426..9da6ce7cc4d 100644
> --- a/include/vsprintf.h
> +++ b/include/vsprintf.h
> @@ -44,6 +44,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
>   */
>  unsigned long hextoul(const char *cp, char **endp);
>
> +/**
> + * hex_strtoull - convert a string in hex to an unsigned long long
> + *
> + * @cp: The string to be converted
> + * @endp: Updated to point to the first character not converted
> + * Return: value decoded from string (0 if invalid)
> + *
> + * Converts a hex string to an unsigned long long. If there are invalid
> + * characters at the end these are ignored. In the worst case, if all characters
> + * are invalid, 0 is returned
> + */
> +unsigned long long hextoull(const char *cp, char **endp);
> +
>  /**
>   * dec_strtoul - convert a string in decimal to an unsigned long
>   *
> diff --git a/lib/strto.c b/lib/strto.c
> index f83ac67c666..206d1e91847 100644
> --- a/lib/strto.c
> +++ b/lib/strto.c
> @@ -78,6 +78,11 @@ ulong hextoul(const char *cp, char **endp)
>         return simple_strtoul(cp, endp, 16);
>  }
>
> +unsigned long long hextoull(const char *cp, char **endp)
> +{
> +       return simple_strtoull(cp, endp, 16);
> +}
> +
>  ulong dectoul(const char *cp, char **endp)
>  {
>         return simple_strtoul(cp, endp, 10);
> --
> 2.45.2
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig
  2024-11-03 22:42 ` [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig Heinrich Schuchardt
  2024-11-03 22:46   ` Tom Rini
@ 2024-11-07  9:52   ` Ilias Apalodimas
  2024-11-12 11:00   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Ilias Apalodimas @ 2024-11-07  9:52 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tom Rini, Tuomas Tynkkynen, Raymond Mao, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot

On Sun, 3 Nov 2024 at 22:42, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> The lib_test_uuid_to_le test fails on 32-bit systems. But we never caught
> this in our CI because we never ran any of our C unit tests on 32-bit.
>
> Enable CONFIG_UNIT_TEST on qemu_arm_defconfig.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         no change
> ---
>  configs/qemu_arm_defconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
> index d042aea49bb..cc4f4540fd5 100644
> --- a/configs/qemu_arm_defconfig
> +++ b/configs/qemu_arm_defconfig
> @@ -67,3 +67,4 @@ CONFIG_TPM2_MMIO=y
>  CONFIG_USB_EHCI_HCD=y
>  CONFIG_USB_EHCI_PCI=y
>  CONFIG_TPM=y
> +CONFIG_UNIT_TEST=y
> --
> 2.45.2
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-07  9:45   ` Ilias Apalodimas
@ 2024-11-07 10:51     ` Marek Vasut
  0 siblings, 0 replies; 22+ messages in thread
From: Marek Vasut @ 2024-11-07 10:51 UTC (permalink / raw)
  To: Ilias Apalodimas, Heinrich Schuchardt, Jaehoon Chung
  Cc: Tom Rini, Tuomas Tynkkynen, Raymond Mao, Simon Glass,
	Caleb Connolly, u-boot

On 11/7/24 10:45 AM, Ilias Apalodimas wrote:
> On Sun, 3 Nov 2024 at 22:42, Heinrich Schuchardt
> <heinrich.schuchardt@canonical.com> wrote:
>>
>> We often convert hexadecimal strings to hextoull(). Provide a wrapper
>> function to simple_strtoull() that does not require specifying the radix.
>>
>> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
>> ---
>> v2:
>>          no change
>> ---
>>   include/vsprintf.h | 13 +++++++++++++
>>   lib/strto.c        |  5 +++++
>>   2 files changed, 18 insertions(+)
>>
>> diff --git a/include/vsprintf.h b/include/vsprintf.h
>> index fe951471426..9da6ce7cc4d 100644
>> --- a/include/vsprintf.h
>> +++ b/include/vsprintf.h
>> @@ -44,6 +44,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
>>    */
>>   unsigned long hextoul(const char *cp, char **endp);
>>
>> +/**
>> + * hex_strtoull - convert a string in hex to an unsigned long long
>> + *
>> + * @cp: The string to be converted
>> + * @endp: Updated to point to the first character not converted
>> + * Return: value decoded from string (0 if invalid)
>> + *
>> + * Converts a hex string to an unsigned long long. If there are invalid
>> + * characters at the end these are ignored. In the worst case, if all characters
>> + * are invalid, 0 is returned
>> + */
>> +unsigned long long hextoull(const char *cp, char **endp);
>> +
>>   /**
>>    * dec_strtoul - convert a string in decimal to an unsigned long
>>    *
>> diff --git a/lib/strto.c b/lib/strto.c
>> index f83ac67c666..206d1e91847 100644
>> --- a/lib/strto.c
>> +++ b/lib/strto.c
>> @@ -78,6 +78,11 @@ ulong hextoul(const char *cp, char **endp)
>>          return simple_strtoul(cp, endp, 16);
>>   }
>>
>> +unsigned long long hextoull(const char *cp, char **endp)
>> +{
>> +       return simple_strtoull(cp, endp, 16);
>> +}
>> +
>>   ulong dectoul(const char *cp, char **endp)
>>   {
>>          return simple_strtoul(cp, endp, 10);
>> --
>> 2.45.2
>>
> 
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

+CC Jaehoon

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() on 32-bit
  2024-11-03 22:42 ` [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() " Heinrich Schuchardt
  2024-11-06 10:42   ` Caleb Connolly
@ 2024-11-11 12:33   ` Ilias Apalodimas
  2024-11-12 10:52   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Ilias Apalodimas @ 2024-11-11 12:33 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tom Rini, Tuomas Tynkkynen, Raymond Mao, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot, Patrick Delaunay

On Mon, 4 Nov 2024 at 00:42, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
>
> Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         new patch
> ---
>  lib/uuid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 19f33dd1477..538a1ba6aa8 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -313,7 +313,7 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
>         tmp16 = cpu_to_be16(hextoul(uuid_str + 19, NULL));
>         memcpy(uuid_bin + 8, &tmp16, 2);
>
> -       tmp64 = cpu_to_be64(hextoul(uuid_str + 24, NULL));
> +       tmp64 = cpu_to_be64(hextoull(uuid_str + 24, NULL));
>         memcpy(uuid_bin + 10, (char *)&tmp64 + 2, 6);
>
>         return 0;
> --
> 2.45.2
>

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit
  2024-11-03 22:42 ` [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
  2024-11-06 10:42   ` Caleb Connolly
@ 2024-11-11 12:34   ` Ilias Apalodimas
  2024-11-12 10:51   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Ilias Apalodimas @ 2024-11-11 12:34 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tom Rini, Tuomas Tynkkynen, Raymond Mao, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot, Patrick Delaunay

On Mon, 4 Nov 2024 at 00:42, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
>
> Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         no change
> ---
>  lib/uuid.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/uuid.c b/lib/uuid.c
> index c6a27b7d044..19f33dd1477 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -35,6 +35,7 @@
>  #ifdef USE_HOSTCC
>  /* polyfill hextoul to avoid pulling in strto.c */
>  #define hextoul(cp, endp) strtoul(cp, endp, 16)
> +#define hextoull(cp, endp) strtoull(cp, endp, 16)
>  #endif
>
>  int uuid_str_valid(const char *uuid)
> @@ -339,7 +340,7 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
>         tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
>         memcpy(uuid_bin + 8, &tmp16, 2);
>
> -       tmp64 = cpu_to_le64(hextoul(uuid_str + 24, NULL));
> +       tmp64 = cpu_to_le64(hextoull(uuid_str + 24, NULL));
>         memcpy(uuid_bin + 10, &tmp64, 6);
>
>         return 0;
> --
> 2.45.2
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit
  2024-11-03 22:42 ` [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
  2024-11-06 10:42   ` Caleb Connolly
  2024-11-11 12:34   ` Ilias Apalodimas
@ 2024-11-12 10:51   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Patrick DELAUNAY @ 2024-11-12 10:51 UTC (permalink / raw)
  To: Heinrich Schuchardt, Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot

Hi,

On 11/3/24 23:42, Heinrich Schuchardt wrote:
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
>
> Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	no change
> ---
>   lib/uuid.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/uuid.c b/lib/uuid.c
> index c6a27b7d044..19f33dd1477 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -35,6 +35,7 @@
>   #ifdef USE_HOSTCC
>   /* polyfill hextoul to avoid pulling in strto.c */
>   #define hextoul(cp, endp) strtoul(cp, endp, 16)
> +#define hextoull(cp, endp) strtoull(cp, endp, 16)
>   #endif
>
>   int uuid_str_valid(const char *uuid)
> @@ -339,7 +340,7 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
>   	tmp16 = cpu_to_le16(hextoul(uuid_str + 19, NULL));
>   	memcpy(uuid_bin + 8, &tmp16, 2);
>   
> -	tmp64 = cpu_to_le64(hextoul(uuid_str + 24, NULL));
> +	tmp64 = cpu_to_le64(hextoull(uuid_str + 24, NULL));
>   	memcpy(uuid_bin + 10, &tmp64, 6);
>   
>   	return 0;


Tested-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>


Thanks.
Patrick


With the series the regression is solved on STM32MP15 board.


tested  on STM32MP15C-DK2 / 2025.01-rc2


the GPT partitions create with GPT common, create with stm32prog 
command,  are

limited a first bytes, after the patch we have the correct UUID 
(partition or type):


before the patch:


STM32MP>partlistmmc0
PartitionMapformmcdevice0--PartitionType:EFI
PartStartLBAEndLBAName
Attributes
TypeGUID
PartitionGUID
10x000000220x00000221"fsbl1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:4a75790f-e291-441b-9637-0000165411b2
20x000002220x00000421"fsbl2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:7a1e006d-bd4a-42b7-a725-000012451e59
30x000004220x00000621"metadata1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:2ead27e5-8fc8-4e00-a0c8-00005d7a437c
40x000006220x00000821"metadata2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:2d2536b7-6420-4401-90b0-0000831b3a72
50x000008220x00002821"fip-a"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-0000c13142a5
(19d5df83-11b0-457b-be2c-0000c13142a5)
guid:4fd84c93-54ef-463f-a7ef-0000ff887087
60x000028220x00004821"fip-b"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-0000c13142a5
(19d5df83-11b0-457b-be2c-0000c13142a5)
guid:09c54952-d5bf-45af-acee-000003766fb3
70x000048220x00004c21"u-boot-env"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-0000c8230908
(8da63339-0007-60c0-c436-0000c8230908)
guid:514446c6-d705-40d7-aa4b-0000a95a0379
80x00004c220x00024c21"bootfs"
attrs:0x0000000000000004
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:22e8efa0-375c-4be0-99ce-00000172479f
90x00024c220x0002cc21"vendorfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:e1e3f6f9-a4f5-4094-9622-000042c3bcd7
100x0002cc220x0019cc21"rootfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:e91c4e10-16e6-4c0e-bd0e-0000cf4a3582
110x0019cc220x0ee2afdc"userfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:3d14d2bf-7798-4c57-865a-00007ac4cd0c
==================
after the series :
==================
STM32MP>partlistmmc0
PartitionMapformmcdevice0--PartitionType:EFI
PartStartLBAEndLBAName
Attributes
TypeGUID
PartitionGUID
10x000000220x00000221"fsbl1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:bcf89b85-baba-4cab-b776-27b7e3eade64
20x000002220x00000421"fsbl2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:0b5c4320-aa24-4133-a08b-99f59ec2405b
30x000004220x00000621"metadata1"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:264a01cf-84d9-4a2e-810f-86cc3617aba0
40x000006220x00000821"metadata2"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:187a929a-f00e-436f-a635-8ccbf2a532e8
50x000008220x00002821"fip-a"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-7559c13142a5
(19d5df83-11b0-457b-be2c-7559c13142a5)
guid:4fd84c93-54ef-463f-a7ef-ae25ff887087
60x000028220x00004821"fip-b"
attrs:0x0000000000000000
type:19d5df83-11b0-457b-be2c-7559c13142a5
(19d5df83-11b0-457b-be2c-7559c13142a5)
guid:09c54952-d5bf-45af-acee-335303766fb3
70x000048220x00004c21"u-boot-env"
attrs:0x0000000000000000
type:8da63339-0007-60c0-c436-083ac8230908
(8da63339-0007-60c0-c436-083ac8230908)
guid:2667f0f0-acfc-4f7e-81b8-5da24fc7efbe
80x00004c220x00024c21"bootfs"
attrs:0x0000000000000004
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:9fedf49a-bcc9-46ef-b40c-bbe42e138c23
90x00024c220x0002cc21"vendorfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:d0633872-d1c2-49b6-b81a-2744c4617148
100x0002cc220x0019cc21"rootfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:e91c4e10-16e6-4c0e-bd0e-77becf4a3582
110x0019cc220x0ee2afdc"userfs"
attrs:0x0000000000000000
type:0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid:8e049511-8c1d-4791-bf37-f2365101a073



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() on 32-bit
  2024-11-03 22:42 ` [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() " Heinrich Schuchardt
  2024-11-06 10:42   ` Caleb Connolly
  2024-11-11 12:33   ` Ilias Apalodimas
@ 2024-11-12 10:52   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Patrick DELAUNAY @ 2024-11-12 10:52 UTC (permalink / raw)
  To: Heinrich Schuchardt, Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot


On 11/3/24 23:42, Heinrich Schuchardt wrote:
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use function hextoull() instead.
>
> Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Fixes: 22c48a92cdce ("lib: uuid: supporting building as part of host tools")
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	new patch
> ---
>   lib/uuid.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 19f33dd1477..538a1ba6aa8 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -313,7 +313,7 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
>   	tmp16 = cpu_to_be16(hextoul(uuid_str + 19, NULL));
>   	memcpy(uuid_bin + 8, &tmp16, 2);
>   
> -	tmp64 = cpu_to_be64(hextoul(uuid_str + 24, NULL));
> +	tmp64 = cpu_to_be64(hextoull(uuid_str + 24, NULL));
>   	memcpy(uuid_bin + 10, (char *)&tmp64 + 2, 6);
>   
>   	return 0;


Tested-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-03 22:42 ` [PATCH v2 1/4] lib: provide function hextoull() Heinrich Schuchardt
  2024-11-07  9:45   ` Ilias Apalodimas
@ 2024-11-12 11:00   ` Patrick DELAUNAY
  2024-11-13 13:39   ` Simon Glass
  2 siblings, 0 replies; 22+ messages in thread
From: Patrick DELAUNAY @ 2024-11-12 11:00 UTC (permalink / raw)
  To: Heinrich Schuchardt, Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot

Hi,

On 11/3/24 23:42, Heinrich Schuchardt wrote:
> We often convert hexadecimal strings to hextoull(). Provide a wrapper
> function to simple_strtoull() that does not require specifying the radix.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	no change
> ---
>   include/vsprintf.h | 13 +++++++++++++
>   lib/strto.c        |  5 +++++
>   2 files changed, 18 insertions(+)
>


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig
  2024-11-03 22:42 ` [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig Heinrich Schuchardt
  2024-11-03 22:46   ` Tom Rini
  2024-11-07  9:52   ` Ilias Apalodimas
@ 2024-11-12 11:00   ` Patrick DELAUNAY
  2 siblings, 0 replies; 22+ messages in thread
From: Patrick DELAUNAY @ 2024-11-12 11:00 UTC (permalink / raw)
  To: Heinrich Schuchardt, Tom Rini
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot

Hi,

On 11/3/24 23:42, Heinrich Schuchardt wrote:
> The lib_test_uuid_to_le test fails on 32-bit systems. But we never caught
> this in our CI because we never ran any of our C unit tests on 32-bit.
>
> Enable CONFIG_UNIT_TEST on qemu_arm_defconfig.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
> 	no change
> ---
>   configs/qemu_arm_defconfig | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig
> index d042aea49bb..cc4f4540fd5 100644
> --- a/configs/qemu_arm_defconfig
> +++ b/configs/qemu_arm_defconfig
> @@ -67,3 +67,4 @@ CONFIG_TPM2_MMIO=y
>   CONFIG_USB_EHCI_HCD=y
>   CONFIG_USB_EHCI_PCI=y
>   CONFIG_TPM=y
> +CONFIG_UNIT_TEST=y


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-03 22:42 ` [PATCH v2 1/4] lib: provide function hextoull() Heinrich Schuchardt
  2024-11-07  9:45   ` Ilias Apalodimas
  2024-11-12 11:00   ` Patrick DELAUNAY
@ 2024-11-13 13:39   ` Simon Glass
  2024-11-13 14:12     ` Tom Rini
  2 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2024-11-13 13:39 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tom Rini, Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas,
	Caleb Connolly, Marek Vasut, u-boot

Hi Heinrich,

On Sun, 3 Nov 2024 at 15:42, Heinrich Schuchardt
<heinrich.schuchardt@canonical.com> wrote:
>
> We often convert hexadecimal strings to hextoull(). Provide a wrapper
> function to simple_strtoull() that does not require specifying the radix.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> ---
> v2:
>         no change
> ---
>  include/vsprintf.h | 13 +++++++++++++
>  lib/strto.c        |  5 +++++
>  2 files changed, 18 insertions(+)

Could you add a test?

>
> diff --git a/include/vsprintf.h b/include/vsprintf.h
> index fe951471426..9da6ce7cc4d 100644
> --- a/include/vsprintf.h
> +++ b/include/vsprintf.h
> @@ -44,6 +44,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
>   */
>  unsigned long hextoul(const char *cp, char **endp);
>
> +/**
> + * hex_strtoull - convert a string in hex to an unsigned long long
> + *
> + * @cp: The string to be converted
> + * @endp: Updated to point to the first character not converted
> + * Return: value decoded from string (0 if invalid)
> + *
> + * Converts a hex string to an unsigned long long. If there are invalid
> + * characters at the end these are ignored. In the worst case, if all characters
> + * are invalid, 0 is returned
> + */
> +unsigned long long hextoull(const char *cp, char **endp);
> +
>  /**
>   * dec_strtoul - convert a string in decimal to an unsigned long
>   *
> diff --git a/lib/strto.c b/lib/strto.c
> index f83ac67c666..206d1e91847 100644
> --- a/lib/strto.c
> +++ b/lib/strto.c
> @@ -78,6 +78,11 @@ ulong hextoul(const char *cp, char **endp)
>         return simple_strtoul(cp, endp, 16);
>  }
>
> +unsigned long long hextoull(const char *cp, char **endp)
> +{
> +       return simple_strtoull(cp, endp, 16);
> +}
> +
>  ulong dectoul(const char *cp, char **endp)
>  {
>         return simple_strtoul(cp, endp, 10);
> --
> 2.45.2
>

Regards,
Simon

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-13 13:39   ` Simon Glass
@ 2024-11-13 14:12     ` Tom Rini
  2024-11-13 14:42       ` Simon Glass
  0 siblings, 1 reply; 22+ messages in thread
From: Tom Rini @ 2024-11-13 14:12 UTC (permalink / raw)
  To: Simon Glass
  Cc: Heinrich Schuchardt, Tuomas Tynkkynen, Raymond Mao,
	Ilias Apalodimas, Caleb Connolly, Marek Vasut, u-boot

[-- Attachment #1: Type: text/plain, Size: 720 bytes --]

On Wed, Nov 13, 2024 at 06:39:43AM -0700, Simon Glass wrote:
> Hi Heinrich,
> 
> On Sun, 3 Nov 2024 at 15:42, Heinrich Schuchardt
> <heinrich.schuchardt@canonical.com> wrote:
> >
> > We often convert hexadecimal strings to hextoull(). Provide a wrapper
> > function to simple_strtoull() that does not require specifying the radix.
> >
> > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> > ---
> > v2:
> >         no change
> > ---
> >  include/vsprintf.h | 13 +++++++++++++
> >  lib/strto.c        |  5 +++++
> >  2 files changed, 18 insertions(+)
> 
> Could you add a test?

We have tests already for this. But they weren't being run, which is
covered by 4/4.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-13 14:12     ` Tom Rini
@ 2024-11-13 14:42       ` Simon Glass
  2024-11-13 15:19         ` Tom Rini
  0 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2024-11-13 14:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Heinrich Schuchardt, Tuomas Tynkkynen, Raymond Mao,
	Ilias Apalodimas, Caleb Connolly, Marek Vasut, u-boot

Hi Tom,

On Wed, 13 Nov 2024 at 07:12, Tom Rini <trini@konsulko.com> wrote:
>
> On Wed, Nov 13, 2024 at 06:39:43AM -0700, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Sun, 3 Nov 2024 at 15:42, Heinrich Schuchardt
> > <heinrich.schuchardt@canonical.com> wrote:
> > >
> > > We often convert hexadecimal strings to hextoull(). Provide a wrapper
> > > function to simple_strtoull() that does not require specifying the radix.
> > >
> > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> > > ---
> > > v2:
> > >         no change
> > > ---
> > >  include/vsprintf.h | 13 +++++++++++++
> > >  lib/strto.c        |  5 +++++
> > >  2 files changed, 18 insertions(+)
> >
> > Could you add a test?
>
> We have tests already for this. But they weren't being run, which is
> covered by 4/4.

I'm not seeing a test for hextoull(). Where are you looking?

There is a test for hextoul() in test/str_ut.c

Regards,
Simon

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 1/4] lib: provide function hextoull()
  2024-11-13 14:42       ` Simon Glass
@ 2024-11-13 15:19         ` Tom Rini
  0 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2024-11-13 15:19 UTC (permalink / raw)
  To: Simon Glass
  Cc: Heinrich Schuchardt, Tuomas Tynkkynen, Raymond Mao,
	Ilias Apalodimas, Caleb Connolly, Marek Vasut, u-boot

[-- Attachment #1: Type: text/plain, Size: 1154 bytes --]

On Wed, Nov 13, 2024 at 07:42:57AM -0700, Simon Glass wrote:
> Hi Tom,
> 
> On Wed, 13 Nov 2024 at 07:12, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Wed, Nov 13, 2024 at 06:39:43AM -0700, Simon Glass wrote:
> > > Hi Heinrich,
> > >
> > > On Sun, 3 Nov 2024 at 15:42, Heinrich Schuchardt
> > > <heinrich.schuchardt@canonical.com> wrote:
> > > >
> > > > We often convert hexadecimal strings to hextoull(). Provide a wrapper
> > > > function to simple_strtoull() that does not require specifying the radix.
> > > >
> > > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
> > > > ---
> > > > v2:
> > > >         no change
> > > > ---
> > > >  include/vsprintf.h | 13 +++++++++++++
> > > >  lib/strto.c        |  5 +++++
> > > >  2 files changed, 18 insertions(+)
> > >
> > > Could you add a test?
> >
> > We have tests already for this. But they weren't being run, which is
> > covered by 4/4.
> 
> I'm not seeing a test for hextoull(). Where are you looking?
> 
> There is a test for hextoul() in test/str_ut.c

Oh sorry, I was referring to the overall problem this series addresses.

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit
  2024-11-03 22:42 [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
                   ` (3 preceding siblings ...)
  2024-11-03 22:42 ` [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig Heinrich Schuchardt
@ 2024-11-13 17:40 ` Tom Rini
  4 siblings, 0 replies; 22+ messages in thread
From: Tom Rini @ 2024-11-13 17:40 UTC (permalink / raw)
  To: Heinrich Schuchardt
  Cc: Tuomas Tynkkynen, Raymond Mao, Ilias Apalodimas, Simon Glass,
	Caleb Connolly, Marek Vasut, u-boot

On Sun, 03 Nov 2024 23:42:19 +0100, Heinrich Schuchardt wrote:

> The lib_test_uuid_to_le and lib lib_test_dynamic_uuid tests fail on
> 32-bit systems. But we never caught this in our CI because we never
> ran any of our C unit tests on 32-bit.
> 
> Enable CONFIG_UNIT_TEST on qemu_arm_defconfig.
> 
> hextoul() cannot convert a string to a 64-bit number on a 32-bit system.
> Use the new function hextoull() instead.
> 
> [...]

Applied to u-boot/master, thanks!

-- 
Tom



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-11-13 17:40 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-03 22:42 [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
2024-11-03 22:42 ` [PATCH v2 1/4] lib: provide function hextoull() Heinrich Schuchardt
2024-11-07  9:45   ` Ilias Apalodimas
2024-11-07 10:51     ` Marek Vasut
2024-11-12 11:00   ` Patrick DELAUNAY
2024-11-13 13:39   ` Simon Glass
2024-11-13 14:12     ` Tom Rini
2024-11-13 14:42       ` Simon Glass
2024-11-13 15:19         ` Tom Rini
2024-11-03 22:42 ` [PATCH v2 2/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Heinrich Schuchardt
2024-11-06 10:42   ` Caleb Connolly
2024-11-11 12:34   ` Ilias Apalodimas
2024-11-12 10:51   ` Patrick DELAUNAY
2024-11-03 22:42 ` [PATCH v2 3/4] lib: uuid: fix uuid_str_to_bin() " Heinrich Schuchardt
2024-11-06 10:42   ` Caleb Connolly
2024-11-11 12:33   ` Ilias Apalodimas
2024-11-12 10:52   ` Patrick DELAUNAY
2024-11-03 22:42 ` [PATCH v2 4/4] configs: enable UNIT_TEST on qemu_arm_defconfig Heinrich Schuchardt
2024-11-03 22:46   ` Tom Rini
2024-11-07  9:52   ` Ilias Apalodimas
2024-11-12 11:00   ` Patrick DELAUNAY
2024-11-13 17:40 ` [PATCH v2 0/4] lib: uuid: fix uuid_str_to_le_bin() on 32-bit Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox