Skip to content

Commit ddeccef

Browse files
committed
Review comments
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent be4fda2 commit ddeccef

File tree

1 file changed

+10
-13
lines changed
  • src/hyperlight_host/src/hypervisor/virtual_machine

1 file changed

+10
-13
lines changed

src/hyperlight_host/src/hypervisor/virtual_machine/whp.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl VirtualMachine for WhpVm {
389389

390390
fn debug_regs(&self) -> Result<CommonDebugRegs> {
391391
let mut whp_debug_regs_values: [Align16<WHV_REGISTER_VALUE>; WHP_DEBUG_REGS_NAMES_LEN] =
392-
unsafe { std::mem::zeroed() };
392+
Default::default();
393393

394394
unsafe {
395395
WHvGetVirtualProcessorRegisters(
@@ -401,18 +401,15 @@ impl VirtualMachine for WhpVm {
401401
)?;
402402
}
403403

404-
WHP_DEBUG_REGS_NAMES
405-
.into_iter()
406-
.zip(whp_debug_regs_values)
407-
.collect::<Vec<(WHV_REGISTER_NAME, Align16<WHV_REGISTER_VALUE>)>>()
408-
.as_slice()
409-
.try_into()
410-
.map_err(|e| {
411-
new_error!(
412-
"Failed to convert WHP registers to CommonDebugRegs: {:?}",
413-
e
414-
)
415-
})
404+
let whp_debug_regs: [(WHV_REGISTER_NAME, Align16<WHV_REGISTER_VALUE>);
405+
WHP_DEBUG_REGS_NAMES_LEN] =
406+
std::array::from_fn(|i| (WHP_DEBUG_REGS_NAMES[i], whp_debug_regs_values[i]));
407+
whp_debug_regs.as_slice().try_into().map_err(|e| {
408+
new_error!(
409+
"Failed to convert WHP registers to CommonDebugRegs: {:?}",
410+
e
411+
)
412+
})
416413
}
417414

418415
fn set_debug_regs(&self, drs: &CommonDebugRegs) -> Result<()> {

0 commit comments

Comments
 (0)