From 7609e94025a5079d69def99d58488113f1321076 Mon Sep 17 00:00:00 2001 From: Dominic Grimm Date: Fri, 15 Nov 2024 21:04:09 +0100 Subject: [PATCH] Update load function --- src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 02a4669..4eb12f3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,12 +81,8 @@ pub struct LipcApi { impl LipcApi { const DEFAULT_NAME: &str = "liblipc.so"; - pub fn load(path: Option<&str>) -> Result> { - let name = match path { - Some(x) => x, - None => Self::DEFAULT_NAME, - }; - let cont: Container = unsafe { Container::load(name) }?; + pub fn load(name: Option<&str>) -> Result> { + let cont: Container = unsafe { Container::load(name.unwrap_or(Self::DEFAULT_NAME)) }?; Ok(cont) } @@ -99,8 +95,8 @@ pub struct Lipc { impl Lipc { pub fn new(api: Container) -> Result { - let lipc = unsafe { (api.lipc_open_no_name)() }; - if lipc == (std::ptr::null_mut() as *mut c_void) { + let lipc: *mut LipcType = unsafe { (api.lipc_open_no_name)() }; + if lipc == std::ptr::null_mut() { bail!("Failed to create connection!"); }