nuttx icon indicating copy to clipboard operation
nuttx copied to clipboard

time: change time_t to signed type in TIME32/64

Open GUIDINGLI opened this issue 1 year ago • 4 comments

Summary

time: change time_t to signed type in TIME32/64

It is wrong to set the time_t to uint32_t, it should be signed type, see the reference here: https://www.gnu.org/software/libc/manual/html_node/Time-Types.html

Impact

time

Testing

sim

GUIDINGLI avatar Jul 03 '24 15:07 GUIDINGLI

I think this is already 4th or 5th time the similar change is proposed in some variation. I think that such changes should be first discuss in the mailing list.

pkarashchenko avatar Jul 03 '24 18:07 pkarashchenko

Just for reference https://github.com/apache/nuttx/pull/8201

pkarashchenko avatar Jul 03 '24 18:07 pkarashchenko

Thank you for the reference @pkarashchenko I think @mu578 pointed it correctly about a consensus of using time_t as signed among other OSes and also the explanation about d-time usage for libraries. Also I think he is wrong about not have 32-bit arch around in 2038, it is just 14 years from now.

BTW, I think it is better to discuss about it in the mailing list as you suggested and later create some documentation/reference to avoid this issues come back.

acassis avatar Jul 03 '24 18:07 acassis

Open group documents that definition of time_t is not specified but is mandated in order to eventually address the year 2038 problem.

The safe path for 2038 is enabling CONFIG_SYSTEM_TIME64. Actually, we enable CONFIG_SYSTEM_TIME64 in all products, since it's very fragile to support 2038 with 32bit time_t, not only for nuttx code base, but also for the 3rd library.

There can be pros and cons to either approach and therefore I think it should be discussed at mailing list.

Thanks for requesting the review. :-)

xiaoxiang781216 avatar Jul 04 '24 02:07 xiaoxiang781216

close dup with https://github.com/apache/nuttx/pull/14273

xiaoxiang781216 avatar Oct 14 '24 19:10 xiaoxiang781216