@@ -7,6 +7,7 @@ use libc::{timespec, time_t, c_int, c_long, intptr_t, uintptr_t};
7
7
#[ cfg( target_os = "netbsd" ) ]
8
8
use libc:: { timespec, time_t, c_long, intptr_t, uintptr_t, size_t} ;
9
9
use std:: convert:: TryInto ;
10
+ use std:: mem;
10
11
use std:: os:: unix:: io:: RawFd ;
11
12
use std:: ptr;
12
13
@@ -21,13 +22,8 @@ pub struct KEvent {
21
22
target_os = "ios" , target_os = "macos" ,
22
23
target_os = "openbsd" ) ) ]
23
24
type type_of_udata = * mut libc:: c_void ;
24
- #[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" ,
25
- target_os = "ios" , target_os = "macos" ) ) ]
26
- type type_of_data = intptr_t ;
27
25
#[ cfg( any( target_os = "netbsd" ) ) ]
28
26
type type_of_udata = intptr_t ;
29
- #[ cfg( any( target_os = "netbsd" , target_os = "openbsd" ) ) ]
30
- type type_of_data = i64 ;
31
27
32
28
#[ cfg( target_os = "netbsd" ) ]
33
29
type type_of_event_filter = u32 ;
@@ -217,15 +213,18 @@ unsafe impl Send for KEvent {
217
213
}
218
214
219
215
impl KEvent {
216
+ #[ allow( clippy:: needless_update) ] // Not needless on all platforms.
220
217
pub fn new ( ident : uintptr_t , filter : EventFilter , flags : EventFlag ,
221
218
fflags : FilterFlag , data : intptr_t , udata : intptr_t ) -> KEvent {
222
219
KEvent { kevent : libc:: kevent {
223
220
ident,
224
221
filter : filter as type_of_event_filter ,
225
222
flags : flags. bits ( ) ,
226
223
fflags : fflags. bits ( ) ,
227
- data : data as type_of_data ,
228
- udata : udata as type_of_udata
224
+ // data can be either i64 or intptr_t, depending on platform
225
+ data : data as _ ,
226
+ udata : udata as type_of_udata ,
227
+ .. unsafe { mem:: zeroed ( ) }
229
228
} }
230
229
}
231
230
@@ -328,7 +327,7 @@ fn test_struct_kevent() {
328
327
assert_eq ! ( libc:: EVFILT_READ , filter) ;
329
328
assert_eq ! ( libc:: EV_ONESHOT | libc:: EV_ADD , actual. flags( ) . bits( ) ) ;
330
329
assert_eq ! ( libc:: NOTE_CHILD | libc:: NOTE_EXIT , actual. fflags( ) . bits( ) ) ;
331
- assert_eq ! ( 0x1337 , actual. data( ) as type_of_data ) ;
330
+ assert_eq ! ( 0x1337 , actual. data( ) ) ;
332
331
assert_eq ! ( udata as type_of_udata, actual. udata( ) as type_of_udata) ;
333
332
assert_eq ! ( mem:: size_of:: <libc:: kevent>( ) , mem:: size_of:: <KEvent >( ) ) ;
334
333
}
0 commit comments