-
Notifications
You must be signed in to change notification settings - Fork 667
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
Mark and document pty::ptsname() as unsafe #744
Conversation
Looks good, but please add a CHANGELOG entry, too. Also, you should update the commit message. |
Would thread local be global? |
f38a15a
to
373fa36
Compare
Ah, it would be. Let me update the commit message. |
373fa36
to
c02eda1
Compare
As far as Rust is concerned a thread-local global variable is still a global variable. Using a thread-local variable does not make |
CHANGELOG.md
Outdated
@@ -45,6 +45,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
- `MapFlags`, `MmapAdvise`, and `MsFlags` expose some more variants and only | |||
officially-supported variants are provided for each target. | |||
([#731](https://github.com/nix-rust/nix/pull/731)) | |||
- Marked `pty::ptsname` function to be as `unsafe` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/to be as/as/
src/pty.rs
Outdated
/// | ||
/// This value is useful for opening the slave pty once the master has already been opened with | ||
/// `posix_openpt()`. | ||
/// | ||
/// On some platforms, `ptsname()` mutates global variables and is *not* threadsafe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/On some platforms, //
c02eda1
to
f9b16a3
Compare
@asomers Changes are done. |
src/pty.rs
Outdated
/// | ||
/// This value is useful for opening the slave pty once the master has already been opened with | ||
/// `posix_openpt()`. | ||
/// | ||
/// `ptsname()` mutates global variables and is *not* threadsafe. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should go in a section named "Safety". See here for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that certainly wasn't in my original reading of the Book. I've added that. 👍
`ptsname()` mutates global variables and mutating global variables is always considered `unsafe` by Rust. Reference: nix-rust#742 (comment)
f9b16a3
to
505bed3
Compare
@Susurrus Changes are done |
@asomers Are you okay to sign off on this? LGTM! |
bors r+ |
744: Mark and document pty::ptsname() as unsafe r=asomers a=nelsonjchen On some platforms, `ptsname()` mutates global variables and mutating global variables is always considered `unsafe` by Rust. Reference: #742 (comment)
On some platforms,
ptsname()
mutates global variables and mutatingglobal variables is always considered
unsafe
by Rust.Reference:
#742 (comment)