Skip to content

Commit a4e0e3e

Browse files
andreeaflorescujiangliu
authored andcommitted
use default implementation instead of using unsafe zeroed()
There is no need to use unsafe code to initialize the kvm_regs structure because this one has a default implementation. Signed-off-by: Andreea Florescu <[email protected]>
1 parent 21b9ed1 commit a4e0e3e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/ioctls/vcpu.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ impl VcpuFd {
144144
/// ```
145145
#[cfg(not(any(target_arch = "arm", target_arch = "aarch64")))]
146146
pub fn get_regs(&self) -> Result<kvm_regs> {
147-
// SAFETY: kvm_regs has only POD fields which are safe to be initialized with 0s.
148-
let mut regs = unsafe { std::mem::zeroed() };
147+
let mut regs = kvm_regs::default();
149148
// SAFETY: Safe because we know that our file is a vCPU fd, we know the kernel will only
150149
// read the correct amount of memory from our pointer, and we verify the return result.
151150
let ret = unsafe { ioctl_with_mut_ref(self, KVM_GET_REGS(), &mut regs) };

0 commit comments

Comments
 (0)