Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: fix clock_settime 8-1 test case #927

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ZhangYet
Copy link

Compare with nanoseconds

Signed-off-by: Dante Zhang [email protected]

Signed-off-by: Dante Zhang <[email protected]>
@@ -36,8 +36,5 @@ static inline long timespec_nsec_diff(struct timespec *t1, struct timespec *t2)
sec_diff = t1->tv_sec - t2->tv_sec;
nsec_diff = t1->tv_nsec - t2->tv_nsec;

if (sec_diff > 1 || (sec_diff == 1 && nsec_diff >= 0))
return NSEC_IN_SEC;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that this is a good idea to remove this check as it is. The function returns long, which is 32bit on x86 which means that the result will overflow if the difference is slightly over 2 seconds.

It would make much more sense to add timespec_msec_diff() function that would return difference in miliseconds, which would be granular enough for the check in the test, but will not overflow like this, since we can store difference worth of days in 32bit integer in miliseconds.

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.

2 participants