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

fix(personality): Fix types for personality constants #1974

Closed
wants to merge 1 commit into from
Closed

fix(personality): Fix types for personality constants #1974

wants to merge 1 commit into from

Conversation

woodruffw
Copy link

First of all, thanks for these bindings!

I noticed this while working on some higher-level (nix) bindings for personality(2): these constants are passed to personality(2), which takes a c_ulong. Thus, these should also be c_ulongs, rather than c_int.

`personality(2)` takes an unsigned long instead of a signed integer,
so each of these should be `c_ulong` instead of `c_int`.
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@JohnTitor
Copy link
Member

JohnTitor commented Nov 30, 2020

You're right, sorry for the trouble!
I'd follow this but it's a breaking change, let's make some period before changing actually:

  1. Add a deprecation notice like #[deprecated(note = "This type is defined as c_int by mistake. We will change it to c_ulong in the future release")] so that the users know it.
  2. After some releases, change the type.

But if we'd consider this as bugfix, we could accept it as-is.

cc @nbaksalyar as you introduced these consts.

@woodruffw
Copy link
Author

No worries! On closer inspection, it might actually be reasonable: personality(2) takes a c_ulong but returns a c_int. Moreover the return value of personality(2) (when it isn't an error) is specified to be the previous persona, meaning that all personality values need to fit into c_int and that it's an equally valid type choice.

I'm interested in hearing what @nbaksalyar thinks, but I'd personally be okay with the current signatures in light of the above 🙂

@woodruffw
Copy link
Author

I'm gonna go ahead and close this, since I've convinced myself that the current types are correct.

@woodruffw woodruffw closed this Dec 7, 2020
@woodruffw woodruffw deleted the ww/personality-flag-types branch December 7, 2020 15:46
bors bot added a commit to nix-rust/nix that referenced this pull request Dec 19, 2020
1331: feat(sys): High-level personality(2) wrappers r=asomers a=woodruffw

Adds a high level `Persona` bitflags enum, as well as `personality::get()` and `personality::set()` for interacting with `libc::personality()`.

Closes #1330.

See also rust-lang/libc#1974.

Co-authored-by: William Woodruff <william@trailofbits.com>
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.

None yet

3 participants