Skip to content

Commit 70ea5dc

Browse files
author
BillXiang
committed
safety: Add safety comment
Signed-off-by: BillXiang <[email protected]>
1 parent 7efcf39 commit 70ea5dc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

kvm-ioctls/src/ioctls/vcpu.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,10 +1698,14 @@ impl VcpuFd {
16981698
// which union field to use and the type of extension_id is 'enum sbi_ext_id'.
16991699
match unsafe { run.__bindgen_anon_1.riscv_sbi.extension_id } as u32 {
17001700
SBI_EXT_0_1_CONSOLE_PUTCHAR => {
1701+
// SAFETY: Safe because the exit_reason (which comes from the kernel) told us
1702+
// which union field to use
17011703
let ch = unsafe { run.__bindgen_anon_1.riscv_sbi.args[0] };
17021704
Ok(VcpuExit::SbiExt0_1ConsolePutchar(ch))
17031705
}
17041706
SBI_EXT_0_1_CONSOLE_GETCHAR => {
1707+
// SAFETY: Safe because the exit_reason (which comes from the kernel) told us
1708+
// which union field to use
17051709
let ch = unsafe { &mut run.__bindgen_anon_1.riscv_sbi.ret[..1] };
17061710
Ok(VcpuExit::SbiExt0_1ConsoleGetchar(ch))
17071711
}

0 commit comments

Comments
 (0)