sched/spawn: Fix MISRA C 2012 Rule 10.4 violations

Fix violations of MISRA C:2012 Rule 10.4 (essential type operand of
unsigned and signed) in posix_spawn attribute handling code.

Changed all POSIX_SPAWN_* flag macro definitions to use unsigned literals
(1u instead of 1) to ensure consistent unsigned arithmetic when performing
bitwise operations. This eliminates mixed signed/unsigned operand violations
in the following flags:

- POSIX_SPAWN_RESETIDS
- POSIX_SPAWN_SETPGROUP
- POSIX_SPAWN_SETSCHEDPARAM
- POSIX_SPAWN_SETSCHEDULER
- POSIX_SPAWN_SETSIGDEF
- POSIX_SPAWN_SETSIGMASK
- POSIX_SPAWN_SETSID

Updated all flag checking comparisons in spawn_execattrs() to compare
against 0u instead of 0 for consistency.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This commit is contained in:
fangxinyong
2026-02-02 16:20:42 +08:00
committed by Xiang Xiao
parent 9ae2fce3c1
commit 2b9506bc5d
2 changed files with 12 additions and 12 deletions
+7 -7
View File
@@ -48,13 +48,13 @@
* posix_spawnattr_t object using the posix_spawnattr_setflags() function:"
*/
#define POSIX_SPAWN_RESETIDS (1 << 0) /* 1: Reset effective user ID */
#define POSIX_SPAWN_SETPGROUP (1 << 1) /* 1: Set process group */
#define POSIX_SPAWN_SETSCHEDPARAM (1 << 2) /* 1: Set task's priority */
#define POSIX_SPAWN_SETSCHEDULER (1 << 3) /* 1: Set task's scheduler policy */
#define POSIX_SPAWN_SETSIGDEF (1 << 4) /* 1: Set default signal actions */
#define POSIX_SPAWN_SETSIGMASK (1 << 5) /* 1: Set sigmask */
#define POSIX_SPAWN_SETSID (1 << 7) /* 1: Create the new session(glibc specific) */
#define POSIX_SPAWN_RESETIDS (1u << 0) /* 1: Reset effective user ID */
#define POSIX_SPAWN_SETPGROUP (1u << 1) /* 1: Set process group */
#define POSIX_SPAWN_SETSCHEDPARAM (1u << 2) /* 1: Set task's priority */
#define POSIX_SPAWN_SETSCHEDULER (1u << 3) /* 1: Set task's scheduler policy */
#define POSIX_SPAWN_SETSIGDEF (1u << 4) /* 1: Set default signal actions */
#define POSIX_SPAWN_SETSIGMASK (1u << 5) /* 1: Set sigmask */
#define POSIX_SPAWN_SETSID (1u << 7) /* 1: Create the new session(glibc specific) */
/* NOTE: NuttX provides only one implementation: If
* CONFIG_LIBC_ENVPATH is defined, then only posix_spawnp() behavior