guard: fix return types as u32

This commit is contained in:
Alex Shelkovnykov 2024-02-20 08:50:17 +08:00
parent 2d0139ff13
commit c40b4ede7f
3 changed files with 8 additions and 9 deletions

View File

@ -2,7 +2,6 @@ use crate::interpreter::{Error, Mote, Result};
use crate::noun::D;
use ares_guard::*;
use assert_no_alloc::permit_alloc;
use std::convert::TryFrom;
use std::ffi::c_void;
use std::marker::PhantomData;
@ -86,7 +85,7 @@ pub fn call_with_guard<F: FnMut() -> Result>(
*result_box
})
} else {
let err = GuardError::from(u32::try_from(res).unwrap());
let err = GuardError::from(res);
match err {
GuardError::OutOfMemory => Err(Error::NonDeterministic(Mote::Meme, D(0))),
_ => {

View File

@ -36,7 +36,7 @@ struct _GD_state {
static GD_state *_guard_state = NULL;
static int32_t
static uint32_t
_prot_page(void *address, int prot)
{
if (mprotect(address, GD_PAGE_SIZE, prot)) {
@ -48,13 +48,13 @@ _prot_page(void *address, int prot)
return 0;
}
static int32_t
static uint32_t
_mark_page(void *address)
{
return _prot_page(address, PROT_NONE);
}
static int32_t
static uint32_t
_unmark_page(void *address)
{
return _prot_page(address, PROT_READ | PROT_WRITE);
@ -63,7 +63,7 @@ _unmark_page(void *address)
/**
* Center the guard page.
*/
static int32_t
static uint32_t
_focus_guard(GD_state *gs) {
uintptr_t *guard_pp = &(gs->guard_p);
uintptr_t stack_p = *(gs->stack_pp);
@ -139,7 +139,7 @@ _signal_handler(int sig, siginfo_t *si, void *unused)
}
}
int32_t
uint32_t
_register_handler(GD_state *gs)
{
struct sigaction sa;
@ -165,7 +165,7 @@ _register_handler(GD_state *gs)
return 0;
}
int32_t
uint32_t
guard(
callback f,
void *closure,

View File

@ -46,7 +46,7 @@ typedef void *(*callback)(void *);
* error will be written to the `ret` pointer. The caller is then responsible
* for handling this error and aborting with a `bail:meme`.
*/
int32_t
uint32_t
guard(
callback f,
void *closure,