From 7c131be377474ed523563b0645b91c9281a33566 Mon Sep 17 00:00:00 2001 From: Stefano Garzarella Date: Wed, 13 Sep 2023 17:27:27 +0200 Subject: [PATCH 1/5] vhost: fix __IncompleteArrayField clone implementation Clippy reported the following suggestions: error: incorrect implementation of `clone` on a `Copy` type --> crates/vhost/src/vhost_kern/vhost_binding.rs:134:29 | 134 | fn clone(&self) -> Self { | _____________________________^ 135 | | Self::new() 136 | | } | |_____^ help: change this to: `{ *self }` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#incorrect_clone_impl_on_copy_type = note: `#[deny(clippy::incorrect_clone_impl_on_copy_type)]` on by default Signed-off-by: Stefano Garzarella --- crates/vhost/src/vhost_kern/vhost_binding.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/vhost/src/vhost_kern/vhost_binding.rs b/crates/vhost/src/vhost_kern/vhost_binding.rs index 5ebaa56b..c8fcbdd9 100644 --- a/crates/vhost/src/vhost_kern/vhost_binding.rs +++ b/crates/vhost/src/vhost_kern/vhost_binding.rs @@ -132,7 +132,7 @@ impl ::std::fmt::Debug for __IncompleteArrayField { impl ::std::clone::Clone for __IncompleteArrayField { #[inline] fn clone(&self) -> Self { - Self::new() + *self } } From 2b809ca2a42b8e1f7b0ed80c42ca18708d080698 Mon Sep 17 00:00:00 2001 From: Stefano Garzarella Date: Wed, 13 Sep 2023 17:32:38 +0200 Subject: [PATCH 2/5] vhost: replace if-then-else with a bool assignment Clippy reported the following suggestions: error: this if-then-else expression assigns a bool literal --> crates/vhost/src/vhost_user/backend_req_handler.rs:739:9 | 739 | / if (self.virtio_features & vflag) != 0 740 | | && self.protocol_features.contains(pflag) 741 | | && (self.acked_protocol_features & pflag.bits()) != 0 742 | | { ... | 745 | | self.reply_ack_enabled = false; 746 | | } | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_bool_assign = note: `-D clippy::needless-bool-assign` implied by `-D warnings` help: you can reduce it to | 739 ~ self.reply_ack_enabled = (self.virtio_features & vflag) != 0 740 + && self.protocol_features.contains(pflag) && (self.acked_protocol_features & pflag.bits()) != 0; | Signed-off-by: Stefano Garzarella --- crates/vhost/src/vhost_user/backend_req_handler.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/vhost/src/vhost_user/backend_req_handler.rs b/crates/vhost/src/vhost_user/backend_req_handler.rs index feb763db..7b4cbe96 100644 --- a/crates/vhost/src/vhost_user/backend_req_handler.rs +++ b/crates/vhost/src/vhost_user/backend_req_handler.rs @@ -736,14 +736,10 @@ impl BackendReqHandler { fn update_reply_ack_flag(&mut self) { let vflag = VhostUserVirtioFeatures::PROTOCOL_FEATURES.bits(); let pflag = VhostUserProtocolFeatures::REPLY_ACK; - if (self.virtio_features & vflag) != 0 + + self.reply_ack_enabled = (self.virtio_features & vflag) != 0 && self.protocol_features.contains(pflag) - && (self.acked_protocol_features & pflag.bits()) != 0 - { - self.reply_ack_enabled = true; - } else { - self.reply_ack_enabled = false; - } + && (self.acked_protocol_features & pflag.bits()) != 0; } fn new_reply_header( From b115c67950b046f7746234c9eb47eeafb21bd033 Mon Sep 17 00:00:00 2001 From: Stefano Garzarella Date: Wed, 13 Sep 2023 17:33:42 +0200 Subject: [PATCH 3/5] vhost/tests: avoid useless `vec!` usage Clippy reported the following suggestions: error: useless use of `vec!` --> crates/vhost/src/vhost_user/connection.rs:676:20 | 676 | let buf1 = vec![0x1, 0x2, 0x3, 0x4]; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[0x1, 0x2, 0x3, 0x4]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec = note: `-D clippy::useless-vec` implied by `-D warnings` error: useless use of `vec!` --> crates/vhost/src/vhost_user/connection.rs:706:20 | 706 | let buf1 = vec![0x1, 0x2, 0x3, 0x4]; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[0x1, 0x2, 0x3, 0x4]` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_vec Signed-off-by: Stefano Garzarella --- crates/vhost/src/vhost_user/connection.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/vhost/src/vhost_user/connection.rs b/crates/vhost/src/vhost_user/connection.rs index 3edda339..37335840 100644 --- a/crates/vhost/src/vhost_user/connection.rs +++ b/crates/vhost/src/vhost_user/connection.rs @@ -673,7 +673,7 @@ mod tests { let sock = listener.accept().unwrap().unwrap(); let mut backend = Endpoint::::from_stream(sock); - let buf1 = vec![0x1, 0x2, 0x3, 0x4]; + let buf1 = [0x1, 0x2, 0x3, 0x4]; let mut len = frontend.send_slice(&buf1[..], None).unwrap(); assert_eq!(len, 4); let (bytes, buf2, _) = backend.recv_into_buf(0x1000).unwrap(); @@ -703,7 +703,7 @@ mod tests { write!(fd, "test").unwrap(); // Normal case for sending/receiving file descriptors - let buf1 = vec![0x1, 0x2, 0x3, 0x4]; + let buf1 = [0x1, 0x2, 0x3, 0x4]; let len = frontend .send_slice(&buf1[..], Some(&[fd.as_raw_fd()])) .unwrap(); From 0937504cc76c1d9fc0f9356684a739429faf8a26 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:30:09 +0000 Subject: [PATCH 4/5] build(deps): bump rust-vmm-ci from `9dfe5b2` to `665f31f` Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `9dfe5b2` to `665f31f`. - [Commits](https://github.com/rust-vmm/rust-vmm-ci/compare/9dfe5b267c4009150f0cdf49597b683f15848d1a...665f31f4b4e050270604d9b534058fa9b9d39adc) --- updated-dependencies: - dependency-name: rust-vmm-ci dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- rust-vmm-ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-vmm-ci b/rust-vmm-ci index 9dfe5b26..665f31f4 160000 --- a/rust-vmm-ci +++ b/rust-vmm-ci @@ -1 +1 @@ -Subproject commit 9dfe5b267c4009150f0cdf49597b683f15848d1a +Subproject commit 665f31f4b4e050270604d9b534058fa9b9d39adc From bf45e01c6eae66565324ce29e4a81757fe7bbcf4 Mon Sep 17 00:00:00 2001 From: Stefano Garzarella Date: Wed, 13 Sep 2023 17:39:20 +0200 Subject: [PATCH 5/5] coverage: update the score After updating the CI the coverage value changed causing failures: Current code coverage (76.33%) deviates by 7.67% from the previous code coverage 84.00%. Signed-off-by: Stefano Garzarella --- coverage_config_x86_64.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage_config_x86_64.json b/coverage_config_x86_64.json index 944803a1..a0da0f5e 100644 --- a/coverage_config_x86_64.json +++ b/coverage_config_x86_64.json @@ -1,5 +1,5 @@ { - "coverage_score": 84.0, + "coverage_score": 76.3, "exclude_path": "vhost/src/vhost_kern/", "crate_features": "vhost/vhost-user-frontend,vhost/vhost-user-backend" }