mozilla / cubeb-coreaudio-rs

The audio backend of Firefox on Mac OS X.
ISC License
25 stars 10 forks source link

Fix new errors reported by clippy on Nightly #181

Closed padenot closed 2 years ago

padenot commented 2 years ago

Error log (on CI: https://github.com/mozilla/cubeb-coreaudio-rs/actions/runs/3219120272/jobs/5264095997):

error: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/backend/buffer_manager.rs:150:59
    |
150 |         let buffer_element_count = output_channel_count * buffer_size_frames as usize * 8;
    |                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `buffer_size_frames`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
    = note: `-D clippy::unnecessary-cast` implied by `-D warnings`

error: clamp-like pattern without using clamp function
   --> src/backend/mod.rs:188:5
    |
188 | /     cmp::max(
189 | |         cmp::min(latency_frames, SAFE_MAX_LATENCY_FRAMES),
190 | |         SAFE_MIN_LATENCY_FRAMES,
191 | |     )
    | |_____^ help: replace with clamp: `latency_frames.clamp(SAFE_MIN_LATENCY_FRAMES, SAFE_MAX_LATENCY_FRAMES)`
    |
    = note: clamp will panic if max < min
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_clamp
    = note: `-D clippy::manual-clamp` implied by `-D warnings`

error: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/backend/mod.rs:615:64
    |
615 |         if prev_frames_written == 0 && buffered_input_frames > input_frames_needed as usize {
    |                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `input_frames_needed`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

error: casting to the same type is unnecessary (`usize` -> `usize`)
   --> src/backend/mod.rs:617:57
    |
617 |             let popped_frames = buffered_input_frames - input_frames_needed as usize;
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `input_frames_needed`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

error: `Box::new(_)` of default value
    --> src/backend/mod.rs:3752:50
     |
3752 |         let mut device: Box = Box::new(ffi::cubeb_device::default());
     |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: use `Box::default()` instead
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#box_default
     = note: `-D clippy::box-default` implied by `-D warnings`