GUIDINGLI opened a new pull request, #14460:
URL: https://github.com/apache/nuttx/pull/14460
## Summary
types.h: time_t as int64_t
The following code will generate errors:
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.
Advantage:
For the most POSIX applications they assume the time_t as signed and do
compare with 0.
The code will become more compatible after this modification.
Disadvantage:
year 2038 problem
Someone think time_t will be overflow when set int32_t, should think his
code should open TIME64 or handle the overflow himself.
## Impact
32 bit time_t is now signed
This will cause Y2038 problem, if your system has this problem, you should
open TIME64 or handle the overflow.
‘ put things right once and for all ’
## Testing
CI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]