Skip to content

Commit 1001cce

Browse files
RuoqingHeroypat
authored andcommitted
chore: Fix clippy
Fix as `doc_lazy_continuation`, `manual_c_str_literals` and `unused_must_use` clippy lints. Signed-off-by: Ruoqing He <[email protected]>
1 parent d1b3eb4 commit 1001cce

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/ioctls/system.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl Kvm {
9696
/// ```
9797
pub fn open_with_cloexec(close_on_exec: bool) -> Result<RawFd> {
9898
// SAFETY: Safe because we give a constant nul-terminated string.
99-
let kvm_path = unsafe { CStr::from_bytes_with_nul_unchecked(b"/dev/kvm\0") };
99+
let kvm_path = c"/dev/kvm";
100100
Self::open_with_cloexec_at(kvm_path, close_on_exec)
101101
}
102102

@@ -741,7 +741,7 @@ mod tests {
741741

742742
#[test]
743743
fn test_kvm_new_with_path() {
744-
let kvm_path = unsafe { CStr::from_bytes_with_nul_unchecked(b"/dev/kvm\0") };
744+
let kvm_path = c"/dev/kvm";
745745
Kvm::new_with_path(kvm_path).unwrap();
746746
}
747747

@@ -981,6 +981,6 @@ mod tests {
981981

982982
// Don't drop the File object, or it'll notice the file it's trying to close is
983983
// invalid and abort the process.
984-
faulty_kvm.kvm.into_raw_fd();
984+
let _ = faulty_kvm.kvm.into_raw_fd();
985985
}
986986
}

src/ioctls/vcpu.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,6 @@ impl VcpuFd {
10881088
target_arch = "arm",
10891089
target_arch = "aarch64"
10901090
))]
1091-
10921091
pub fn set_vcpu_events(&self, vcpu_events: &kvm_vcpu_events) -> Result<()> {
10931092
// SAFETY: Here we trust the kernel not to read past the end of the kvm_vcpu_events struct.
10941093
let ret = unsafe { ioctl_with_ref(self, KVM_SET_VCPU_EVENTS(), vcpu_events) };
@@ -1639,7 +1638,7 @@ impl VcpuFd {
16391638
/// # Arguments
16401639
///
16411640
/// * `freq` - The frequency unit is KHz as per the KVM API documentation
1642-
/// for `KVM_SET_TSC_KHZ`.
1641+
/// for `KVM_SET_TSC_KHZ`.
16431642
///
16441643
/// # Example
16451644
///
@@ -2575,7 +2574,7 @@ mod tests {
25752574

25762575
// Don't drop the File object, or it'll notice the file it's trying to close is
25772576
// invalid and abort the process.
2578-
faulty_vcpu_fd.vcpu.into_raw_fd();
2577+
let _ = faulty_vcpu_fd.vcpu.into_raw_fd();
25792578
}
25802579

25812580
#[test]
@@ -2699,7 +2698,7 @@ mod tests {
26992698

27002699
// Don't drop the File object, or it'll notice the file it's trying to close is
27012700
// invalid and abort the process.
2702-
faulty_vcpu_fd.vcpu.into_raw_fd();
2701+
let _ = faulty_vcpu_fd.vcpu.into_raw_fd();
27032702
}
27042703

27052704
#[test]

src/ioctls/vm.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,8 +913,7 @@ impl VmFd {
913913
// For ease of access we are saving the bitmap in a u64 vector. We are using ceil to
914914
// make sure we count all dirty pages even when `memory_size` is not a multiple of
915915
// `page_size * 64`.
916-
let div_ceil = |dividend, divisor| (dividend + divisor - 1) / divisor;
917-
let bitmap_size = div_ceil(memory_size, page_size * 64);
916+
let bitmap_size = memory_size.div_ceil(page_size * 64);
918917
let mut bitmap = vec![0u64; bitmap_size];
919918
let dirtylog = kvm_dirty_log {
920919
slot,
@@ -2406,7 +2405,7 @@ mod tests {
24062405

24072406
// Don't drop the File object, or it'll notice the file it's trying to close is
24082407
// invalid and abort the process.
2409-
faulty_vm_fd.vm.into_raw_fd();
2408+
let _ = faulty_vm_fd.vm.into_raw_fd();
24102409
}
24112410

24122411
#[test]

0 commit comments

Comments
 (0)