@@ -92,7 +92,7 @@ pub mod cmsg_macros {
92
92
93
93
// TODO: In Rust 1.63 we can make this a `const fn`.
94
94
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 > ( ) )
96
96
}
97
97
98
98
pub const unsafe fn CMSG_SPACE ( len : c_uint ) -> c_uint {
@@ -113,19 +113,19 @@ pub mod cmsg_macros {
113
113
}
114
114
115
115
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.
118
119
119
120
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 ;
122
122
let max = ( ( * mhdr) . msg_control as usize ) + ( ( * mhdr) . msg_controllen as usize ) ;
123
123
124
124
if cmsg_len < size_of :: < cmsghdr > ( ) as _ {
125
125
return ptr:: null_mut ( ) ;
126
126
}
127
127
128
- if next_cmsg. offset ( 1 ) as usize > max
128
+ if next_cmsg. add ( 1 ) as usize > max
129
129
|| next_cmsg as usize + CMSG_ALIGN ( cmsg_len as _ ) as usize > max
130
130
{
131
131
return ptr:: null_mut ( ) ;
@@ -144,21 +144,21 @@ pub mod select_macros {
144
144
pub unsafe fn FD_CLR ( fd : c_int , set : * mut __kernel_fd_set ) {
145
145
let bytes = set as * mut u8 ;
146
146
if fd >= 0 {
147
- * bytes. offset ( ( fd / 8 ) as isize ) &= !( 1 << ( fd % 8 ) ) ;
147
+ * bytes. add ( ( fd / 8 ) as usize ) &= !( 1 << ( fd % 8 ) ) ;
148
148
}
149
149
}
150
150
151
151
pub unsafe fn FD_SET ( fd : c_int , set : * mut __kernel_fd_set ) {
152
152
let bytes = set as * mut u8 ;
153
153
if fd >= 0 {
154
- * bytes. offset ( ( fd / 8 ) as isize ) |= 1 << ( fd % 8 ) ;
154
+ * bytes. add ( ( fd / 8 ) as usize ) |= 1 << ( fd % 8 ) ;
155
155
}
156
156
}
157
157
158
158
pub unsafe fn FD_ISSET ( fd : c_int , set : * const __kernel_fd_set ) -> bool {
159
159
let bytes = set as * const u8 ;
160
160
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
162
162
} else {
163
163
false
164
164
}
0 commit comments