@@ -22,7 +22,7 @@ use crate::net::{
2222use alloc:: borrow:: ToOwned ;
2323#[ cfg( feature = "alloc" ) ]
2424use alloc:: string:: String ;
25- use core:: mem:: MaybeUninit ;
25+ use core:: mem:: { size_of , MaybeUninit } ;
2626use core:: time:: Duration ;
2727use linux_raw_sys:: general:: { __kernel_old_timeval, __kernel_sock_timeval} ;
2828use linux_raw_sys:: net:: { IPV6_MTU , IPV6_MULTICAST_IF , IP_MTU , IP_MULTICAST_IF } ;
3737
3838#[ inline]
3939fn getsockopt < T : Copy > ( fd : BorrowedFd < ' _ > , level : u32 , optname : u32 ) -> io:: Result < T > {
40- let mut optlen: c:: socklen_t = core :: mem :: size_of :: < T > ( ) . try_into ( ) . unwrap ( ) ;
40+ let mut optlen: c:: socklen_t = size_of :: < T > ( ) . try_into ( ) . unwrap ( ) ;
4141 debug_assert ! (
42- optlen as usize >= core :: mem :: size_of:: <c:: c_int>( ) ,
42+ optlen as usize >= size_of:: <c:: c_int>( ) ,
4343 "Socket APIs don't ever use `bool` directly"
4444 ) ;
4545
@@ -48,7 +48,7 @@ fn getsockopt<T: Copy>(fd: BorrowedFd<'_>, level: u32, optname: u32) -> io::Resu
4848
4949 assert_eq ! (
5050 optlen as usize ,
51- core :: mem :: size_of:: <T >( ) ,
51+ size_of:: <T >( ) ,
5252 "unexpected getsockopt size"
5353 ) ;
5454
@@ -92,9 +92,9 @@ fn getsockopt_raw<T>(
9292
9393#[ inline]
9494fn setsockopt < T : Copy > ( fd : BorrowedFd < ' _ > , level : u32 , optname : u32 , value : T ) -> io:: Result < ( ) > {
95- let optlen = core :: mem :: size_of :: < T > ( ) . try_into ( ) . unwrap ( ) ;
95+ let optlen = size_of :: < T > ( ) . try_into ( ) . unwrap ( ) ;
9696 debug_assert ! (
97- optlen as usize >= core :: mem :: size_of:: <c:: c_int>( ) ,
97+ optlen as usize >= size_of:: <c:: c_int>( ) ,
9898 "Socket APIs don't ever use `bool` directly"
9999 ) ;
100100 setsockopt_raw ( fd, level, optname, & value, optlen)
@@ -883,15 +883,15 @@ pub(crate) fn xdp_mmap_offsets(fd: BorrowedFd<'_>) -> io::Result<XdpMmapOffsets>
883883 // kernel version. This works because C will layout all struct members one
884884 // after the other.
885885
886- let mut optlen = core :: mem :: size_of :: < xdp_mmap_offsets > ( ) . try_into ( ) . unwrap ( ) ;
886+ let mut optlen = size_of :: < xdp_mmap_offsets > ( ) . try_into ( ) . unwrap ( ) ;
887887 debug_assert ! (
888- optlen as usize >= core :: mem :: size_of:: <c:: c_int>( ) ,
888+ optlen as usize >= size_of:: <c:: c_int>( ) ,
889889 "Socket APIs don't ever use `bool` directly"
890890 ) ;
891891 let mut value = MaybeUninit :: < xdp_mmap_offsets > :: zeroed ( ) ;
892892 getsockopt_raw ( fd, c:: SOL_XDP , c:: XDP_MMAP_OFFSETS , & mut value, & mut optlen) ?;
893893
894- if optlen as usize == core :: mem :: size_of :: < c:: xdp_mmap_offsets_v1 > ( ) {
894+ if optlen as usize == size_of :: < c:: xdp_mmap_offsets_v1 > ( ) {
895895 // Safety: All members of xdp_mmap_offsets are u64 and thus are correctly
896896 // initialized by `MaybeUninit::<xdp_statistics>::zeroed()`
897897 let xpd_mmap_offsets = unsafe { value. assume_init ( ) } ;
@@ -924,7 +924,7 @@ pub(crate) fn xdp_mmap_offsets(fd: BorrowedFd<'_>) -> io::Result<XdpMmapOffsets>
924924 } else {
925925 assert_eq ! (
926926 optlen as usize ,
927- core :: mem :: size_of:: <xdp_mmap_offsets>( ) ,
927+ size_of:: <xdp_mmap_offsets>( ) ,
928928 "unexpected getsockopt size"
929929 ) ;
930930 // Safety: All members of xdp_mmap_offsets are u64 and thus are correctly
@@ -962,15 +962,15 @@ pub(crate) fn xdp_mmap_offsets(fd: BorrowedFd<'_>) -> io::Result<XdpMmapOffsets>
962962#[ cfg( target_os = "linux" ) ]
963963#[ inline]
964964pub ( crate ) fn xdp_statistics ( fd : BorrowedFd < ' _ > ) -> io:: Result < XdpStatistics > {
965- let mut optlen = core :: mem :: size_of :: < xdp_statistics > ( ) . try_into ( ) . unwrap ( ) ;
965+ let mut optlen = size_of :: < xdp_statistics > ( ) . try_into ( ) . unwrap ( ) ;
966966 debug_assert ! (
967- optlen as usize >= core :: mem :: size_of:: <c:: c_int>( ) ,
967+ optlen as usize >= size_of:: <c:: c_int>( ) ,
968968 "Socket APIs don't ever use `bool` directly"
969969 ) ;
970970 let mut value = MaybeUninit :: < xdp_statistics > :: zeroed ( ) ;
971971 getsockopt_raw ( fd, c:: SOL_XDP , c:: XDP_STATISTICS , & mut value, & mut optlen) ?;
972972
973- if optlen as usize == core :: mem :: size_of :: < xdp_statistics_v1 > ( ) {
973+ if optlen as usize == size_of :: < xdp_statistics_v1 > ( ) {
974974 // Safety: All members of xdp_statistics are u64 and thus are correctly
975975 // initialized by `MaybeUninit::<xdp_statistics>::zeroed()`
976976 let xdp_statistics = unsafe { value. assume_init ( ) } ;
@@ -985,7 +985,7 @@ pub(crate) fn xdp_statistics(fd: BorrowedFd<'_>) -> io::Result<XdpStatistics> {
985985 } else {
986986 assert_eq ! (
987987 optlen as usize ,
988- core :: mem :: size_of:: <xdp_statistics>( ) ,
988+ size_of:: <xdp_statistics>( ) ,
989989 "unexpected getsockopt size"
990990 ) ;
991991 // Safety: All members of xdp_statistics are u64 and thus are correctly
0 commit comments