Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix clippy warning casting u64 to usize #4604

Closed
wants to merge 2 commits into from

Conversation

rtczza
Copy link

@rtczza rtczza commented May 7, 2024

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
Copy link
Author

rtczza commented May 16, 2024

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

@JonathanWoollett-Light
Copy link
Contributor

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.

@roypat
Copy link
Contributor

roypat commented Jul 15, 2024

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 roypat closed this Jul 15, 2024
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.

None yet

4 participants