-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
#[deny(unsafe_op_in_unsafe_fn)]
in sys/sgx
#77346
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @cramertj (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. |
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.
You need to run x.py fmt
:
Diff in /checkout/library/std/src/sys/sgx/mod.rs at line 122:
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt" "--config-path" "/checkout" "--edition" "2018" "--unstable-features" "--skip-children" "--check" "/checkout/library/std/src/sys/sgx/mod.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.
pub unsafe fn strlen(mut s: *const c_char) -> usize {
let mut n = 0;
- while unsafe {*s} != 0 {
+ while unsafe { *s } != 0 {
n += 1;
s = unsafe { s.offset(1) };
}
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.
Left a few comments, but didn't go through the whole PR -- it looks like the general pattern they suggest holds in other places though, so would be good to update those too. Let me know if I can explain anything better.
library/std/src/sys/sgx/abi/tls.rs
Outdated
@@ -87,18 +87,21 @@ impl Tls { | |||
} | |||
|
|||
pub unsafe fn activate(&self) -> ActiveTls<'_> { | |||
set_tls_ptr(self as *const Tls as _); | |||
// SAFETY: External function. |
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 doesn't appear to explain why it's safe to call? I would at least want a FIXME if we can't document these functions appropriately.
@Mark-Simulacrum Fixed review comments, but couldn't figure out how to document the TLS ptr calls, so added a FIXME there. |
Please squash commits; r=me with that done. |
Run `./x.py` fmt Add reference link Fix reference link Apply review suggestions.
@Mark-Simulacrum Done. |
@bors r+ |
📌 Commit 1fb0a1d has been approved by |
☀️ Test successful - checks-actions, checks-azure |
This is part of #73904.
Enclose unsafe operations in unsafe blocks in
libstd/sys/sgx
.