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

Clippy cleanup #1244

Merged
merged 9 commits into from Jul 3, 2020
Merged

Clippy cleanup #1244

merged 9 commits into from Jul 3, 2020

Conversation

asomers
Copy link
Member

@asomers asomers commented May 16, 2020

Reported-by: Clippy

@asomers asomers changed the title Fix an unaligned pointer read in Inotify::read_events Clippy cleanup May 17, 2020
@asomers
Copy link
Member Author

asomers commented May 17, 2020

@kamalmarhubi @Susurrus @posborne could one of you please review this PR? I especially would like some review for the commits that make previously unsafe functions safe. This PR eliminates almost all of the outstanding clippy issues. It would be great to enable clippy in CI.

@kamalmarhubi
Copy link
Member

I took a quick look, but I think realistically I want to do a closer read, especially since it's been a while since I worked in this codebase. I'll aim to do that in the next few days, by the end of the week at the latest. Does that work?

@asomers
Copy link
Member Author

asomers commented May 19, 2020

Yeah; there's no urgency.

Copy link
Contributor

@Susurrus Susurrus left a comment

Choose a reason for hiding this comment

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

Haven't finished yet, just went through the first commit, but that one LGTM.

@@ -173,6 +173,7 @@ libc_bitflags! {
since="0.10.0",
note="usages of `ptrace()` should be replaced with the specialized helper functions instead"
)]
#[allow(clippy::missing_safety_doc)] // It's deprecated anyway
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason we shouldn't just remove this API at this point? It's been 2.5 years at this point. I'd imagine if we've had at least two releases and it's been at least a year we can probably remove deprecated APIs.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I'll take it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I removed it. But I decided to remove some other stuff, too, and created a new PR: #1255 .

Copy link
Contributor

@Susurrus Susurrus left a comment

Choose a reason for hiding this comment

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

Other than those things to review, looks good to me!

addr: &sockaddr_storage,
len: usize) -> Result<SockAddr> {

assert!(len <= mem::size_of::<sockaddr_un>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Or debug_assert!? Not certain when you should use which. If we expect this to be on a hot-path might be worth using debug_assert here instead. Otherwise assert is probably fine.

Copy link
Member Author

Choose a reason for hiding this comment

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

My usual habit is to use debug_assert for inputs that came from inside of the module, and assert for inputs that cam from outside.

@asomers asomers force-pushed the clippy_16_may_2020 branch 2 times, most recently from 9eae5de to 5079325 Compare June 12, 2020 20:38
@asomers
Copy link
Member Author

asomers commented Jun 12, 2020

bors r+

bors bot added a commit that referenced this pull request Jun 12, 2020
1244: Clippy cleanup r=asomers a=asomers

Reported-by: Clippy

Co-authored-by: Alan Somers <asomers@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jun 12, 2020

Build failed:

@asomers
Copy link
Member Author

asomers commented Jun 12, 2020

bors retry

bors bot added a commit that referenced this pull request Jun 12, 2020
1244: Clippy cleanup r=asomers a=asomers

Reported-by: Clippy

Co-authored-by: Alan Somers <asomers@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jun 12, 2020

Build failed:

@asomers
Copy link
Member Author

asomers commented Jun 13, 2020

redoxer hanged again. I think I'll disable the Redox build if we can't get that issue fixed.

bors retry

bors bot added a commit that referenced this pull request Jun 13, 2020
1244: Clippy cleanup r=asomers a=asomers

Reported-by: Clippy

Co-authored-by: Alan Somers <asomers@gmail.com>
@bors
Copy link
Contributor

bors bot commented Jun 13, 2020

Build failed:

@asomers
Copy link
Member Author

asomers commented Jun 27, 2020

bors retry

@bors
Copy link
Contributor

bors bot commented Jun 27, 2020

Merge conflict.

It already fully validated its arguments, so there's no need for it to
be `unsafe`.
It's small and `Copy`, so pass by value is more efficient.  This is
technically a breaking change, but most code should compile without
changes.
All it does is assign a value to a thread-local int.  There's nothing
unsafe about that.
It was only marked unsafe because it did a pointer cast, but that
particular pointer cast is always allowed by C.
@asomers
Copy link
Member Author

asomers commented Jun 27, 2020

rebased to fix merge conflict and also fix a formatting error in CHANGELOG

@asomers
Copy link
Member Author

asomers commented Jul 3, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented Jul 3, 2020

Build succeeded:

@bors bors bot merged commit 6f0ca03 into nix-rust:master Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants