|
|
Message-Id: <20250930101718.1590205-1-Qi.Chen@windriver.com>
Date: Tue, 30 Sep 2025 18:17:18 +0800
From: Qi.Chen@...driver.com
To: musl@...ts.openwall.com
Cc: qi.chen@...driver.com
Subject: [PATCH] include/sched.h: fix _CPU_op_S to support expression such as '--i'
From: Chen Qi <Qi.Chen@...driver.com>
We need a local variable to hold the result of (i). Otherwise,
when this marco is as with expression such as '--i', we will
get compilation error as below:
error: operation on 'i' may be undefined [-Werror=sequence-point]
Signed-off-by: Chen Qi <Qi.Chen@...driver.com>
---
include/sched.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/sched.h b/include/sched.h
index 8c3b53f0..e7b81ca1 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -89,8 +89,8 @@ int sched_getcpu(void);
int sched_getaffinity(pid_t, size_t, cpu_set_t *);
int sched_setaffinity(pid_t, size_t, const cpu_set_t *);
-#define __CPU_op_S(i, size, set, op) ( (i)/8U >= (size) ? 0 : \
- (((unsigned long *)(set))[(i)/8/sizeof(long)] op (1UL<<((i)%(8*sizeof(long))))) )
+#define __CPU_op_S(i, size, set, op) ({size_t _i=(i); (_i)/8U >= (size) ? 0 : \
+ (((unsigned long *)(set))[(_i)/8/sizeof(long)] op (1UL<<((_i)%(8*sizeof(long))))); })
#define CPU_SET_S(i, size, set) __CPU_op_S(i, size, set, |=)
#define CPU_CLR_S(i, size, set) __CPU_op_S(i, size, set, &=~)
--
2.34.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.