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
The following commit(s) were added to refs/heads/master by this push: new 3cd5e20f74 sched: return 0 from clock_systime_ticks if failed 3cd5e20f74 is described below commit 3cd5e20f741a6069004d6d31c5bc8cf7a4178fe5 Author: Xu Xingliang <xuxingli...@xiaomi.com> AuthorDate: Fri Sep 15 16:12:39 2023 +0800 sched: return 0 from clock_systime_ticks if failed Signed-off-by: Xu Xingliang <xuxingli...@xiaomi.com> --- include/nuttx/arch.h | 2 +- sched/clock/clock_systime_ticks.c | 37 +++++++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 5bad8fddf7..64bf8c47dd 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -1655,7 +1655,7 @@ void up_timer_initialize(void); * set a time in the future and get an event when that alarm goes off. * * int up_alarm_cancel(void): Cancel the alarm. - * int up_alarm_start(FAR const struct timespec *ts): Enable (or re-anable + * int up_alarm_start(FAR const struct timespec *ts): Enable (or re-enable * the alarm. * #else * int up_timer_cancel(void): Cancels the interval timer. diff --git a/sched/clock/clock_systime_ticks.c b/sched/clock/clock_systime_ticks.c index 486adb2f3c..067772194e 100644 --- a/sched/clock/clock_systime_ticks.c +++ b/sched/clock/clock_systime_ticks.c @@ -84,13 +84,18 @@ clock_t clock_systime_ticks(void) /* Get the time from the platform specific hardware */ - clock_systime_timespec(&ts); - - /* Convert to a 64-bit value in microseconds, - * then in clock tick units. - */ + if (clock_systime_timespec(&ts) == OK) + { + /* Convert to a 64-bit value in microseconds, + * then in clock tick units. + */ - return timespec_to_tick(&ts); + return timespec_to_tick(&ts); + } + else + { + return 0; + } } else #endif @@ -101,12 +106,24 @@ clock_t clock_systime_ticks(void) #if defined(CONFIG_SCHED_TICKLESS_TICK_ARGUMENT) clock_t ticks; - up_timer_gettick(&ticks); - return ticks; + if (up_timer_gettick(&ticks) == OK) + { + return ticks; + } + else + { + return 0; + } #elif defined(CONFIG_SCHED_TICKLESS) struct timespec ts; - up_timer_gettime(&ts); - return timespec_to_tick(&ts); + if (up_timer_gettime(&ts) == OK) + { + return timespec_to_tick(&ts); + } + else + { + return 0; + } #elif defined(CONFIG_SYSTEM_TIME64) clock_t sample;