capi: check api is aligned
This commit is contained in:
parent
403ed5ed13
commit
1fa85d1e4d
2 changed files with 5 additions and 3 deletions
|
@ -107,7 +107,7 @@ pub extern "C" fn libra_error_free(error: *mut libra_error_t) -> i32 {
|
||||||
|
|
||||||
/// Function pointer definition for libra_error_write
|
/// Function pointer definition for libra_error_write
|
||||||
pub type PFN_libra_error_write =
|
pub type PFN_libra_error_write =
|
||||||
extern "C" fn(error: libra_error_t, out: *mut MaybeUninit<*mut c_char>) -> i32;
|
extern "C" fn(error: libra_error_t, out: *mut MaybeUninit<*mut c_char>) -> i32;
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
/// Writes the error message into `out`
|
/// Writes the error message into `out`
|
||||||
///
|
///
|
||||||
|
@ -194,12 +194,12 @@ impl LibrashaderError {
|
||||||
|
|
||||||
macro_rules! assert_non_null {
|
macro_rules! assert_non_null {
|
||||||
($value:ident) => {
|
($value:ident) => {
|
||||||
if $value.is_null() {
|
if $value.is_null() || !$value.is_aligned() {
|
||||||
return $crate::error::LibrashaderError::InvalidParameter(stringify!($value)).export();
|
return $crate::error::LibrashaderError::InvalidParameter(stringify!($value)).export();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
(noexport $value:ident) => {
|
(noexport $value:ident) => {
|
||||||
if $value.is_null() {
|
if $value.is_null() || !$value.is_aligned() {
|
||||||
return Err($crate::error::LibrashaderError::InvalidParameter(
|
return Err($crate::error::LibrashaderError::InvalidParameter(
|
||||||
stringify!($value),
|
stringify!($value),
|
||||||
));
|
));
|
||||||
|
@ -234,5 +234,6 @@ macro_rules! assert_some_ptr {
|
||||||
|
|
||||||
use crate::ctypes::libra_error_t;
|
use crate::ctypes::libra_error_t;
|
||||||
pub(crate) use assert_non_null;
|
pub(crate) use assert_non_null;
|
||||||
|
|
||||||
// pub(crate) use assert_some;
|
// pub(crate) use assert_some;
|
||||||
pub(crate) use assert_some_ptr;
|
pub(crate) use assert_some_ptr;
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
//! `libra_error_free`.
|
//! `libra_error_free`.
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
#![feature(try_blocks)]
|
#![feature(try_blocks)]
|
||||||
|
#![feature(pointer_is_aligned)]
|
||||||
#![feature(vec_into_raw_parts)]
|
#![feature(vec_into_raw_parts)]
|
||||||
#![deny(unsafe_op_in_unsafe_fn)]
|
#![deny(unsafe_op_in_unsafe_fn)]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue