Skip to content

De-dup timespec validation and conversion code#219

Merged
jserv merged 1 commit into
sysprog21:mainfrom
henrybear327:refactor/dedup_time_spec_code
Jul 18, 2026
Merged

De-dup timespec validation and conversion code#219
jserv merged 1 commit into
sysprog21:mainfrom
henrybear327:refactor/dedup_time_spec_code

Conversation

@henrybear327

@henrybear327 henrybear327 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary by cubic

Deduplicated Linux timespec validation and nanosecond conversion via shared helpers. Replaced open-coded logic in ppoll, pselect6, and rt_sigtimedwait for consistent EINVAL handling and saturated conversion (no behavior change).

  • Refactors
    • Exported linux_timespec_valid and linux_timespec_to_ns_sat from time.c and declared them in time.h.
    • Updated sys_ppoll, both sys_pselect6 validation paths, and signal_rt_sigtimedwait to use the helpers; added syscall/time.h includes where needed.

Written for commit 2c24204. Summary will update on new commits.

Review in cubic

@henrybear327
henrybear327 requested a review from jserv July 17, 2026 20:52

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 4 files

Re-trigger cubic

@jserv jserv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@henrybear327
henrybear327 force-pushed the refactor/dedup_time_spec_code branch from baacc82 to a219c51 Compare July 18, 2026 14:35
@henrybear327 henrybear327 changed the title Refactor duplicated timespec validation and conversion code De-dup timespec validation and conversion code Jul 18, 2026
@henrybear327
henrybear327 requested a review from jserv July 18, 2026 14:36
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
henrybear327 force-pushed the refactor/dedup_time_spec_code branch from a219c51 to 2c24204 Compare July 18, 2026 18:27
@jserv
jserv merged commit 875e849 into sysprog21:main Jul 18, 2026
10 checks passed
@henrybear327
henrybear327 deleted the refactor/dedup_time_spec_code branch July 18, 2026 21:18
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