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 cca7c756ef3ef6fb0a49dd78c768468d1b16f034 Author: dengwenqi <[email protected]> AuthorDate: Sun May 24 12:36:41 2026 +0800 spinlock: Fix Coverity CID 8904187 unsigned comparison with zero The `if (sizeof(*(l)) > 0u)` guard in spin_lock_init compares an unsigned value with zero, which Coverity flags as a constant expression result. The guard existed only to skip the memset when spinlock_t is a zero-size type (the `atomic_t lock[0]` definition used when neither CONFIG_TICKET_ SPINLOCK nor CONFIG_SPINLOCK is set and CONFIG_HAVE_ZERO_SIZE_ARRAY is available). Move that decision to preprocessor time so no unsigned comparison is emitted: select the memset variant via #if on the same configuration conditions used to define spinlock_t in spinlock_type.h, and provide a no-op variant for the zero-size case. Coverity CID: 8904187 Type: Macro compares unsigned value with zero (CONSTANT_EXPRESSION_RESULT) File: include/nuttx/spinlock.h (reported at drivers/power/pm/pm_lock.c:60) Assisted-By: mimo-v2.6-pro Co-authored-by: ouyangxiangzhen <[email protected]> Signed-off-by: dengwenqi <[email protected]> Signed-off-by: ouyangxiangzhen <[email protected]> --- include/nuttx/spinlock.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/include/nuttx/spinlock.h b/include/nuttx/spinlock.h index c8a930258a4..950ec938dc9 100644 --- a/include/nuttx/spinlock.h +++ b/include/nuttx/spinlock.h @@ -126,14 +126,7 @@ pid_t spinlock_get_holder(FAR spinlock_debug_t *info); ****************************************************************************/ #define spin_lock_init(l) \ - do \ - { \ - if (sizeof(*(l)) > 0u) \ - { \ - memset((FAR void *)(l), 0, sizeof(*(l))); \ - } \ - } \ - while (0) + do { memset((FAR void *)(l), 0, sizeof(*(l))); } while (0) /**************************************************************************** * Name: rspin_lock_init
