firecracker icon indicating copy to clipboard operation
firecracker copied to clipboard

fix clippy warning casting u64 to usize

Open rtczza opened this issue 1 year ago • 2 comments
trafficstars

fix clippy warning casting u64 to usize may truncate the value on targets with 32-bit wide pointer

clippy tips:

warning: casting `u64` to `usize` may truncate the value on targets with 32-bit wide pointers
   --> src/firecracker/examples/uffd/uffd_utils.rs:185:35
    |
185 |         let backing_memory_size = file_meta.len() as usize;
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: if this is intentional allow the lint with `#[allow(clippy::cast_possible_truncation)]` ...
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_possible_truncation
    = note: requested on the command line with `-W clippy::cast-possible-truncation`
help: ... or use `try_from` and handle the error accordingly
    |
185 |         let backing_memory_size = usize::try_from(file_meta.len());
    |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


rtczza avatar May 07 '24 08:05 rtczza

What modifications should I make to pass the CI/CD checks?

rtczza avatar May 16 '24 01:05 rtczza

Thank you for your contribution. Currently we don’t apply clippy to our /examples and don't play to enable this. We do not support 32-bit so this cast is safe on our targeted platforms.

JonathanWoollett-Light avatar May 20 '24 08:05 JonathanWoollett-Light

Hi @rtczza, thanks again for your contribution. As Jonathan already pointed out, without running clippy continuously on our example crates, patching individual occurrences of these casts is sadly not something we're interested in :( If you'd still like to contribute to Firecracker, maybe check out some of our good first issues?

roypat avatar Jul 15 '24 12:07 roypat