This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit e4ebcd77ae1436cf28738fce6d31b7f8b57cfe1a Author: Marco Casaroli <[email protected]> AuthorDate: Wed Oct 28 15:04:13 2026 +0100 include/sched.h: Fix four CPU set macros. CPU_ZERO_S(n, s) expanded to CPU_ZERO_S(s): the preprocessor does not expand a macro in its own expansion, so the result was a call of an undeclared function CPU_ZERO_S() with one argument. It now expands to CPU_ZERO(s), as the other _S macros expand to their fixed-size forms. CPU_ALLOC() ended with a semicolon and had no parentheses around the cast, so it could not be used in an expression, for example "if ((set = CPU_ALLOC(n)) == NULL)". CPU_COUNT(s) used *s without parentheses, so CPU_COUNT(sets + 1) counted the bits of *sets + 1. cpu_set_t is volatile, so CPU_FREE(s) passed a pointer to volatile to free(), and the compiler warns that the qualifier is discarded. It now casts the pointer to void *. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- include/sched.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/sched.h b/include/sched.h index 825cbb8d9cd..88c9295de35 100644 --- a/include/sched.h +++ b/include/sched.h @@ -99,7 +99,7 @@ /* int CPU_COUNT(FAR const cpu_set_t *set); */ -#define CPU_COUNT(s) popcountl(*s) +#define CPU_COUNT(s) popcountl(*(s)) /* void CPU_AND(FAR cpu_set_t *destset, FAR const cpu_set_t *srcset1, * FAR const cpu_set_t *srcset2); @@ -127,11 +127,11 @@ /* FAR cpu_set_t *CPU_ALLOC(int num_cpus); */ -#define CPU_ALLOC(n) (FAR cpu_set_t *)malloc(sizeof(cpu_set_t)); +#define CPU_ALLOC(n) ((FAR cpu_set_t *)malloc(sizeof(cpu_set_t))) /* void CPU_FREE(cpu_set_t *set); */ -#define CPU_FREE(s) free(s) +#define CPU_FREE(s) free((FAR void *)(s)) /* size_t CPU_ALLOC_SIZE(int num_cpus); */ @@ -139,7 +139,7 @@ /* void CPU_ZERO_S(size_t setsize, FAR cpu_set_t *set); */ -#define CPU_ZERO_S(n,s) CPU_ZERO_S(s) +#define CPU_ZERO_S(n,s) CPU_ZERO(s) /* void CPU_SET_S(int cpu, size_t setsize, FAR cpu_set_t *set); */
