@@ -7,6 +7,7 @@ use libc::{timespec, time_t, c_int, c_long, intptr_t, uintptr_t};
77#[ cfg( target_os = "netbsd" ) ]
88use libc:: { timespec, time_t, c_long, intptr_t, uintptr_t, size_t} ;
99use std:: convert:: TryInto ;
10+ use std:: mem;
1011use std:: os:: unix:: io:: RawFd ;
1112use std:: ptr;
1213
@@ -21,13 +22,8 @@ pub struct KEvent {
2122 target_os = "ios" , target_os = "macos" ,
2223 target_os = "openbsd" ) ) ]
2324type 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 ;
2725#[ cfg( any( target_os = "netbsd" ) ) ]
2826type type_of_udata = intptr_t ;
29- #[ cfg( any( target_os = "netbsd" , target_os = "openbsd" ) ) ]
30- type type_of_data = i64 ;
3127
3228#[ cfg( target_os = "netbsd" ) ]
3329type type_of_event_filter = u32 ;
@@ -217,15 +213,18 @@ unsafe impl Send for KEvent {
217213}
218214
219215impl KEvent {
216+ #[ allow( clippy:: needless_update) ] // Not needless on all platforms.
220217 pub fn new ( ident : uintptr_t , filter : EventFilter , flags : EventFlag ,
221218 fflags : FilterFlag , data : intptr_t , udata : intptr_t ) -> KEvent {
222219 KEvent { kevent : libc:: kevent {
223220 ident,
224221 filter : filter as type_of_event_filter ,
225222 flags : flags. bits ( ) ,
226223 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 ( ) }
229228 } }
230229 }
231230
@@ -328,7 +327,7 @@ fn test_struct_kevent() {
328327 assert_eq ! ( libc:: EVFILT_READ , filter) ;
329328 assert_eq ! ( libc:: EV_ONESHOT | libc:: EV_ADD , actual. flags( ) . bits( ) ) ;
330329 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( ) ) ;
332331 assert_eq ! ( udata as type_of_udata, actual. udata( ) as type_of_udata) ;
333332 assert_eq ! ( mem:: size_of:: <libc:: kevent>( ) , mem:: size_of:: <KEvent >( ) ) ;
334333}
0 commit comments