File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ extern "C" {
1212}
1313
1414/// WASI p1 uses `u16` for error codes in its witx definitions:
15- /// https://github.com/WebAssembly/WASI/blob/38454e9e22013cd00ea04916f556beb9e6d96cec /legacy/preview1/witx/typenames.witx#L39
15+ /// https://github.com/WebAssembly/WASI/blob/38454e9e /legacy/preview1/witx/typenames.witx#L34- L39
1616const MAX_ERROR_CODE : i32 = u16:: MAX as i32 ;
1717
1818#[ inline]
@@ -25,6 +25,7 @@ pub fn fill_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
2525 let ret = unsafe { random_get ( dest. as_mut_ptr ( ) as i32 , dest. len ( ) as i32 ) } ;
2626 match ret {
2727 0 => Ok ( ( ) ) ,
28+ // WASI functions should return positive error codes which are smaller than `MAX_ERROR_CODE`
2829 code if code <= MAX_ERROR_CODE => Err ( Error :: from_neg_error_code ( -code) ) ,
2930 _ => Err ( Error :: UNEXPECTED ) ,
3031 }
You can’t perform that action at this time.
0 commit comments