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

use_file: Use AtomicI32 instead of AtomicUsize to avoid conversions. #480

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

briansmith
Copy link
Contributor

All the targets that use use_file support AtomicI32. Using AtomicI32 eliminates as conversions and thus avoids any possibility of truncation or confusion between FD_UNINIT and a valid file descriptor.

Use -1 as the sentinel value for FD_UNINIT since libstd (only) guarantees that -1 is not a valid file descriptor value.

Minimize the scope of FD_UNINIT.

All the targets that use `use_file` support `AtomicI32`. Using
`AtomicI32` eliminates `as` conversions and thus avoids any
possibility of truncation or confusion between `FD_UNINIT` and a
valid file descriptor.

Use -1 as the sentinel value for `FD_UNINIT` since libstd (only)
guarantees that -1 is not a valid file descriptor value.

Minimize the scope of `FD_UNINIT`.
@newpavlov newpavlov merged commit 480d6b0 into rust-random:master Jun 17, 2024
54 checks passed
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