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 b5f7b88bae2440830535bc296f1f079e06646fee
Author: yushuailong <[email protected]>
AuthorDate: Sat Sep 12 15:40:05 2026 +0800

    sched/clock: Normalize CLOCK_FD getres errors.
    
    Convert failures from CLOCK_FD lookup and PTP_CLOCK_GETRES into the public
    clock_getres() convention of returning ERROR and setting errno. This keeps
    dynamic PTP clocks consistent with the other clock_getres() error paths.
    
    Assisted-by: OpenAI Codex
    Signed-off-by: yushuailong <[email protected]>
---
 sched/clock/clock_getres.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/sched/clock/clock_getres.c b/sched/clock/clock_getres.c
index 780d3db50ba..9b32428d84a 100644
--- a/sched/clock/clock_getres.c
+++ b/sched/clock/clock_getres.c
@@ -81,13 +81,17 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
           FAR struct file *filep;
 
           ret = ptp_clockid_to_filep(clock_id, &filep);
-          if (ret < 0)
+          if (ret >= 0)
             {
-              return ret;
+              ret = file_ioctl(filep, PTP_CLOCK_GETRES, res);
+              file_put(filep);
             }
 
-          ret = file_ioctl(filep, PTP_CLOCK_GETRES, res);
-          file_put(filep);
+          if (ret < 0)
+            {
+              set_errno(-ret);
+              ret = ERROR;
+            }
         }
         break;
 #endif

Reply via email to