!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 <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2026-05-03 17:17:05 +08:00 committed by Xiang Xiao
parent 72837c8d26
commit a6477ec8dc
11 changed files with 33 additions and 33 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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, "",

View file

@ -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)