check_call_opt_key: [] -> ()

(cherry picked from commit 76966c24dcf6413a4ebdfe0ddba00e3d1d7e5fff)
This commit is contained in:
Taeer Bar-Yam 2024-07-02 16:44:04 -04:00 committed by Robert Hensing
parent cc2e640e7f
commit c235b32868
2 changed files with 4 additions and 4 deletions

View file

@ -225,12 +225,12 @@ impl EvalState {
let attr_name = CString::new(attr_name) let attr_name = CString::new(attr_name)
.with_context(|| "require_attrs_select_opt: attrName contains null byte")?; .with_context(|| "require_attrs_select_opt: attrName contains null byte")?;
let v2 = unsafe { let v2 = unsafe {
check_call_opt_key!(raw::get_attr_byname[ check_call_opt_key!(raw::get_attr_byname(
&mut self.context, &mut self.context,
v.raw_ptr(), v.raw_ptr(),
self.eval_state.as_ptr(), self.eval_state.as_ptr(),
attr_name.as_ptr() attr_name.as_ptr()
]) ))
}?; }?;
Ok(v2.map(Value::new)) Ok(v2.map(Value::new))
} }

View file

@ -105,10 +105,10 @@ pub use check_call;
// TODO: Generalize this macro to work with any error code or any error handling logic // TODO: Generalize this macro to work with any error code or any error handling logic
#[macro_export] #[macro_export]
macro_rules! check_call_opt_key { macro_rules! check_call_opt_key {
($f:path[$ctx:expr, $($arg:expr),*]) => { ($($f:ident)::+($ctx:expr, $($arg:expr),*)) => {
{ {
let ctx : &mut $crate::context::Context = $ctx; let ctx : &mut $crate::context::Context = $ctx;
let ret = $f(ctx.ptr(), $($arg,)*); let ret = $($f)::*(ctx.ptr(), $($arg,)*);
if unsafe { raw::err_code(ctx.ptr()) == raw::NIX_ERR_KEY } { if unsafe { raw::err_code(ctx.ptr()) == raw::NIX_ERR_KEY } {
ctx.clear(); ctx.clear();
return Ok(None); return Ok(None);