From: Yu Watanabe Date: Tue, 1 Jul 2025 03:53:14 +0000 (+0900) Subject: musl: avoid multiple evaluations in CPU_ISSET_S() macro X-Git-Tag: v259-rc1~71^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ebbc0ea7fd764c870bb8689111138b4f73854d42;p=thirdparty%2Fsystemd.git musl: avoid multiple evaluations in CPU_ISSET_S() macro musl's CPU_ISSET_S() macro does not avoid multiple evaluations, and it only accepts simple variable or constant. Fixes the following error. ``` ../src/shared/cpu-set-util.c: In function ‘cpu_set_to_mask_string’: ../src/shared/cpu-set-util.c:101:41: warning: operation on ‘i’ may be undefined [-Werror=sequence-point] 101 | if (CPU_ISSET_S(--i, c->allocated, c->set)) | ^ ``` --- diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c index 25288046c14..a9bdd235f81 100644 --- a/src/shared/cpu-set-util.c +++ b/src/shared/cpu-set-util.c @@ -96,9 +96,11 @@ char* cpu_set_to_mask_string(const CPUSet *c) { for (size_t i = c->allocated * 8; i > 0; ) { uint32_t m = 0; - for (int j = (i % 32 ?: 32) - 1; j >= 0; j--) - if (CPU_ISSET_S(--i, c->allocated, c->set)) + for (int j = (i % 32 ?: 32) - 1; j >= 0; j--) { + --i; + if (CPU_ISSET_S(i, c->allocated, c->set)) SET_BIT(m, j); + } if (!found_nonzero) { if (m == 0)