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

#[deny(unsafe_op_in_unsafe_fn)] in sys/sgx #77346

Merged
merged 1 commit into from Oct 8, 2020
Merged

#[deny(unsafe_op_in_unsafe_fn)] in sys/sgx #77346

merged 1 commit into from Oct 8, 2020

Conversation

ghost
Copy link

@ghost ghost commented Sep 29, 2020

This is part of #73904.

Enclose unsafe operations in unsafe blocks in libstd/sys/sgx.

@rust-highfive
Copy link
Collaborator

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 29, 2020
@ghost
Copy link
Author

ghost commented Sep 29, 2020

r? @Mark-Simulacrum

Copy link
Member

@jyn514 jyn514 left a 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) };
     }

@jyn514 jyn514 added C-cleanup Category: PRs that clean code up or issues documenting cleanup. F-unsafe-block-in-unsafe-fn RFC #2585 T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 29, 2020
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a 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.

@@ -87,18 +87,21 @@ impl Tls {
}

pub unsafe fn activate(&self) -> ActiveTls<'_> {
set_tls_ptr(self as *const Tls as _);
// SAFETY: External function.
Copy link
Member

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.

library/std/src/sys/sgx/abi/mod.rs Outdated Show resolved Hide resolved
library/std/src/sys/sgx/abi/usercalls/alloc.rs Outdated Show resolved Hide resolved
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 30, 2020
@ghost
Copy link
Author

ghost commented Oct 6, 2020

@Mark-Simulacrum Fixed review comments, but couldn't figure out how to document the TLS ptr calls, so added a FIXME there.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 6, 2020
@Mark-Simulacrum
Copy link
Member

Please squash commits; r=me with that done.

Run `./x.py` fmt

Add reference link

Fix reference link

Apply review suggestions.
@ghost
Copy link
Author

ghost commented Oct 8, 2020

@Mark-Simulacrum Done.

@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Oct 8, 2020

📌 Commit 1fb0a1d has been approved by Mark-Simulacrum

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2020
@bors
Copy link
Contributor

bors commented Oct 8, 2020

⌛ Testing commit 1fb0a1d with merge 6b8d791...

@bors
Copy link
Contributor

bors commented Oct 8, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: Mark-Simulacrum
Pushing 6b8d791 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 8, 2020
@bors bors merged commit 6b8d791 into rust-lang:master Oct 8, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 8, 2020
@ghost ghost mentioned this pull request Oct 8, 2020
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-cleanup Category: PRs that clean code up or issues documenting cleanup. F-unsafe-block-in-unsafe-fn RFC #2585 merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants