summary refs log tree commit diff
path: root/qcow
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2018-12-01 17:49:30 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-03 20:32:03 -0800
commit5bbbf610828e975fd308b90543359a85ef59b67f (patch)
tree4cd736628475d702b7ac45feb2e359c3fb74d220 /qcow
parent21fb34fb937678d85e9bfa4c721ab4a29196c764 (diff)
downloadcrosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar
crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.gz
crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.bz2
crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.lz
crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.xz
crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.tar.zst
crosvm-5bbbf610828e975fd308b90543359a85ef59b67f.zip
lint: Resolve the easier clippy lints
Hopefully the changes are self-explanatory and uncontroversial. This
eliminates much of the noise from `cargo clippy` and, for my purposes,
gives me a reasonable way to use it as a tool when writing and reviewing
code.

Here is the Clippy invocation I was using:

    cargo +nightly clippy -- -W clippy::correctness -A renamed_and_removed_lints -Aclippy::{blacklisted_name,borrowed_box,cast_lossless,cast_ptr_alignment,enum_variant_names,identity_op,if_same_then_else,mut_from_ref,needless_pass_by_value,new_without_default,new_without_default_derive,or_fun_call,ptr_arg,should_implement_trait,single_match,too_many_arguments,trivially_copy_pass_by_ref,unreadable_literal,unsafe_vector_initialization,useless_transmute}

TEST=cargo check --features wl-dmabuf,gpu,usb-emulation
TEST=boot linux

Change-Id: I55eb1b4a72beb2f762480e3333a921909314a0a2
Reviewed-on: https://chromium-review.googlesource.com/1356911
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'qcow')
-rw-r--r--qcow/src/qcow.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/qcow/src/qcow.rs b/qcow/src/qcow.rs
index db138bf..640f469 100644
--- a/qcow/src/qcow.rs
+++ b/qcow/src/qcow.rs
@@ -358,11 +358,10 @@ impl QcowFile {
         }
 
         let l2_size = cluster_size / size_of::<u64>() as u64;
-        let num_clusters = div_round_up_u64(header.size, u64::from(cluster_size));
+        let num_clusters = div_round_up_u64(header.size, cluster_size);
         let num_l2_clusters = div_round_up_u64(num_clusters, l2_size);
-        let l1_clusters = div_round_up_u64(num_l2_clusters, u64::from(cluster_size));
-        let header_clusters =
-            div_round_up_u64(size_of::<QcowHeader>() as u64, u64::from(cluster_size));
+        let l1_clusters = div_round_up_u64(num_l2_clusters, cluster_size);
+        let header_clusters = div_round_up_u64(size_of::<QcowHeader>() as u64, cluster_size);
         let l1_table = VecCache::from_vec(
             raw_file
                 .read_pointer_table(
@@ -372,7 +371,7 @@ impl QcowFile {
                 ).map_err(Error::ReadingHeader)?,
         );
 
-        let num_clusters = div_round_up_u64(header.size, u64::from(cluster_size));
+        let num_clusters = div_round_up_u64(header.size, cluster_size);
         let refcount_clusters = max_refcount_clusters(
             header.refcount_order,
             cluster_size as u32,
@@ -699,7 +698,7 @@ impl QcowFile {
         let refcount_bytes = div_round_up_u64(refcount_bits, 8);
         let refcount_block_entries = cluster_size / refcount_bytes;
         let pointers_per_cluster = cluster_size / size_of::<u64>() as u64;
-        let data_clusters = div_round_up_u64(header.size, u64::from(cluster_size));
+        let data_clusters = div_round_up_u64(header.size, cluster_size);
         let l2_clusters = div_round_up_u64(data_clusters, pointers_per_cluster);
         let l1_clusters = div_round_up_u64(l2_clusters, cluster_size);
         let header_clusters = div_round_up_u64(size_of::<QcowHeader>() as u64, cluster_size);
@@ -1433,7 +1432,7 @@ where
             .read(&mut buf[..this_count])
             .map_err(Error::ReadingData)?;
         writer.write(&buf[..nread]).map_err(Error::WritingData)?;
-        read_count = read_count + nread as u64;
+        read_count += nread as u64;
         if nread == 0 || read_count == size {
             break;
         }