Skip to content

Commit b894870

Browse files
committed
Remove unnecessary unsafe in write_abort
Signed-off-by: adamperlin <[email protected]>
1 parent 92b1ca7 commit b894870

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/hyperlight_guest/src/exit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub unsafe fn abort_with_code_and_message(code: &[u8], message_ptr: *const c_cha
7171
/// over the abort sequence. For example, in the panic handler,
7272
/// we have a message of unknown length that we want to stream
7373
/// to the host, which requires sending the message in chunks
74-
pub unsafe fn write_abort(code: &[u8]) {
74+
pub fn write_abort(code: &[u8]) {
7575
outb(OutBAction::Abort as u16, code);
7676
}
7777

src/hyperlight_guest_bin/src/lib.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
149149
struct HyperlightAbortWriter;
150150
impl core::fmt::Write for HyperlightAbortWriter {
151151
fn write_str(&mut self, s: &str) -> core::fmt::Result {
152-
unsafe {
153-
write_abort(s.as_bytes());
154-
}
152+
write_abort(s.as_bytes());
155153
Ok(())
156154
}
157155
}
@@ -161,23 +159,17 @@ fn _panic_handler(info: &core::panic::PanicInfo) -> ! {
161159
let mut w = HyperlightAbortWriter;
162160

163161
// begin abort sequence by writing the error code
164-
unsafe {
165-
write_abort(&[ErrorCode::UnknownError as u8]);
166-
}
162+
write_abort(&[ErrorCode::UnknownError as u8]);
167163

168164
let write_res = write!(w, "{}", info);
169165
if write_res.is_err() {
170-
unsafe {
171-
write_abort("panic: message format failed".as_bytes());
172-
}
166+
write_abort("panic: message format failed".as_bytes());
173167
}
174168

175169
// write abort terminator to finish the abort
176170
// and signal to the host that the message can now be read
177-
unsafe {
178-
write_abort(&[0xFF]);
179-
unreachable!();
180-
}
171+
write_abort(&[0xFF]);
172+
unreachable!();
181173
}
182174

183175
// === Entrypoint ===

0 commit comments

Comments
 (0)