@@ -292,10 +292,7 @@ impl ProgramInfo {
292292
293293 // SANITY: `libbpf` should guarantee NUL termination.
294294 let name = util:: c_char_slice_to_cstr ( & item. name ) . unwrap ( ) ;
295- let ty = match ProgramType :: try_from ( item. type_ ) {
296- Ok ( ty) => ty,
297- Err ( _) => ProgramType :: Unknown ,
298- } ;
295+ let ty = ProgramType :: from ( item. type_ ) ;
299296
300297 if opts. include_xlated_prog_insns {
301298 xlated_prog_insns. resize ( item. xlated_prog_len as usize , 0u8 ) ;
@@ -464,10 +461,7 @@ impl MapInfo {
464461 fn from_uapi ( _fd : BorrowedFd < ' _ > , s : libbpf_sys:: bpf_map_info ) -> Option < Self > {
465462 // SANITY: `libbpf` should guarantee NUL termination.
466463 let name = util:: c_char_slice_to_cstr ( & s. name ) . unwrap ( ) ;
467- let ty = match MapType :: try_from ( s. type_ ) {
468- Ok ( ty) => ty,
469- Err ( _) => MapType :: Unknown ,
470- } ;
464+ let ty = MapType :: from ( s. type_ ) ;
471465
472466 Some ( Self {
473467 name : name. to_owned ( ) ,
@@ -673,25 +667,22 @@ impl LinkInfo {
673667 } )
674668 }
675669 libbpf_sys:: BPF_LINK_TYPE_TRACING => LinkTypeInfo :: Tracing ( TracingLinkInfo {
676- attach_type : ProgramAttachType :: try_from ( unsafe {
670+ attach_type : ProgramAttachType :: from ( unsafe {
677671 s. __bindgen_anon_1 . tracing . attach_type
678- } )
679- . unwrap_or ( ProgramAttachType :: Unknown ) ,
672+ } ) ,
680673 } ) ,
681674 libbpf_sys:: BPF_LINK_TYPE_CGROUP => LinkTypeInfo :: Cgroup ( CgroupLinkInfo {
682675 cgroup_id : unsafe { s. __bindgen_anon_1 . cgroup . cgroup_id } ,
683- attach_type : ProgramAttachType :: try_from ( unsafe {
676+ attach_type : ProgramAttachType :: from ( unsafe {
684677 s. __bindgen_anon_1 . cgroup . attach_type
685- } )
686- . unwrap_or ( ProgramAttachType :: Unknown ) ,
678+ } ) ,
687679 } ) ,
688680 libbpf_sys:: BPF_LINK_TYPE_ITER => LinkTypeInfo :: Iter ,
689681 libbpf_sys:: BPF_LINK_TYPE_NETNS => LinkTypeInfo :: NetNs ( NetNsLinkInfo {
690682 ino : unsafe { s. __bindgen_anon_1 . netns . netns_ino } ,
691- attach_type : ProgramAttachType :: try_from ( unsafe {
683+ attach_type : ProgramAttachType :: from ( unsafe {
692684 s. __bindgen_anon_1 . netns . attach_type
693- } )
694- . unwrap_or ( ProgramAttachType :: Unknown ) ,
685+ } ) ,
695686 } ) ,
696687 _ => LinkTypeInfo :: Unknown ,
697688 } ;
0 commit comments