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 <skandigraun@gmail.com>
This commit is contained in:
Gyorgy Sarvari 2025-09-13 11:49:20 +02:00
parent eabddce219
commit cecc91c084
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,44 @@
From ed747ac3540cb38797f56533f9f51f5627e6b994 Mon Sep 17 00:00:00 2001
From: Tony Asleson <tasleson@redhat.com>
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 <tasleson@redhat.com>
Upstream-Status: Backport [https://github.com/intel/ledmon/commit/ed747ac3540cb38797f56533f9f51f5627e6b994]
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
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)

View File

@ -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"