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

Add more clippy lints #75

Closed
wants to merge 4 commits into from

Conversation

szszszsz
Copy link
Member

Add more clippy rules, and fix reported issues.

Fixes #39

@szszszsz szszszsz changed the base branch from main to 62-config-set-max-credentials May 23, 2023 18:18
Comment on lines +10 to +11
clippy::expect_used,
clippy::unwrap_used
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm generally not a fan of these two.
Unwrap and Expect are pretty explicit so there is not much risk that they are used badly, and they can be more readable than abusing the type system...
And they still leave many places for panics (syscall! can very easily panic, but so can try_syscall! if the inputs are too large).

Copy link
Member Author

@szszszsz szszszsz May 24, 2023

Choose a reason for hiding this comment

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

  1. I admit I do not see entirely your point. Depends on your target, but I rather like to avoid crashing completely, and thus avoid unwraps where possible. I understand, that instead you would rather panic on any unexpected state instead, than keep the device working, but I am not convinced this is better.
  2. I plan to move syscalls to try_syscalls too, if that is useful in any way (I have 13 of them, out of 52 total).
  3. I wish try_syscall panicking would be fixed. Is this not a bug in the framework?

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. https://blog.burntsushi.net/unwrap/
  2. In opcard I use syscall when I know it can't fail
  3. https://docs.rs/trussed/latest/src/trussed/client.rs.html#747-758 if the client can't create the value and put it in the interchange, try_syscall will panic.

I do think it should instead generate an error integrated with the result.

@szszszsz szszszsz closed this in ba1ba0b May 24, 2023
@szszszsz szszszsz deleted the 39-clippy-hints branch May 25, 2023 15:20
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.

Extend compiler and clippy lints
2 participants