De-dup timespec validation and conversion code#219
Merged
Conversation
jserv
requested changes
Jul 17, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Enforce https://cbea.ms/git-commit/
henrybear327
force-pushed
the
refactor/dedup_time_spec_code
branch
from
July 18, 2026 14:35
baacc82 to
a219c51
Compare
The kernel-style timespec validity check and nanosecond saturation conversion were open-coded independently at each timeout-bearing syscall site. poll.c used RANGE_CHECK on tv_nsec while signal.c used a direct comparison, and sigtimedwait carried its own INT64_MAX saturation block, so the four sites had drifted in form despite encoding the same hrtimer rules. Promote linux_timespec_valid and linux_timespec_to_ns_sat in src/syscall/time.c from static to exported, declare them in src/syscall/time.h, and replace every open-coded copy with a call. This leaves a single source of truth for guest timespec validation and removes ~25 lines of duplicated logic without changing behavior.
henrybear327
force-pushed
the
refactor/dedup_time_spec_code
branch
from
July 18, 2026 18:27
a219c51 to
2c24204
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Deduplicated Linux timespec validation and nanosecond conversion via shared helpers. Replaced open-coded logic in
ppoll,pselect6, andrt_sigtimedwaitfor consistentEINVALhandling and saturated conversion (no behavior change).linux_timespec_validandlinux_timespec_to_ns_satfromtime.cand declared them intime.h.sys_ppoll, bothsys_pselect6validation paths, andsignal_rt_sigtimedwaitto use the helpers; addedsyscall/time.hincludes where needed.Written for commit 2c24204. Summary will update on new commits.