Skip to content

Make 64-bit time_t unsigned - #8201

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
yamt:time_t-sign
Feb 27, 2023
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
yamt:time_t-sign

Conversation

@yamt

@yamt yamt commented Jan 20, 2023 •

Copy link
Copy Markdown
Contributor

Summary

  • 32-bit time_t should be unsigned because otherwise it wraps too soon. (in 2038)

  • 64-bit time_t should be unsigned because it should be consistent within NuttX.

  • While signed time_t seems more popular among other OSes, the consisitency within NuttX outweighs, IMO.

Previous attempts and discussions:
#7975
#7115
#4693
#4692

Impact

Testing

@yamt
yamt marked this pull request as draft January 20, 2023 09:55
@acassis

acassis commented Jan 23, 2023 •

Copy link
Copy Markdown
Contributor

@yamt I think it is dangerous to disable that warning because it could hidden other really issues in C++ code, maybe you can find a way to disable on temporarily to compile that file My fault, it is already only for that file. So, why did you keep this PR as draft?

@yamt
yamt marked this pull request as ready for review January 23, 2023 15:44
@yamt
yamt requested a review from xiaoxiang781216 January 23, 2023 15:44
@yamt

yamt commented Jan 23, 2023

Copy link
Copy Markdown
Contributor Author

@yamt I think it is dangerous to disable that warning because it could hidden other really issues in C++ code, maybe you can find a way to disable on temporarily to compile that file My fault, it is already only for that file. So, why did you keep this PR as draft?

just because i forgot to make it ready.

Comment thread libs/libxx/libcxx.defs Resolved
yamt added 2 commits February 27, 2023 17:15
* 32-bit time_t should be unsigned because otherwise it wraps too
  soon. (in 2038)

* 64-bit time_t should be unsigned because it should be consistent
  within NuttX.

* While signed time_t seems more popular among other OSes, the
  consisitency within NuttX outweighs, IMO.
@yamt

yamt commented Feb 27, 2023

Copy link
Copy Markdown
Contributor Author

the last push was a conflict resolution

@xiaoxiang781216
xiaoxiang781216 merged commit e9158ef into apache:master Feb 27, 2023
yamt added a commit to yamt/incubator-nuttx that referenced this pull request Dec 29, 2023
it has been changed by apache#10303
without any explicit mentions. i suppose it was a mistake.

see apache#8201 and referenced PRs
for previos discussions.
yamt added a commit to yamt/incubator-nuttx that referenced this pull request Dec 29, 2023
it has been changed by apache#10303
without any explicit mentions. i suppose it was a mistake.

see apache#8201 and referenced PRs
for previous discussions.
xiaoxiang781216 pushed a commit that referenced this pull request Dec 30, 2023
it has been changed by #10303
without any explicit mentions. i suppose it was a mistake.

see #8201 and referenced PRs
for previous discussions.
@mu578

mu578 commented Dec 31, 2023 •

Copy link
Copy Markdown

Posix time_t is signed as a consensus. Originally it triggered some controversy and debates over whether it should be signed or unsigned, the problem is not new.

Why does this consensus exist? Because if unsigned you cannot represent times prior to the Unix epoch or between another arbitrary timer value, and Posix requires it to be an integral type that's it (the grey).

Now, it has an impact on the sign comparison implementation, but it also has an impact on interpolating with other Unix-like sub-systems and/or third-party libraries (For instance, can be an issue in some network APIs if before expected hypothetical d-time computations are made expecting signed behaviors, it will forcibily trigger internal overflows if unsigned).

The truth is, there is a consensus and most people are adhering to it. Yes we know, the issue revolves around an informal practice. I think that the original change was not a random mistake, but rather an attempt to follow the consensus found in other popular projects.

For the 2038 halt date, I don't think they will be 32-bit archs running anymore by then e.g 15 years ahead of us.

casaroli pushed a commit to casaroli/nuttx that referenced this pull request Jan 25, 2024
it has been changed by apache#10303
without any explicit mentions. i suppose it was a mistake.

see apache#8201 and referenced PRs
for previous discussions.
freakishness pushed a commit to freakishness/incubator-nuttx that referenced this pull request Feb 18, 2024
it has been changed by apache#10303
without any explicit mentions. i suppose it was a mistake.

see apache#8201 and referenced PRs
for previous discussions.
halyssonJr pushed a commit to halyssonJr/nuttx that referenced this pull request Apr 10, 2024
it has been changed by apache#10303
without any explicit mentions. i suppose it was a mistake.

see apache#8201 and referenced PRs
for previous discussions.
@yamt yamt mentioned this pull request Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants