mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
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))
| ^
```
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user