File tree 2 files changed +21
-20
lines changed 2 files changed +21
-20
lines changed Original file line number Diff line number Diff line change @@ -43,13 +43,14 @@ pub(crate) fn index_to_name(index: u32) -> io::Result<String> {
43
43
let fd = open_socket ( ) ?;
44
44
unsafe { ioctl ( fd. as_fd ( ) , SIOCGIFNAME as _ , & mut ifreq as * mut ifreq as _ ) } ?;
45
45
46
- let Some ( nul_byte) = ifreq. ifr_name . iter ( ) . position ( |char| * char == 0 ) else {
47
- return Err ( io:: Errno :: INVAL ) ;
48
- } ;
49
- let name: String = ifreq. ifr_name [ ..nul_byte]
50
- . iter ( )
51
- . map ( |v| * v as u8 as char )
52
- . collect ( ) ;
53
-
54
- Ok ( name)
46
+ if let Some ( nul_byte) = ifreq. ifr_name . iter ( ) . position ( |char| * char == 0 ) {
47
+ let name: String = ifreq. ifr_name [ ..nul_byte]
48
+ . iter ( )
49
+ . map ( |v| * v as u8 as char )
50
+ . collect ( ) ;
51
+
52
+ Ok ( name)
53
+ } else {
54
+ Err ( io:: Errno :: INVAL )
55
+ }
55
56
}
Original file line number Diff line number Diff line change @@ -42,17 +42,17 @@ pub(crate) fn index_to_name(index: u32) -> io::Result<String> {
42
42
let fd = open_socket ( ) ?;
43
43
unsafe { ioctl ( fd. as_fd ( ) , SIOCGIFNAME , & mut ifreq as * mut ifreq as _ ) } ?;
44
44
45
- let Some ( nul_byte) = unsafe { ifreq. ifr_ifrn . ifrn_name }
45
+ if let Some ( nul_byte) = unsafe { ifreq. ifr_ifrn . ifrn_name }
46
46
. iter ( )
47
47
. position ( |char| * char == 0 )
48
- else {
49
- return Err ( io :: Errno :: INVAL ) ;
50
- } ;
51
-
52
- let name = unsafe { ifreq . ifr_ifrn . ifrn_name } [ ..nul_byte ]
53
- . iter ( )
54
- . map ( |v| * v as char )
55
- . collect ( ) ;
56
-
57
- Ok ( name )
48
+ {
49
+ let name = unsafe { ifreq . ifr_ifrn . ifrn_name } [ ..nul_byte ]
50
+ . iter ( )
51
+ . map ( |v| * v as char )
52
+ . collect ( ) ;
53
+
54
+ Ok ( name )
55
+ } else {
56
+ Err ( io :: Errno :: INVAL )
57
+ }
58
58
}
You can’t perform that action at this time.
0 commit comments