Skip to content

Commit

Permalink
vfio-ioctls: Fix clippy warning
Browse files Browse the repository at this point in the history
error: manually reimplementing `div_ceil`
  --> crates/vfio-ioctls/src/fam.rs:12:24
   |
12 |     let rounded_size = (size_in_bytes + size_of::<T>() - 1) / size_of::<T>();
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   help: consider using `.div_ceil()`: `size_in_bytes.div_ceil(size_of::<T>())`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_div_ceil
   = note: `-D clippy::manual-div-ceil` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::manual_div_ceil)]`

Signed-off-by: Jinank Jain <jinankjain@microsoft.com>
  • Loading branch information
jinankjain authored and rbradford committed Dec 16, 2024
1 parent e71efe4 commit bdbb1cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/vfio-ioctls/src/fam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::mem::size_of;

/// Returns a `Vec<T>` with a size in bytes at least as large as `size_in_bytes`.
fn vec_with_size_in_bytes<T: Default>(size_in_bytes: usize) -> Vec<T> {
let rounded_size = (size_in_bytes + size_of::<T>() - 1) / size_of::<T>();
let rounded_size = size_in_bytes.div_ceil(size_of::<T>());
let mut v = Vec::with_capacity(rounded_size);
for _ in 0..rounded_size {
v.push(T::default())
Expand Down

0 comments on commit bdbb1cd

Please sign in to comment.