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 e171415897eace89955d1ac75334d69e269c8477 Author: jiangtao16 <[email protected]> AuthorDate: Thu Aug 7 18:06:44 2025 +0800 sched/clock: has external linkage but is only used in one translation unit Fix for MISRA-C rule 8.10 Signed-off-by: jiangtao16 <[email protected]> --- include/nuttx/clock.h | 13 ---------- sched/clock/clock_settime.c | 59 ++++++++++++++------------------------------- 2 files changed, 18 insertions(+), 54 deletions(-) diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 71718f45064..5ac210c8392 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -817,19 +817,6 @@ void perf_convert(clock_t elapsed, FAR struct timespec *ts); unsigned long perf_getfreq(void); -/**************************************************************************** - * Name: nxclock_settime - * - * Description: - * Clock Functions based on POSIX APIs - * - * CLOCK_REALTIME - POSIX demands this to be present. This is the wall - * time clock. - * - ****************************************************************************/ - -int nxclock_settime(clockid_t clock_id, FAR const struct timespec *tp); - /**************************************************************************** * Name: nxclock_gettime * diff --git a/sched/clock/clock_settime.c b/sched/clock/clock_settime.c index a448e809ea1..cfe749f1f7f 100644 --- a/sched/clock/clock_settime.c +++ b/sched/clock/clock_settime.c @@ -99,7 +99,7 @@ static void nxclock_set_realtime(FAR const struct timespec *tp) ****************************************************************************/ /**************************************************************************** - * Name: nxclock_settime + * Name: clock_settime * * Description: * Clock Functions based on POSIX APIs @@ -109,55 +109,32 @@ static void nxclock_set_realtime(FAR const struct timespec *tp) * ****************************************************************************/ -int nxclock_settime(clockid_t clock_id, FAR const struct timespec *tp) +int clock_settime(clockid_t clock_id, FAR const struct timespec *tp) { int ret = -EINVAL; - if (tp == NULL || tp->tv_nsec < 0 || tp->tv_nsec >= 1000000000) - { - return ret; - } - - if (clock_id == CLOCK_REALTIME) + if (tp != NULL && tp->tv_nsec >= 0 && tp->tv_nsec < 1000000000) { - nxclock_set_realtime(tp); - return 0; - } + if (clock_id == CLOCK_REALTIME) + { + nxclock_set_realtime(tp); + ret = 0; + } #ifdef CONFIG_PTP_CLOCK - else if ((clock_id & CLOCK_MASK) == CLOCK_FD) - { - FAR struct file *filep; - - ret = ptp_clockid_to_filep(clock_id, &filep); - if (ret < 0) + else if ((clock_id & CLOCK_MASK) == CLOCK_FD) { - return ret; + FAR struct file *filep; + + ret = ptp_clockid_to_filep(clock_id, &filep); + if (ret >= 0) + { + ret = file_ioctl(filep, PTP_CLOCK_SETTIME, tp); + fs_putfilep(filep); + } } - - ret = file_ioctl(filep, PTP_CLOCK_SETTIME, tp); - fs_putfilep(filep); - } #endif + } - return ret; -} - -/**************************************************************************** - * Name: clock_settime - * - * Description: - * Clock Functions based on POSIX APIs - * - * CLOCK_REALTIME - POSIX demands this to be present. This is the wall - * time clock. - * - ****************************************************************************/ - -int clock_settime(clockid_t clock_id, FAR const struct timespec *tp) -{ - int ret; - - ret = nxclock_settime(clock_id, tp); if (ret < 0) { set_errno(-ret);
