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-apps.git

commit a6477ec8dc38f92e16c2b6632cdcf3320259042f
Author: Xiang Xiao <[email protected]>
AuthorDate: Sun May 3 17:17:05 2026 +0800

    !apps: replace sclock_t with clock_t and drop redundant time_t/off_t casts
    
    Align with the upstream nuttx change that drops the sclock_t alias now
    that clock_t is itself a signed 64-bit type (int64_t).  Beyond the pure
    sclock_t -> clock_t rename, this commit also removes the
    now-unnecessary (time_t)-1 / (time_t)0 / (off_t)-1 casts that were
    papering over the previously-unsigned time_t.
    
    Files touched:
    
      - examples/alarm/alarm_main.c:        sclock_t -> clock_t
      - netutils/dhcpd/dhcpd.c:             sclock_t -> clock_t
      - netutils/ftpd/ftpd.c:               sclock_t -> clock_t
      - netutils/thttpd/libhttpd.c,
        netutils/thttpd/tdate_parse.c:      drop (time_t)-1 / (time_t)0 /
                                            (off_t)-1 sentinel casts
      - system/resmonitor/filldisk.c,
        system/zmodem/zm_receive.c:         sclock_t -> clock_t
      - testing/ostest/wdog.c:              sclock_t -> clock_t (the bulk
                                            of the rename, 30 sites)
      - testing/testsuites/kernel/syscall/cases/{clock_nanosleep_test,
        fsync_test,time_test}.c:            drop (time_t)-1 casts in the
                                            new signed-time_t world
    
    No behavioural change.
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 examples/alarm/alarm_main.c                        |  2 +-
 netutils/dhcpd/dhcpd.c                             |  2 +-
 netutils/ftpd/ftpd.c                               |  4 +--
 netutils/thttpd/libhttpd.c                         | 16 ++++++------
 netutils/thttpd/tdate_parse.c                      |  2 +-
 system/resmonitor/filldisk.c                       |  2 +-
 system/zmodem/zm_receive.c                         |  2 +-
 testing/ostest/wdog.c                              | 30 +++++++++++-----------
 .../kernel/syscall/cases/clock_nanosleep_test.c    |  2 +-
 .../testsuites/kernel/syscall/cases/fsync_test.c   |  2 +-
 .../testsuites/kernel/syscall/cases/time_test.c    |  2 +-
 11 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/examples/alarm/alarm_main.c b/examples/alarm/alarm_main.c
index d4ab70a80..4b5296f73 100644
--- a/examples/alarm/alarm_main.c
+++ b/examples/alarm/alarm_main.c
@@ -393,7 +393,7 @@ int main(int argc, FAR char *argv[])
 
       setrel.id      = alarmid;
       setrel.pid     = g_alarm_daemon_pid;
-      setrel.reltime = (time_t)seconds;
+      setrel.reltime = seconds;
 
       setrel.event.sigev_notify = SIGEV_SIGNAL;
       setrel.event.sigev_signo  = CONFIG_EXAMPLES_ALARM_SIGNO;
diff --git a/netutils/dhcpd/dhcpd.c b/netutils/dhcpd/dhcpd.c
index a166e9123..5d909a2e6 100644
--- a/netutils/dhcpd/dhcpd.c
+++ b/netutils/dhcpd/dhcpd.c
@@ -661,7 +661,7 @@ static inline bool dhcpd_parseoptions(void)
             if (optlen >= 6 && optlen < remaining)
               {
                 memcpy(&tmp, &ptr[DHCPD_OPTION_DATA], 4);
-                g_state.ds_optleasetime = (time_t)ntohl(tmp);
+                g_state.ds_optleasetime = ntohl(tmp);
               }
             break;
 
diff --git a/netutils/ftpd/ftpd.c b/netutils/ftpd/ftpd.c
index fa5eb9284..ded7484d7 100644
--- a/netutils/ftpd/ftpd.c
+++ b/netutils/ftpd/ftpd.c
@@ -2305,11 +2305,11 @@ static int ftpd_listbuffer(FAR struct ftpd_session_s 
*session,
 
       /* time */
 
-      memcpy(&tm, localtime((FAR const time_t *)&st->st_mtime), sizeof(tm));
+      memcpy(&tm, localtime(&st->st_mtime), sizeof(tm));
       offset += snprintf(&buffer[offset], buflen - offset, " %s %2u",
                          g_monthtab[tm.tm_mon], tm.tm_mday);
       now = time(0);
-      if ((now - st->st_mtime) > (time_t)(60 * 60 * 24 * 180))
+      if (now - st->st_mtime > 60 * 60 * 24 * 180)
         {
           offset += snprintf(&buffer[offset], buflen - offset, " %5u",
                              tm.tm_year + 1900);
diff --git a/netutils/thttpd/libhttpd.c b/netutils/thttpd/libhttpd.c
index 19acb562c..1a7d46c13 100644
--- a/netutils/thttpd/libhttpd.c
+++ b/netutils/thttpd/libhttpd.c
@@ -327,7 +327,7 @@ static void send_mime(httpd_conn *hc, int status, const 
char *title,
           (hc->range_end >= hc->range_start) &&
           ((hc->range_end != length - 1) ||
            (hc->range_start != 0)) &&
-          (hc->range_if == (time_t) - 1 || hc->range_if == hc->sb.st_mtime))
+          (hc->range_if == -1 || hc->range_if == hc->sb.st_mtime))
         {
           partial_content = 1;
           status = 206;
@@ -340,7 +340,7 @@ static void send_mime(httpd_conn *hc, int status, const 
char *title,
         }
 
       gettimeofday(&now, NULL);
-      if (mod == (time_t)0)
+      if (mod == 0)
         {
           mod = now.tv_sec;
         }
@@ -510,7 +510,7 @@ static int send_err_file(httpd_conn *hc, int status, char 
*title,
     }
 
   send_mime(hc, status, title, "", extraheads, "text/html; charset=%s",
-            (off_t)-1, (time_t)0);
+            -1, 0);
   for (; ; )
     {
       nread = fread(buf, 1, sizeof(buf) - 1, fp);
@@ -2421,8 +2421,8 @@ int httpd_get_conn(httpd_server *hs, int listen_fd, 
httpd_conn *hc)
   hc->altdir[0]         = '\0';
 #endif
   hc->buflen = 0;
-  hc->if_modified_since = (time_t) - 1;
-  hc->range_if          = (time_t)-1;
+  hc->if_modified_since = -1;
+  hc->range_if          = -1;
   hc->contentlength     = -1;
   hc->type = "";
 #ifdef CONFIG_THTTPD_VHOST
@@ -2926,7 +2926,7 @@ int httpd_parse_request(httpd_conn *hc)
             {
               cp = &buf[18];
               hc->if_modified_since = tdate_parse(cp);
-              if (hc->if_modified_since == (time_t) - 1)
+              if (hc->if_modified_since == -1)
                 {
                   nerr("ERROR: unparsable time: %s\n", cp);
                 }
@@ -2973,7 +2973,7 @@ int httpd_parse_request(httpd_conn *hc)
             {
               cp = &buf[9];
               hc->range_if = tdate_parse(cp);
-              if (hc->range_if == (time_t) - 1)
+              if (hc->range_if == -1)
                 {
                   nerr("ERROR: unparsable time: %s\n", cp);
                 }
@@ -3521,7 +3521,7 @@ int httpd_start_request(httpd_conn *hc, struct timeval 
*nowp)
       send_mime(hc, 200, ok200title, hc->encodings, "", hc->type,
                 hc->sb.st_size, hc->sb.st_mtime);
     }
-  else if (hc->if_modified_since != (time_t) - 1 &&
+  else if (hc->if_modified_since != -1 &&
            hc->if_modified_since >= hc->sb.st_mtime)
     {
       send_mime(hc, 304, err304title, hc->encodings, "",
diff --git a/netutils/thttpd/tdate_parse.c b/netutils/thttpd/tdate_parse.c
index 2b49d3995..82b55846a 100644
--- a/netutils/thttpd/tdate_parse.c
+++ b/netutils/thttpd/tdate_parse.c
@@ -348,7 +348,7 @@ time_t tdate_parse(char *str)
 #endif /* Day of week not yet supported by NuttX */
   else
     {
-      return (time_t) - 1;
+      return -1;
     }
 
   if (tm.tm_year > 1900)
diff --git a/system/resmonitor/filldisk.c b/system/resmonitor/filldisk.c
index de550b47e..6670048b0 100644
--- a/system/resmonitor/filldisk.c
+++ b/system/resmonitor/filldisk.c
@@ -304,7 +304,7 @@ int main(int argc, FAR char *argv[])
             mode   = 1;
             break;
           case 'i':
-            interval = (time_t)bytes(optarg);
+            interval = bytes(optarg);
             break;
           case 'b':
             bufsize = bytes(optarg);
diff --git a/system/zmodem/zm_receive.c b/system/zmodem/zm_receive.c
index 6818a1fab..19fe6ef18 100644
--- a/system/zmodem/zm_receive.c
+++ b/system/zmodem/zm_receive.c
@@ -675,7 +675,7 @@ static int zmr_filename(FAR struct zm_state_s *pzm)
 
   pzmr->filesize  = (off_t)filesize;
 #ifdef CONFIG_SYSTEM_ZMODEM_TIMESTAMPS
-  pzmr->timestamp = (time_t)timestamp;
+  pzmr->timestamp = timestamp;
 #endif
 
   /* Check if we need to send the CRC */
diff --git a/testing/ostest/wdog.c b/testing/ostest/wdog.c
index e64f1246f..69e4b1386 100644
--- a/testing/ostest/wdog.c
+++ b/testing/ostest/wdog.c
@@ -56,7 +56,7 @@
 typedef struct wdtest_param_s
 {
   FAR struct wdog_s *wdog;
-  sclock_t           interval;
+  clock_t            interval;
   uint64_t           callback_cnt;
   clock_t            triggered_tick;
 } wdtest_param_t;
@@ -79,7 +79,7 @@ static void wdtest_callback(wdparm_t param)
   wdtest_param->callback_cnt   += 1;
 }
 
-static void wdtest_checkdelay(sclock_t diff, sclock_t delay_tick)
+static void wdtest_checkdelay(clock_t diff, clock_t delay_tick)
 {
   /* Ensure the watchdog trigger time is not earlier than expected. */
 
@@ -97,13 +97,13 @@ static void wdtest_checkdelay(sclock_t diff, sclock_t 
delay_tick)
 }
 
 static void wdtest_once(FAR struct wdog_s *wdog, FAR wdtest_param_t *param,
-                        sclock_t delay_ns)
+                        clock_t delay_ns)
 {
   uint64_t   cnt;
-  sclock_t   diff;
+  clock_t    diff;
   clock_t    wdset_tick;
   irqstate_t flags;
-  sclock_t   delay_tick = (sclock_t)NSEC2TICK((clock_t)delay_ns);
+  clock_t    delay_tick = NSEC2TICK(delay_ns);
 
   wdtest_printf("wdtest_once %lld ns\n", (long long)delay_ns);
 
@@ -133,20 +133,20 @@ static void wdtest_once(FAR struct wdog_s *wdog, FAR 
wdtest_param_t *param,
 
   /* Check if the delay is within the acceptable tolerance. */
 
-  diff = (sclock_t)(param->triggered_tick - wdset_tick);
+  diff = param->triggered_tick - wdset_tick;
 
   wdtest_checkdelay(diff, delay_tick);
 }
 
 static void wdtest_rand(FAR struct wdog_s *wdog, FAR wdtest_param_t *param,
-                        sclock_t rand_ns)
+                        clock_t rand_ns)
 {
   uint64_t   cnt;
   int        idx;
-  sclock_t   delay_ns;
+  clock_t    delay_ns;
   clock_t    wdset_tick;
-  sclock_t   delay_tick;
-  sclock_t   diff;
+  clock_t    delay_tick;
+  clock_t    diff;
   irqstate_t flags = 0;
 
   /* Perform multiple iterations with random delays. */
@@ -190,7 +190,7 @@ static void wdtest_rand(FAR struct wdog_s *wdog, FAR 
wdtest_param_t *param,
 
           if (cnt % 2)
             {
-              diff = (sclock_t)(param->triggered_tick - wdset_tick);
+              diff = param->triggered_tick - wdset_tick;
               wdtest_checkdelay(diff, delay_tick);
             }
         }
@@ -204,7 +204,7 @@ static void wdtest_rand(FAR struct wdog_s *wdog, FAR 
wdtest_param_t *param,
 static void wdtest_callback_recursive(wdparm_t param)
 {
   FAR wdtest_param_t *wdtest_param = (FAR wdtest_param_t *)param;
-  sclock_t            interval     = wdtest_param->interval;
+  clock_t             interval     = wdtest_param->interval;
 
   wdtest_param->callback_cnt   += 1;
   wdtest_param->triggered_tick  = clock_systime_ticks();
@@ -215,7 +215,7 @@ static void wdtest_callback_recursive(wdparm_t param)
 
 static void wdtest_recursive(FAR struct wdog_s *wdog,
                              FAR wdtest_param_t *param,
-                             sclock_t delay_ns,
+                             clock_t delay_ns,
                              unsigned int times)
 {
   uint64_t cnt;
@@ -227,7 +227,7 @@ static void wdtest_recursive(FAR struct wdog_s *wdog,
   cnt = param->callback_cnt;
 
   param->wdog = wdog;
-  param->interval = (sclock_t)NSEC2TICK((clock_t)delay_ns);
+  param->interval = NSEC2TICK(delay_ns);
 
   wdtest_assert(param->interval >= 0);
 
@@ -253,7 +253,7 @@ static void wdtest_recursive(FAR struct wdog_s *wdog,
 static void wdog_test_run(FAR wdtest_param_t *param)
 {
   uint64_t             cnt;
-  sclock_t             rest;
+  clock_t              rest;
   clock_t              delay;
   struct wdog_s        test_wdog =
   {
diff --git a/testing/testsuites/kernel/syscall/cases/clock_nanosleep_test.c 
b/testing/testsuites/kernel/syscall/cases/clock_nanosleep_test.c
index 6ae37f7da..dacb6076b 100644
--- a/testing/testsuites/kernel/syscall/cases/clock_nanosleep_test.c
+++ b/testing/testsuites/kernel/syscall/cases/clock_nanosleep_test.c
@@ -55,7 +55,7 @@ void test_nuttx_syscall_clocknanosleep01(FAR void **state)
   ret = clock_nanosleep(type, 0, &t, NULL);
   assert_int_equal(ret, 0);
   end_time = clock();
-  assert_int_equal((time_t)(end_time - start_time) / CLOCKS_PER_SEC,
+  assert_int_equal((end_time - start_time) / CLOCKS_PER_SEC,
                    t.tv_sec);
 }
 
diff --git a/testing/testsuites/kernel/syscall/cases/fsync_test.c 
b/testing/testsuites/kernel/syscall/cases/fsync_test.c
index e2834f861..d84f17937 100644
--- a/testing/testsuites/kernel/syscall/cases/fsync_test.c
+++ b/testing/testsuites/kernel/syscall/cases/fsync_test.c
@@ -238,7 +238,7 @@ void test_nuttx_syscall_fsync03(FAR void **state)
   ret = fsync(fd);
 
   time_end = time(0);
-  assert_true(time_end != (time_t)-1);
+  assert_true(time_end != -1);
   assert_int_not_equal(ret, -1);
   assert_int_equal(ret, 0);
   assert_false(time_end < time_start);
diff --git a/testing/testsuites/kernel/syscall/cases/time_test.c 
b/testing/testsuites/kernel/syscall/cases/time_test.c
index a5aea7653..1d9b35119 100644
--- a/testing/testsuites/kernel/syscall/cases/time_test.c
+++ b/testing/testsuites/kernel/syscall/cases/time_test.c
@@ -57,7 +57,7 @@ void test_nuttx_syscall_time01(FAR void **state)
 
       /* check return code */
 
-      assert_int_not_equal(ret, (time_t)-1);
+      assert_int_not_equal(ret, -1);
     }
 }
 

Reply via email to