@@ -92,7 +92,7 @@ pub mod cmsg_macros {
9292
9393 // TODO: In Rust 1.63 we can make this a `const fn`.
9494 pub unsafe fn CMSG_DATA ( cmsg : * const cmsghdr ) -> * mut c_uchar {
95- ( cmsg as * mut c_uchar ) . offset ( size_of :: < cmsghdr > ( ) as isize )
95+ ( cmsg as * mut c_uchar ) . add ( size_of :: < cmsghdr > ( ) )
9696 }
9797
9898 pub const unsafe fn CMSG_SPACE ( len : c_uint ) -> c_uint {
@@ -113,19 +113,19 @@ pub mod cmsg_macros {
113113 }
114114
115115 pub unsafe fn CMSG_NXTHDR ( mhdr : * const msghdr , cmsg : * const cmsghdr ) -> * mut cmsghdr {
116- // We convert from raw pointers to isize here, which may not be sound in a future version of Rust.
117- // Once the provenance rules are set in stone, it will be a good idea to give this function a once-over.
116+ // We convert from raw pointers to usize here, which may not be sound in a
117+ // future version of Rust. Once the provenance rules are set in stone,
118+ // it will be a good idea to give this function a once-over.
118119
119120 let cmsg_len = ( * cmsg) . cmsg_len ;
120- let next_cmsg =
121- ( cmsg as * mut u8 ) . offset ( CMSG_ALIGN ( cmsg_len as _ ) as isize ) as * mut cmsghdr ;
121+ let next_cmsg = ( cmsg as * mut u8 ) . add ( CMSG_ALIGN ( cmsg_len as _ ) as usize ) as * mut cmsghdr ;
122122 let max = ( ( * mhdr) . msg_control as usize ) + ( ( * mhdr) . msg_controllen as usize ) ;
123123
124124 if cmsg_len < size_of :: < cmsghdr > ( ) as _ {
125125 return ptr:: null_mut ( ) ;
126126 }
127127
128- if next_cmsg. offset ( 1 ) as usize > max
128+ if next_cmsg. add ( 1 ) as usize > max
129129 || next_cmsg as usize + CMSG_ALIGN ( cmsg_len as _ ) as usize > max
130130 {
131131 return ptr:: null_mut ( ) ;
@@ -144,21 +144,21 @@ pub mod select_macros {
144144 pub unsafe fn FD_CLR ( fd : c_int , set : * mut __kernel_fd_set ) {
145145 let bytes = set as * mut u8 ;
146146 if fd >= 0 {
147- * bytes. offset ( ( fd / 8 ) as isize ) &= !( 1 << ( fd % 8 ) ) ;
147+ * bytes. add ( ( fd / 8 ) as usize ) &= !( 1 << ( fd % 8 ) ) ;
148148 }
149149 }
150150
151151 pub unsafe fn FD_SET ( fd : c_int , set : * mut __kernel_fd_set ) {
152152 let bytes = set as * mut u8 ;
153153 if fd >= 0 {
154- * bytes. offset ( ( fd / 8 ) as isize ) |= 1 << ( fd % 8 ) ;
154+ * bytes. add ( ( fd / 8 ) as usize ) |= 1 << ( fd % 8 ) ;
155155 }
156156 }
157157
158158 pub unsafe fn FD_ISSET ( fd : c_int , set : * const __kernel_fd_set ) -> bool {
159159 let bytes = set as * const u8 ;
160160 if fd >= 0 {
161- * bytes. offset ( ( fd / 8 ) as isize ) & ( 1 << ( fd % 8 ) ) != 0
161+ * bytes. add ( ( fd / 8 ) as usize ) & ( 1 << ( fd % 8 ) ) != 0
162162 } else {
163163 false
164164 }
0 commit comments