From 99c2485d92552edb61cfb138f511eb0836e1490b Mon Sep 17 00:00:00 2001 From: ligd Date: Tue, 22 Oct 2024 00:13:52 +0800 Subject: [PATCH] types.h: time_t as int64_t 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) { ref: 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 --- include/sys/types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sys/types.h b/include/sys/types.h index 557ed051cfaa3..32328ac30f032 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -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 */