mirror of
https://github.com/apache/nuttx.git
synced 2026-05-19 03:03:37 +08:00
sched/timer: Fix MISRA Rule 10.3
Fix MISRA Rule 10.3 exist clock to sclock cause wide type implicit conversion to narrow type, NSEC_PER_USEC to l Signed-off-by: jiangtao16 <jiangtao16@xiaomi.com>
This commit is contained in:
+4
-4
@@ -65,7 +65,7 @@ struct timerfd_priv_s
|
||||
mutex_t lock; /* Enforces device exclusive access */
|
||||
FAR timerfd_waiter_sem_t *rdsems; /* List of blocking readers */
|
||||
int clock; /* Clock to use as the timing base */
|
||||
int delay; /* If non-zero, used to reset repetitive
|
||||
clock_t delay; /* If non-zero, used to reset repetitive
|
||||
* timers */
|
||||
struct wdog_s wdog; /* The watchdog that provides the timing */
|
||||
timerfd_t counter; /* timerfd counter */
|
||||
@@ -404,7 +404,7 @@ static void timerfd_timeout(wdparm_t arg)
|
||||
|
||||
/* If this is a repetitive timer, then restart the watchdog */
|
||||
|
||||
if (dev->delay > 0)
|
||||
if (dev->delay > 0u)
|
||||
{
|
||||
wd_start(&dev->wdog, dev->delay, timerfd_timeout, arg);
|
||||
}
|
||||
@@ -492,7 +492,7 @@ int timerfd_settime(int fd, int flags,
|
||||
FAR struct timerfd_priv_s *dev;
|
||||
FAR struct file *filep;
|
||||
irqstate_t intflags;
|
||||
sclock_t delay;
|
||||
clock_t delay;
|
||||
int ret;
|
||||
|
||||
/* Some sanity checks */
|
||||
@@ -594,7 +594,7 @@ int timerfd_settime(int fd, int flags,
|
||||
* instead (assuming a repetitive timer).
|
||||
*/
|
||||
|
||||
if (delay <= 0)
|
||||
if ((sclock_t)delay <= 0)
|
||||
{
|
||||
delay = dev->delay;
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ struct posix_timer_s
|
||||
uint8_t pt_crefs; /* Reference count */
|
||||
pid_t pt_owner; /* Creator of timer */
|
||||
int pt_overrun; /* Overrun time */
|
||||
sclock_t pt_delay; /* If non-zero, used to reset repetitive timers */
|
||||
clock_t pt_delay; /* If non-zero, used to reset repetitive timers */
|
||||
clock_t pt_expected; /* Expected absolute time */
|
||||
struct wdog_s pt_wdog; /* The watchdog that provides the timing */
|
||||
struct sigevent pt_event; /* Notification information */
|
||||
|
||||
@@ -186,7 +186,7 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp,
|
||||
ret->pt_clock = clockid;
|
||||
ret->pt_crefs = 1u;
|
||||
ret->pt_owner = tcb->pid;
|
||||
ret->pt_delay = 0;
|
||||
ret->pt_delay = 0u;
|
||||
ret->pt_expected = 0u;
|
||||
|
||||
/* Was a struct sigevent provided? */
|
||||
|
||||
@@ -102,8 +102,8 @@ static inline void timer_restart(FAR struct posix_timer_s *timer,
|
||||
wdparm_t itimer)
|
||||
{
|
||||
clock_t ticks;
|
||||
sclock_t delay;
|
||||
sclock_t frame;
|
||||
clock_t delay;
|
||||
clock_t frame;
|
||||
|
||||
/* If this is a repetitive timer, then restart the watchdog */
|
||||
|
||||
@@ -128,7 +128,7 @@ static inline void timer_restart(FAR struct posix_timer_s *timer,
|
||||
*/
|
||||
|
||||
frame = (delay + timer->pt_delay) / timer->pt_delay;
|
||||
timer->pt_overrun = frame - 1;
|
||||
timer->pt_overrun = (int)(frame - 1u);
|
||||
timer->pt_expected += frame * timer->pt_delay;
|
||||
|
||||
wd_start_abstick(&timer->pt_wdog, timer->pt_expected,
|
||||
@@ -254,7 +254,7 @@ int timer_settime(timer_t timerid, int flags,
|
||||
FAR struct itimerspec *ovalue)
|
||||
{
|
||||
FAR struct posix_timer_s *timer = timer_gethandle(timerid);
|
||||
sclock_t delay;
|
||||
clock_t delay;
|
||||
int ret = OK;
|
||||
|
||||
/* Some sanity checks */
|
||||
@@ -304,7 +304,7 @@ int timer_settime(timer_t timerid, int flags,
|
||||
}
|
||||
else
|
||||
{
|
||||
timer->pt_delay = 0;
|
||||
timer->pt_delay = 0u;
|
||||
}
|
||||
|
||||
/* Check if abstime is selected */
|
||||
|
||||
Reference in New Issue
Block a user