Fix return value for map removing/deleting

pull/326/head
tirex 2 years ago
parent 24597b15b7
commit 5b1a3ed866

@ -354,5 +354,5 @@ fn insert<K, V>(def: *mut bpf_map_def, key: &K, value: &V, flags: u64) -> Result
#[inline]
fn remove<K>(def: *mut bpf_map_def, key: &K) -> Result<(), c_long> {
let ret = unsafe { bpf_map_delete_elem(def as *mut _, key as *const _ as *const c_void) };
(ret >= 0).then(|| ()).ok_or(ret)
(ret == 0).then(|| ()).ok_or(ret)
}

@ -86,7 +86,7 @@ impl<K, V> LpmTrie<K, V> {
let ret = unsafe {
bpf_map_delete_elem(self.def.get() as *mut _, key as *const _ as *const c_void)
};
(ret >= 0).then(|| ()).ok_or(ret)
(ret == 0).then(|| ()).ok_or(ret)
}
}

Loading…
Cancel
Save