Skip to content

fix(aml): Fix Clippy lints - #339

Open
mkroening wants to merge 4 commits into
rust-osdev:mainfrom
mkroening:clippy
Open

fix(aml): Fix Clippy lints#339
mkroening wants to merge 4 commits into
rust-osdev:mainfrom
mkroening:clippy

Conversation

@mkroening

Copy link
Copy Markdown
Member

See the individual commits for details.

```
$ cargo clippy
warning: redundant reference in `writeln!` argument
   --> src/aml/namespace.rs:379:21
    |
379 |                     &indent_stack,
    |                     ^^^^^^^^^^^^^ help: remove the redundant `&`: `indent_stack`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#useless_borrows_in_formatting
    = note: `#[warn(clippy::useless_borrows_in_formatting)]` on by default

warning: redundant reference in `writeln!` argument
   --> src/aml/namespace.rs:400:40
    |
400 |                 writeln!(f, "{}{}{}:", &indent_stack, if end { END } else { BRANCH }, name.as_str())?;
    |                                        ^^^^^^^^^^^^^ help: remove the redundant `&`: `indent_stack`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#useless_borrows_in_formatting
```
```
$ cargo clippy
warning: this expression creates a reference which is immediately dereferenced by the compiler
   --> src/aml/object.rs:333:50
    |
333 |                 *value = String::from_utf8_lossy(&new_bytes).split('\0').next().unwrap().to_string();
    |                                                  ^^^^^^^^^^ help: change this to: `new_bytes`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#needless_borrow
    = note: `#[warn(clippy::needless_borrow)]` on by default
```
```
$ cargo clippy
warning: length comparison to zero
    --> src/aml/mod.rs:2989:83
     |
2989 |         } else if self.op == Opcode::Package || (self.op == Opcode::VarPackage && self.arguments.len() > 0) {
     |                                                                                   ^^^^^^^^^^^^^^^^^^^^^^^^ help: using `!is_empty` is clearer and more explicit: `!self.arguments.is_empty()`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#len_zero
     = note: `#[warn(clippy::len_zero)]` on by default
```
```
$ cargo clippy
warning: manually reimplementing `div_ceil`
    --> src/aml/mod.rs:2549:38
     |
2549 |           let native_accesses_needed = (field.bit_length + (field.bit_index % access_width_bits))
     |  ______________________________________^
2550 | |             .next_multiple_of(access_width_bits)
2551 | |             / access_width_bits;
     | |_______________________________^ help: consider using `.div_ceil()`: `(field.bit_length + (field.bit_index % access_width_bits)).div_ceil(access_width_bits)`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#manual_div_ceil
     = note: `#[warn(clippy::manual_div_ceil)]` on by default

warning: manually reimplementing `div_ceil`
    --> src/aml/mod.rs:2629:38
     |
2629 |           let native_accesses_needed = (field.bit_length + (field.bit_index % access_width_bits))
     |  ______________________________________^
2630 | |             .next_multiple_of(access_width_bits)
2631 | |             / access_width_bits;
     | |_______________________________^ help: consider using `.div_ceil()`: `(field.bit_length + (field.bit_index % access_width_bits)).div_ceil(access_width_bits)`
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/main/index.html#manual_div_ceil
```
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.

1 participant