
In 22c48a92cdce (lib: uuid: supporting building as part of host tools), some instances of simple_strtoull() were accidentally replaced with strtoul() instead (spot the difference!).
To keep compatibility with building as part of host tools, re-implement this via a new hextoull macro to handle both cases.
Fixes: 22c48a92cdce (lib: uuid: supporting building as part of host tools) Signed-off-by: Caleb Connolly caleb.connolly@linaro.org Reported-by: Patrick DELAUNAY patrick.delaunay@foss.st.com --- I've build-tested this but don't have the hardware set up to easily test. --- lib/uuid.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/uuid.c b/lib/uuid.c index c6a27b7d044d..59f07a9a5834 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -34,8 +34,11 @@
#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) +#else +#define hextoull(cp, endp) simple_strtoull(cp, endp, 16) #endif
int uuid_str_valid(const char *uuid) { @@ -289,9 +292,9 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin, return -EINVAL; }
if (str_format == UUID_STR_FORMAT_STD) { - tmp32 = cpu_to_be32(hextoul(uuid_str, NULL)); + tmp32 = cpu_to_be32(hextoull(uuid_str, NULL)); memcpy(uuid_bin, &tmp32, 4);
tmp16 = cpu_to_be16(hextoul(uuid_str + 9, NULL)); memcpy(uuid_bin + 4, &tmp16, 2); @@ -326,9 +329,9 @@ int uuid_str_to_le_bin(const char *uuid_str, unsigned char *uuid_bin)
if (!uuid_str_valid(uuid_str) || !uuid_bin) return -EINVAL;
- tmp32 = cpu_to_le32(hextoul(uuid_str, NULL)); + tmp32 = cpu_to_le32(hextoull(uuid_str, NULL)); memcpy(uuid_bin, &tmp32, 4);
tmp16 = cpu_to_le16(hextoul(uuid_str + 9, NULL)); memcpy(uuid_bin + 4, &tmp16, 2);