Skip to content

Restore old time_t difference calculations #516

Merged
cgzones merged 4 commits intologrotate:masterfrom
cgzones:difftime
Jun 30, 2023
Merged

Restore old time_t difference calculations #516
cgzones merged 4 commits intologrotate:masterfrom
cgzones:difftime

Conversation

@cgzones
Copy link
Member

@cgzones cgzones commented May 5, 2023

With the introduction of difftime(3) in commit 4eb3add ("Use difftime
to compare time_t") to support platform with an unsigned time_t several
arithmetic operations and comparisons turned from integer to floating
point ones. This can lead to different results since integer divisions
round down to the next integer while floating point divisions do not.

Cast the result of difftime(3) to intmax_t to revert back to integer
operations.

Fixes: 4eb3add ("Use difftime to compare time_t")
Fixes: #514

Supersedes: #515

Additionally contains some test cases and minor changes.

cgzones added 4 commits June 7, 2023 20:21
With the introduction of difftime(3) in commit 4eb3add ("Use difftime
to compare time_t") to support platform with an unsigned time_t several
arithmetic operations and comparisons turned from integer to floating
point ones.  This can lead to different results since integer divisions
round down to the next integer while floating point divisions do not.

Cast the result of difftime(3) to intmax_t to revert back to integer
operations.

Fixes: 4eb3add ("Use difftime to compare time_t")
Fixes: logrotate#514
@cgzones cgzones merged commit 3be271a into logrotate:master Jun 30, 2023
@cgzones cgzones deleted the difftime branch June 30, 2023 17:16
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.

maxage calculation is changed

2 participants