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

Remove getrandom(), clean up error handling #1190

Merged
merged 1 commit into from
Jan 16, 2025
Merged

Remove getrandom(), clean up error handling #1190

merged 1 commit into from
Jan 16, 2025

Conversation

cjpatton
Copy link
Collaborator

@cjpatton cjpatton commented Jan 9, 2025

Closes #955.

Use thread_rng().gen::<[u8; SEED_SIZE]>() to generate seeds rather than getrandom(). Since this method is infallible, we no longer need to propagate errors from getrandom().

@cjpatton cjpatton marked this pull request as ready for review January 9, 2025 18:20
@cjpatton cjpatton requested a review from a team as a code owner January 9, 2025 18:20
Copy link
Collaborator

@divergentdave divergentdave left a comment

Choose a reason for hiding this comment

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

FWIW, gen() and fill() are technically infallible because they're unwrapping a Result, but I think that we can ignore such failures on modern mainstream systems. Note that rand::thread_rng() also unwraps a Result during per-thread initialization -- this Result comes from getrandom.

Use `thread_rng().gen::<[u8; SEED_SIZE]>()` to generate seeds rather
than `getrandom()`. Since this method is infallible, we no longer need
to propagate errors from `getrandom()`.
@cjpatton
Copy link
Collaborator Author

Rebased.

@cjpatton cjpatton merged commit c31b0a0 into main Jan 16, 2025
6 checks passed
@cjpatton cjpatton deleted the cjpatton/955 branch January 16, 2025 23:24
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.

Do we still need getrandom?
2 participants