From cecc91c084c95cedc210ddd0ca6b36ea6c520a80 Mon Sep 17 00:00:00 2001 From: Gyorgy Sarvari Date: Sat, 13 Sep 2025 11:49:20 +0200 Subject: [PATCH] ledmon: fix building on 32-bit x86 Building the recipe on x86 platform fails with the following error: | ../../git/src/utils.c: In function 'get_uint64': | ../../git/src/utils.c:105:18: error: passing argument 1 of 'str_toul' from incompatible pointer type [-Wincompatible-pointer-types] | 105 | str_toul(&defval, p, NULL, 16); Upstream has already changed this function to avoid overflow due to the size difference in the pointer - this change backports that patch. Signed-off-by: Gyorgy Sarvari --- .../ledmon/ledmon/Correct-get_uint64.patch | 44 +++++++++++++++++++ meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb | 3 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-bsp/ledmon/ledmon/Correct-get_uint64.patch diff --git a/meta-oe/recipes-bsp/ledmon/ledmon/Correct-get_uint64.patch b/meta-oe/recipes-bsp/ledmon/ledmon/Correct-get_uint64.patch new file mode 100644 index 0000000000..c4d8ff80b8 --- /dev/null +++ b/meta-oe/recipes-bsp/ledmon/ledmon/Correct-get_uint64.patch @@ -0,0 +1,44 @@ +From ed747ac3540cb38797f56533f9f51f5627e6b994 Mon Sep 17 00:00:00 2001 +From: Tony Asleson +Date: Wed, 21 Aug 2024 12:27:28 -0500 +Subject: [PATCH] Correct get_uint64 + +For large integer values, the existing implementation will be +incorrect. + +The current implementation of converting strings to integer values +uses a signed integer for the intermediate conversion and performs +a range check. Since any value in an unsigned 64-bit integer is valid, +the range check seems unnecessary. To mimic the same code path, we would +need a larger integer type. + +Signed-off-by: Tony Asleson + +Upstream-Status: Backport [https://github.com/intel/ledmon/commit/ed747ac3540cb38797f56533f9f51f5627e6b994] + +Signed-off-by: Gyorgy Sarvari +--- + src/utils.c | 9 ++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/utils.c b/src/utils.c +index 86b9593..b87d064 100644 +--- a/src/utils.c ++++ b/src/utils.c +@@ -102,9 +102,14 @@ uint64_t get_uint64(const char *path, uint64_t defval, const char *name) + if (!p) + return defval; + +- str_toul(&defval, p, NULL, 16); ++ errno = 0; ++ uint64_t t = strtoull(p, NULL, 16); + free(p); +- return defval; ++ ++ if (errno) ++ return defval; ++ ++ return t; + } + + int get_int(const char *path, int defval, const char *name) diff --git a/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb b/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb index 88a6e5bb30..23a49a7d1b 100644 --- a/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb +++ b/meta-oe/recipes-bsp/ledmon/ledmon_0.97.bb @@ -16,7 +16,8 @@ SYSTEMD_SERVICE:${PN} = "ledmon.service" SRC_URI = "git://github.com/intel/ledmon;branch=master;protocol=https \ file://0002-include-sys-select.h-and-sys-types.h.patch \ - file://0001-fix-build-with-clang.patch" + file://0001-fix-build-with-clang.patch \ + file://Correct-get_uint64.patch" SRCREV = "b0edae14e8660b80ffe0384354038a9f62e2978d"