firecracker
firecracker copied to clipboard
fix clippy warning casting u64 to usize
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());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
What modifications should I make to pass the CI/CD checks?
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.
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?