Update load function

This commit is contained in:
Dominic Grimm 2024-11-15 21:04:09 +01:00
parent 36d2ba034c
commit 7609e94025

View file

@ -81,12 +81,8 @@ pub struct LipcApi {
impl LipcApi {
const DEFAULT_NAME: &str = "liblipc.so";
pub fn load(path: Option<&str>) -> Result<Container<Self>> {
let name = match path {
Some(x) => x,
None => Self::DEFAULT_NAME,
};
let cont: Container<Self> = unsafe { Container::load(name) }?;
pub fn load(name: Option<&str>) -> Result<Container<Self>> {
let cont: Container<Self> = 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<LipcApi>) -> Result<Self> {
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!");
}