Skip to content

Commit

Permalink
time: fix 32-bit integer truncation warning
Browse files Browse the repository at this point in the history
CID 1266677: (#2 of 2): Use 32-bit time_t (Y2K38_SAFETY)
1. declaration_with_small_time_t: Declare use of time_t, which is defined as 32 bits wide on this platform, while the minimum safe width is 64.

Signed-off-by: yinshengkai <[email protected]>
Signed-off-by: ligd <[email protected]>
  • Loading branch information
Gary-Hobson authored and xiaoxiang781216 committed Sep 12, 2024
1 parent f4a650a commit 62047aa
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/nuttx/clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ EXTERN volatile clock_t g_system_ticks;
#define clock_ticks2time(ts, tick) \
do \
{ \
clock_t _tick = (tick); \
(ts)->tv_sec = div_const(_tick, TICK_PER_SEC); \
clock_t _tick = (clock_t)(tick); \
(ts)->tv_sec = (time_t)div_const(_tick, TICK_PER_SEC); \
_tick -= (clock_t)(ts)->tv_sec * TICK_PER_SEC; \
(ts)->tv_nsec = _tick * NSEC_PER_TICK; \
(ts)->tv_nsec = (long)_tick * NSEC_PER_TICK; \
} \
while (0)

Expand All @@ -347,9 +347,9 @@ EXTERN volatile clock_t g_system_ticks;
do \
{ \
uint64_t _usec = (usec); \
(ts)->tv_sec = div_const(_usec, USEC_PER_SEC); \
(ts)->tv_sec = (time_t)div_const(_usec, USEC_PER_SEC); \
_usec -= (uint64_t)(ts)->tv_sec * USEC_PER_SEC; \
(ts)->tv_nsec = _usec * NSEC_PER_USEC; \
(ts)->tv_nsec = (long)_usec * NSEC_PER_USEC; \
} \
while (0)

Expand All @@ -360,9 +360,9 @@ EXTERN volatile clock_t g_system_ticks;
do \
{ \
uint64_t _nsec = (nsec); \
(ts)->tv_sec = div_const(_nsec, NSEC_PER_SEC); \
(ts)->tv_sec = (time_t)div_const(_nsec, NSEC_PER_SEC); \
_nsec -= (uint64_t)(ts)->tv_sec * NSEC_PER_SEC; \
(ts)->tv_nsec = _nsec; \
(ts)->tv_nsec = (long)_nsec; \
} \
while (0)

Expand Down

0 comments on commit 62047aa

Please sign in to comment.