Skip to content

Commit fb838a8

Browse files
committed
chore: appease clippy
Som new complaints, mostly dealt with using `cargo clippy --fix` (except the `continue`, which I had to manually remove) Signed-off-by: Patrick Roy <[email protected]>
1 parent 8de7fe3 commit fb838a8

File tree

6 files changed

+18
-29
lines changed

6 files changed

+18
-29
lines changed

src/rebase-snap/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ enum RebaseSnapError {
4444
}
4545

4646
fn build_arg_parser<'a>() -> ArgParser<'a> {
47-
let arg_parser = ArgParser::new()
47+
ArgParser::new()
4848
.arg(
4949
Argument::new(BASE_FILE)
5050
.required(true)
@@ -56,9 +56,7 @@ fn build_arg_parser<'a>() -> ArgParser<'a> {
5656
.required(true)
5757
.takes_value(true)
5858
.help("File path of the diff mem snapshot."),
59-
);
60-
61-
arg_parser
59+
)
6260
}
6361

6462
fn get_files(args: &Arguments) -> Result<(File, File), FileError> {

src/vmm/src/cpu_config/x86_64/cpuid/intel/normalize.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ fn default_brand_string(
345345
let c = before[i];
346346
match c {
347347
b' ' => break 'outer Ok(before.split_at(i)),
348-
b'0'..=b'9' | b'.' => continue,
348+
b'0'..=b'9' | b'.' => (),
349349
_ => break,
350350
}
351351
}
@@ -373,13 +373,12 @@ fn default_brand_string(
373373
// Include frequency suffix e.g. "GHz"
374374
.chain(after.iter().copied())
375375
// Pad with 0s to `BRAND_STRING_LENGTH`
376-
.chain(
377-
std::iter::repeat(b'\0').take(
378-
BRAND_STRING_LENGTH
379-
.checked_sub(len)
380-
.ok_or(DefaultBrandStringError::Overflow)?,
381-
),
382-
)
376+
.chain(std::iter::repeat_n(
377+
b'\0',
378+
BRAND_STRING_LENGTH
379+
.checked_sub(len)
380+
.ok_or(DefaultBrandStringError::Overflow)?,
381+
))
383382
.collect::<Vec<_>>();
384383
debug_assert_eq!(brand_string.len(), BRAND_STRING_LENGTH);
385384

src/vmm/src/devices/virtio/vsock/csm/txbuf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ impl WriteVolatile for TxBuf {
142142
&mut self,
143143
buf: &VolatileSlice<B>,
144144
) -> Result<usize, VolatileMemoryError> {
145-
self.push(buf).map(|()| buf.len()).map_err(|err| {
146-
VolatileMemoryError::IOError(std::io::Error::new(std::io::ErrorKind::Other, err))
147-
})
145+
self.push(buf)
146+
.map(|()| buf.len())
147+
.map_err(|err| VolatileMemoryError::IOError(std::io::Error::other(err)))
148148
}
149149
}
150150

src/vmm/src/logger/logging.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,16 @@ impl<'de> Deserialize<'de> for LevelFilter {
234234
{
235235
use serde::de::Error;
236236
let key = String::deserialize(deserializer)?;
237-
let level = match key.to_lowercase().as_str() {
237+
238+
match key.to_lowercase().as_str() {
238239
"off" => Ok(LevelFilter::Off),
239240
"trace" => Ok(LevelFilter::Trace),
240241
"debug" => Ok(LevelFilter::Debug),
241242
"info" => Ok(LevelFilter::Info),
242243
"warn" | "warning" => Ok(LevelFilter::Warn),
243244
"error" => Ok(LevelFilter::Error),
244245
_ => Err(D::Error::custom("Invalid LevelFilter")),
245-
};
246-
level
246+
}
247247
}
248248
}
249249

src/vmm/src/vstate/kvm.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,7 @@ pub(crate) mod tests {
106106
];
107107

108108
let combined_caps = Kvm::combine_capabilities(&additional_capabilities);
109-
assert!(
110-
combined_caps
111-
.iter()
112-
.any(|c| *c == kvm_bindings::KVM_CAP_IOMMU)
113-
);
114-
assert!(
115-
!combined_caps
116-
.iter()
117-
.any(|c| *c == kvm_bindings::KVM_CAP_IOEVENTFD)
118-
);
109+
assert!(combined_caps.contains(&kvm_bindings::KVM_CAP_IOMMU));
110+
assert!(!combined_caps.contains(&kvm_bindings::KVM_CAP_IOEVENTFD));
119111
}
120112
}

src/vmm/src/vstate/vcpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl Vcpu {
140140
// _before_ running this, then there is nothing we can do.
141141
Self::TLS_VCPU_PTR.with(|cell: &VcpuCell| {
142142
if let Some(vcpu_ptr) = cell.get() {
143-
if vcpu_ptr == self as *mut Vcpu {
143+
if std::ptr::eq(vcpu_ptr, self) {
144144
Self::TLS_VCPU_PTR.with(|cell: &VcpuCell| cell.take());
145145
return Ok(());
146146
}

0 commit comments

Comments
 (0)