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

Solaris/Illumos: use correct types for getrandom(2) flags #3090

Merged
merged 1 commit into from
Jan 28, 2023

Conversation

josephlr
Copy link
Contributor

On Solaris (and any other platform that supports it), the getrandom(2) syscall has signature:

fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;

so the flag constants (GRND_NONBLOCK, GRND_RANDOM, etc...) should be of type c_uint.

I'm not sure if this sort of "bug fix" counts as a breaking change, there weren't any Solaris/Illumos files under libc-test/semver.

Signed-off-by: Joe Richey joerichey@google.com

On Solaris (and any other platform that supports it), the `getrandom(2)`
syscall has signature:

```rust
fn getrandom(buf: *mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;
```
so the flag constants (`GRND_NONBLOCK`, `GRND_RANDOM`, etc...) should be
of type `c_uint`.

I'm not sure if this sort of "bug fix" counts as a breaking change.

Signed-off-by: Joe Richey <joerichey@google.com>
@rustbot
Copy link
Collaborator

rustbot commented Jan 26, 2023

r? @JohnTitor

(rustbot has picked a reviewer for you, use r? to override)

@rustbot
Copy link
Collaborator

rustbot commented Jan 26, 2023

Some changes occurred in solarish module

cc @jclulow, @pfmooney

Copy link
Contributor

@jclulow jclulow left a comment

Choose a reason for hiding this comment

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

This looks right to me, and critically brings this platform into line with all the other ones, which was our intent at the OS level when we added this interface with a matching signature. I think it regrettably suggests nobody actually compiled and used the code in the original PR that added these.

@josephlr
Copy link
Contributor Author

I think it regrettably suggests nobody actually compiled and used the code in the original PR that added these.

I've actually been using these flags in the getrandom crate: https://github.com/rust-random/getrandom/blob/6536b9e60c0101ba7c555af90bdfd2e47c9a5384/src/solaris_illumos.rs#L41 but we need an as cast to make the flag the right type. I'd imagine the flags are very rarely used, because most of the time, flags == 0, which works regardless of the particular integer type.

@JohnTitor
Copy link
Member

Thanks for the explanation! It makes sense to call it a bug fix if it currently needs an assertion.
@bors r+

@bors
Copy link
Contributor

bors commented Jan 28, 2023

📌 Commit 328d723 has been approved by JohnTitor

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jan 28, 2023

⌛ Testing commit 328d723 with merge 4d072b0...

@bors
Copy link
Contributor

bors commented Jan 28, 2023

☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14
Approved by: JohnTitor
Pushing 4d072b0 to master...

1 similar comment
@bors
Copy link
Contributor

bors commented Jan 28, 2023

☀️ Test successful - checks-actions, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13, checks-cirrus-freebsd-14
Approved by: JohnTitor
Pushing 4d072b0 to master...

@bors bors merged commit 4d072b0 into rust-lang:master Jan 28, 2023
@bors
Copy link
Contributor

bors commented Jan 28, 2023

👀 Test was successful, but fast-forwarding failed: 422 Changes must be made through a pull request.

@josephlr josephlr deleted the solaris branch March 12, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants