Skip to content

Commit

Permalink
types.h: time_t as int64_t
Browse files Browse the repository at this point in the history
The following code will generate warnings:
auto now = time(nullptr);
auto last_active_time = GetEventService(self->ctx_)->getActiveTime();
if (last_active_time + 60 * 1000 / 1000 <= now) {

src/ams/../controller/controller_timer.h: In lambda function:
src/ams/../controller/controller_timer.h:117:57: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
  117 |                 if (last_active_time + 60 * 1000 / 1000 <= now) {

reference:
https://www.gnu.org/software/libc/manual/html_node/Time-Types.html

On POSIX-conformant systems, time_t is an integer type.

Signed-off-by: ligd <[email protected]>
  • Loading branch information
GUIDINGLI committed Oct 29, 2024
1 parent 17bca89 commit 5f6286c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,10 @@ typedef uint16_t sa_family_t;

#ifdef CONFIG_SYSTEM_TIME64
typedef uint64_t clock_t;
typedef uint64_t time_t; /* Holds time in seconds */
typedef int64_t time_t; /* Holds time in seconds */
#else
typedef uint32_t clock_t;
typedef uint32_t time_t; /* Holds time in seconds */
typedef int32_t time_t; /* Holds time in seconds */
#endif
typedef int clockid_t; /* Identifies one time base source */
typedef FAR void *timer_t; /* Represents one POSIX timer */
Expand Down

0 comments on commit 5f6286c

Please sign in to comment.