You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/01/22 14:14:14 UTC
(nuttx) 07/13: sched/timer: Fix MISRA Rule 10.4
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit caafba07bca5dd24480bdf83b61d5b739f9a7e91
Author: jiangtao16 <ji...@xiaomi.com>
AuthorDate: Fri Aug 22 15:38:38 2025 +0800
sched/timer: Fix MISRA Rule 10.4
Fix MISRA Rule 10.4 convert signed variabled to unsigned ones.
Signed-off-by: jiangtao16 <ji...@xiaomi.com>
---
include/signal.h | 6 +++---
sched/timer/timer.h | 2 +-
sched/timer/timer_create.c | 6 +++---
sched/timer/timer_release.c | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/include/signal.h b/include/signal.h
index f3d9ccd165e..392ab270154 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -303,7 +303,7 @@
# define SIG_HOLD ((_sa_handler_t)1) /* Used only with sigset() */
#endif
-#define GOOD_SIGNO(s) (((unsigned)(s)) <= MAX_SIGNO)
+#define GOOD_SIGNO(s) (((unsigned)(s)) <= ((unsigned)(MAX_SIGNO)))
#define UNCAUGHT_SIGNO(s) ((s) == SIGKILL || (s) == SIGSTOP)
#define tkill(tid, signo) tgkill((pid_t)-1, tid, signo)
@@ -347,8 +347,8 @@ typedef CODE void (*sigev_notify_function_t)(union sigval value);
typedef struct sigevent
{
- uint8_t sigev_notify; /* Notification method: SIGEV_SIGNAL, SIGEV_NONE, or SIGEV_THREAD */
- uint8_t sigev_signo; /* Notification signal */
+ int sigev_notify; /* Notification method: SIGEV_SIGNAL, SIGEV_NONE, or SIGEV_THREAD */
+ int sigev_signo; /* Notification signal */
union sigval sigev_value; /* Data passed with notification */
union
diff --git a/sched/timer/timer.h b/sched/timer/timer.h
index 4f6fd6e2139..f2f8d0430e5 100644
--- a/sched/timer/timer.h
+++ b/sched/timer/timer.h
@@ -43,7 +43,7 @@
* Pre-processor Definitions
****************************************************************************/
-#define PT_FLAGS_PREALLOCATED 0x01 /* Timer comes from a pool of preallocated timers */
+#define PT_FLAGS_PREALLOCATED 0x01u /* Timer comes from a pool of preallocated timers */
/****************************************************************************
* Public Types
diff --git a/sched/timer/timer_create.c b/sched/timer/timer_create.c
index 65c6c6b7dba..0a536d47eaa 100644
--- a/sched/timer/timer_create.c
+++ b/sched/timer/timer_create.c
@@ -81,7 +81,7 @@ static FAR struct posix_timer_s *timer_allocate(void)
ret = (FAR struct posix_timer_s *)
kmm_malloc(sizeof(struct posix_timer_s));
- pt_flags = 0;
+ pt_flags = 0u;
}
/* If we have a timer, then put it into the allocated timer list */
@@ -184,10 +184,10 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp,
/* Initialize the timer instance */
ret->pt_clock = clockid;
- ret->pt_crefs = 1;
+ ret->pt_crefs = 1u;
ret->pt_owner = tcb->pid;
ret->pt_delay = 0;
- ret->pt_expected = 0;
+ ret->pt_expected = 0u;
/* Was a struct sigevent provided? */
diff --git a/sched/timer/timer_release.c b/sched/timer/timer_release.c
index 3ab5354d375..baf72d3dbe7 100644
--- a/sched/timer/timer_release.c
+++ b/sched/timer/timer_release.c
@@ -63,7 +63,7 @@ static inline void timer_free(struct posix_timer_s *timer)
/* Return it to the free list if it is one of the preallocated timers */
#if CONFIG_PREALLOC_TIMERS > 0
- if ((timer->pt_flags & PT_FLAGS_PREALLOCATED) != 0)
+ if ((timer->pt_flags & PT_FLAGS_PREALLOCATED) != 0u)
{
sq_addlast((FAR sq_entry_t *)timer, (FAR sq_queue_t *)&g_freetimers);
spin_unlock_irqrestore(&g_locktimers, flags);
@@ -118,7 +118,7 @@ int timer_release(FAR struct posix_timer_s *timer)
* would decrement to zero.
*/
- else if (timer->pt_crefs > 1)
+ else if (timer->pt_crefs > 1u)
{
timer->pt_crefs--;
ret = 1;