Skip to content

Conversation

@linux-riscv-bot
Copy link

PR for series 1045293 applied to workflow__riscv__fixes

Name: pwm: th1520: fix CLIPPY=1 warning
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1045293
Version: 1

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>
@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 113.67 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1123.00 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1412.95 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 24.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 26.04 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.69 seconds
Result: WARNING
Output:

WARNING: 'arithmatic' may be misspelled - perhaps 'arithmetic'?
#35: 
Thus fix it by using saturating arithmatic, which simplifies the code
                                ^^^^^^^^^^

total: 0 errors, 1 warnings, 0 checks, 11 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit bdf23c51836f ("pwm: th1520: fix `CLIPPY=1` warning") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 0 checks, 11 lines checked
WARNING: 'arithmatic' may be misspelled - perhaps 'arithmetic'?


@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 81.60 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
kdoc
Desc: Detects for kdoc errors
Duration: 0.97 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "pwm: th1520: fix CLIPPY=1 warning"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.29 seconds
Result: PASS

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.

3 participants