diff options
author | Tom Rini <trini@konsulko.com> | 2024-11-13 08:14:29 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-11-13 08:14:29 -0600 |
commit | 9d49c73862c4c492b81b8cdd941fc4d602774673 (patch) | |
tree | c0e441278c859d2e65ebf46844714ff58349fc8f /lib/uuid.c | |
parent | b30787ad24d51ea7efb75870a83f2c3e6cad0f24 (diff) | |
parent | 37587d2e1454e9642bbae900b920dc5f0530fa87 (diff) |
Merge patch series "lib: uuid: fix uuid_str_to_le_bin() on 32-bit"
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> says:
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.
Link: https://lore.kernel.org/r/20241103224223.195255-1-heinrich.schuchardt@canonical.com
Diffstat (limited to 'lib/uuid.c')
-rw-r--r-- | lib/uuid.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/uuid.c b/lib/uuid.c index c6a27b7d044..538a1ba6aa8 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) @@ -312,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; @@ -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; |