mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
AK: Fix adding timeval/timespec
tv_usec and tv_nsec should always be less than one second.
This commit is contained in:
parent
18e8fd333c
commit
df3c8267d4
Notes:
sideshowbarker
2024-07-19 04:21:34 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/df3c8267d41 Pull-request: https://github.com/SerenityOS/serenity/pull/2973 Reviewed-by: https://github.com/awesomekling
1 changed files with 2 additions and 2 deletions
|
@ -44,7 +44,7 @@ inline void timeval_add(const TimevalType& a, const TimevalType& b, TimevalType&
|
|||
{
|
||||
result.tv_sec = a.tv_sec + b.tv_sec;
|
||||
result.tv_usec = a.tv_usec + b.tv_usec;
|
||||
if (result.tv_usec > 1'000'000) {
|
||||
if (result.tv_usec >= 1'000'000) {
|
||||
++result.tv_sec;
|
||||
result.tv_usec -= 1'000'000;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ inline void timespec_add(const TimespecType& a, const TimespecType& b, TimespecT
|
|||
{
|
||||
result.tv_sec = a.tv_sec + b.tv_sec;
|
||||
result.tv_nsec = a.tv_nsec + b.tv_nsec;
|
||||
if (result.tv_nsec > 1000'000'000) {
|
||||
if (result.tv_nsec >= 1000'000'000) {
|
||||
++result.tv_sec;
|
||||
result.tv_nsec -= 1000'000'000;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue