-
Notifications
You must be signed in to change notification settings - Fork 2
[PW_SID:1045293] pwm: th1520: fix CLIPPY=1 warning
#1362
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
base: workflow__riscv__fixes
Are you sure you want to change the base?
Conversation
The Rust kernel code should be kept `CLIPPY=1`-clean [1].
Clippy reports:
error: this pattern reimplements `Option::unwrap_or`
--> drivers/pwm/pwm_th1520.rs:64:5
|
64 | / (match ns.checked_mul(rate_hz) {
65 | | Some(product) => product,
66 | | None => u64::MAX,
67 | | }) / NSEC_PER_SEC_U64
| |______^ help: replace with: `ns.checked_mul(rate_hz).unwrap_or(u64::MAX)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#manual_unwrap_or
= note: `-D clippy::manual-unwrap-or` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or)]`
Applying the suggestion then triggers:
error: manual saturating arithmetic
--> drivers/pwm/pwm_th1520.rs:64:5
|
64 | ns.checked_mul(rate_hz).unwrap_or(u64::MAX) / NSEC_PER_SEC_U64
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_mul`: `ns.saturating_mul(rate_hz)`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.92.0/index.html#manual_saturating_arithmetic
= note: `-D clippy::manual-saturating-arithmetic` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]`
Thus fix it by using saturating arithmatic, which simplifies the code
as well.
Link: https://rust-for-linux.com/contributing#submit-checklist-addendum [1]
Fixes: e03724a ("pwm: Add Rust driver for T-HEAD TH1520 SoC")
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
|
Patch 1: "pwm: th1520: fix |
PR for series 1045293 applied to workflow__riscv__fixes
Name: pwm: th1520: fix
CLIPPY=1warningURL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1045293
Version: 1