File tree Expand file tree Collapse file tree 1 file changed +0
-38
lines changed
Expand file tree Collapse file tree 1 file changed +0
-38
lines changed Original file line number Diff line number Diff line change 1- use std:: any:: type_name;
21use std:: ffi:: CStr ;
32use std:: ffi:: CString ;
4- use std:: io;
53use std:: mem:: transmute;
64use std:: ops:: Deref ;
75use std:: os:: raw:: c_char;
@@ -95,42 +93,6 @@ pub fn validate_bpf_ret<T>(ptr: *mut T) -> Result<NonNull<T>> {
9593}
9694
9795
98- pub fn create_bpf_entity_checked < B : ' static , F : FnOnce ( ) -> * mut B > ( f : F ) -> Result < NonNull < B > > {
99- create_bpf_entity_checked_opt ( f) . and_then ( |ptr| {
100- ptr. ok_or_else ( || {
101- Error :: with_io_error (
102- io:: ErrorKind :: Other ,
103- format ! (
104- "bpf call {:?} returned NULL" ,
105- type_name:: <F >( ) /* this is usually a library bug, hopefully this will
106- * help diagnose the bug.
107- *
108- * One way to fix the bug might be to change to calling
109- * create_bpf_entity_checked_opt and handling Ok(None)
110- * as a meaningful value. */
111- ) ,
112- )
113- } )
114- } )
115- }
116-
117- fn create_bpf_entity_checked_opt < B : ' static , F : FnOnce ( ) -> * mut B > (
118- f : F ,
119- ) -> Result < Option < NonNull < B > > > {
120- let ptr = f ( ) ;
121- if ptr. is_null ( ) {
122- return Ok ( None ) ;
123- }
124- // SAFETY: `libbpf_get_error` is always safe to call.
125- match unsafe { libbpf_sys:: libbpf_get_error ( ptr as * const _ ) } {
126- 0 => Ok ( Some ( unsafe {
127- // SAFETY: We checked if the pointer was non null before.
128- NonNull :: new_unchecked ( ptr)
129- } ) ) ,
130- err => Err ( Error :: from_raw_os_error ( -err as i32 ) ) ,
131- }
132- }
133-
13496// Fix me, If std::sync::LazyLock is stable(https://github.com/rust-lang/rust/issues/109736).
13597pub ( crate ) struct LazyLock < T > {
13698 cell : OnceLock < T > ,
You can’t perform that action at this time.
0 commit comments