From e12a4c062f7fe22eab6d0ec5fdc62162c46e09ae Mon Sep 17 00:00:00 2001 From: Mathieu Tarral Date: Sun, 20 Dec 2020 13:53:13 +0100 Subject: [PATCH] xen: refactor building vm_event_response_t struct --- src/driver/xen.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/driver/xen.rs b/src/driver/xen.rs index c27cf9a7..ba589134 100644 --- a/src/driver/xen.rs +++ b/src/driver/xen.rs @@ -412,12 +412,13 @@ impl Introspectable for Xen { // get the request back let vcpu_index: usize = event.vcpu.try_into()?; let req: vm_event_request_t = mem::replace(&mut self.vec_events[vcpu_index], None).unwrap(); - let mut rsp: vm_event_response_t = - unsafe { mem::MaybeUninit::::zeroed().assume_init() }; - rsp.reason = req.reason; - rsp.version = VM_EVENT_INTERFACE_VERSION; - rsp.vcpu_id = req.vcpu_id; - rsp.flags = req.flags & add_flags; + let mut rsp = vm_event_response_t { + reason: req.reason, + version: VM_EVENT_INTERFACE_VERSION, + vcpu_id: req.vcpu_id, + flags: req.flags & add_flags, + ..Default::default() + }; self.xc.put_response(&mut rsp, &mut self.back_ring)?; Ok(self.xev.xenevtchn_notify()?) }