@@ -32,23 +32,8 @@ pub(super) fn recv_vectored_with_ancillary_from(
32
32
msg. msg_name = & mut msg_name as * mut _ as * mut _ ;
33
33
msg. msg_namelen = size_of :: < libc:: sockaddr_un > ( ) as libc:: socklen_t ;
34
34
msg. msg_iov = bufs. as_mut_ptr ( ) . cast ( ) ;
35
- cfg_if:: cfg_if! {
36
- if #[ cfg( any( target_os = "android" , all( target_os = "linux" , target_env = "gnu" ) ) ) ] {
37
- msg. msg_iovlen = bufs. len( ) as libc:: size_t;
38
- msg. msg_controllen = ancillary. buffer. len( ) as libc:: size_t;
39
- } else if #[ cfg( any(
40
- target_os = "dragonfly" ,
41
- target_os = "emscripten" ,
42
- target_os = "freebsd" ,
43
- all( target_os = "linux" , target_env = "musl" , ) ,
44
- target_os = "macos" ,
45
- target_os = "netbsd" ,
46
- target_os = "openbsd" ,
47
- ) ) ] {
48
- msg. msg_iovlen = bufs. len( ) as libc:: c_int;
49
- msg. msg_controllen = ancillary. buffer. len( ) as libc:: socklen_t;
50
- }
51
- }
35
+ msg. msg_iovlen = bufs. len ( ) as _ ;
36
+ msg. msg_controllen = ancillary. buffer . len ( ) as _ ;
52
37
// macos requires that the control pointer is null when the len is 0.
53
38
if msg. msg_controllen > 0 {
54
39
msg. msg_control = ancillary. buffer . as_mut_ptr ( ) . cast ( ) ;
@@ -80,23 +65,8 @@ pub(super) fn send_vectored_with_ancillary_to(
80
65
msg. msg_name = & mut msg_name as * mut _ as * mut _ ;
81
66
msg. msg_namelen = msg_namelen;
82
67
msg. msg_iov = bufs. as_ptr ( ) as * mut _ ;
83
- cfg_if:: cfg_if! {
84
- if #[ cfg( any( target_os = "android" , all( target_os = "linux" , target_env = "gnu" ) ) ) ] {
85
- msg. msg_iovlen = bufs. len( ) as libc:: size_t;
86
- msg. msg_controllen = ancillary. length as libc:: size_t;
87
- } else if #[ cfg( any(
88
- target_os = "dragonfly" ,
89
- target_os = "emscripten" ,
90
- target_os = "freebsd" ,
91
- all( target_os = "linux" , target_env = "musl" , ) ,
92
- target_os = "macos" ,
93
- target_os = "netbsd" ,
94
- target_os = "openbsd" ,
95
- ) ) ] {
96
- msg. msg_iovlen = bufs. len( ) as libc:: c_int;
97
- msg. msg_controllen = ancillary. length as libc:: socklen_t;
98
- }
99
- }
68
+ msg. msg_iovlen = bufs. len ( ) as _ ;
69
+ msg. msg_controllen = ancillary. length as _ ;
100
70
// macos requires that the control pointer is null when the len is 0.
101
71
if msg. msg_controllen > 0 {
102
72
msg. msg_control = ancillary. buffer . as_mut_ptr ( ) . cast ( ) ;
@@ -144,21 +114,7 @@ fn add_to_ancillary_data<T>(
144
114
145
115
let mut msg: libc:: msghdr = zeroed ( ) ;
146
116
msg. msg_control = buffer. as_mut_ptr ( ) . cast ( ) ;
147
- cfg_if:: cfg_if! {
148
- if #[ cfg( any( target_os = "android" , all( target_os = "linux" , target_env = "gnu" ) ) ) ] {
149
- msg. msg_controllen = * length as libc:: size_t;
150
- } else if #[ cfg( any(
151
- target_os = "dragonfly" ,
152
- target_os = "emscripten" ,
153
- target_os = "freebsd" ,
154
- all( target_os = "linux" , target_env = "musl" , ) ,
155
- target_os = "macos" ,
156
- target_os = "netbsd" ,
157
- target_os = "openbsd" ,
158
- ) ) ] {
159
- msg. msg_controllen = * length as libc:: socklen_t;
160
- }
161
- }
117
+ msg. msg_controllen = * length as _ ;
162
118
163
119
let mut cmsg = libc:: CMSG_FIRSTHDR ( & msg) ;
164
120
let mut previous_cmsg = cmsg;
@@ -180,21 +136,7 @@ fn add_to_ancillary_data<T>(
180
136
181
137
( * previous_cmsg) . cmsg_level = cmsg_level;
182
138
( * previous_cmsg) . cmsg_type = cmsg_type;
183
- cfg_if:: cfg_if! {
184
- if #[ cfg( any( target_os = "android" , all( target_os = "linux" , target_env = "gnu" ) ) ) ] {
185
- ( * previous_cmsg) . cmsg_len = libc:: CMSG_LEN ( source_len) as libc:: size_t;
186
- } else if #[ cfg( any(
187
- target_os = "dragonfly" ,
188
- target_os = "emscripten" ,
189
- target_os = "freebsd" ,
190
- all( target_os = "linux" , target_env = "musl" , ) ,
191
- target_os = "macos" ,
192
- target_os = "netbsd" ,
193
- target_os = "openbsd" ,
194
- ) ) ] {
195
- ( * previous_cmsg) . cmsg_len = libc:: CMSG_LEN ( source_len) as libc:: socklen_t;
196
- }
197
- }
139
+ ( * previous_cmsg) . cmsg_len = libc:: CMSG_LEN ( source_len) as _ ;
198
140
199
141
let data = libc:: CMSG_DATA ( previous_cmsg) . cast ( ) ;
200
142
@@ -364,28 +306,10 @@ impl<'a> AncillaryData<'a> {
364
306
365
307
fn try_from_cmsghdr ( cmsg : & ' a libc:: cmsghdr ) -> Result < Self , AncillaryError > {
366
308
unsafe {
367
- cfg_if:: cfg_if! {
368
- if #[ cfg( any(
369
- target_os = "android" ,
370
- all( target_os = "linux" , target_env = "gnu" ) ,
371
- all( target_os = "linux" , target_env = "uclibc" ) ,
372
- ) ) ] {
373
- let cmsg_len_zero = libc:: CMSG_LEN ( 0 ) as libc:: size_t;
374
- } else if #[ cfg( any(
375
- target_os = "dragonfly" ,
376
- target_os = "emscripten" ,
377
- target_os = "freebsd" ,
378
- all( target_os = "linux" , target_env = "musl" , ) ,
379
- target_os = "macos" ,
380
- target_os = "netbsd" ,
381
- target_os = "openbsd" ,
382
- ) ) ] {
383
- let cmsg_len_zero = libc:: CMSG_LEN ( 0 ) as libc:: socklen_t;
384
- }
385
- }
386
- let data_len = ( * cmsg) . cmsg_len - cmsg_len_zero;
309
+ let cmsg_len_zero = libc:: CMSG_LEN ( 0 ) as usize ;
310
+ let data_len = ( * cmsg) . cmsg_len as usize - cmsg_len_zero;
387
311
let data = libc:: CMSG_DATA ( cmsg) . cast ( ) ;
388
- let data = from_raw_parts ( data, data_len as usize ) ;
312
+ let data = from_raw_parts ( data, data_len) ;
389
313
390
314
match ( * cmsg) . cmsg_level {
391
315
libc:: SOL_SOCKET => match ( * cmsg) . cmsg_type {
@@ -419,21 +343,7 @@ impl<'a> Iterator for Messages<'a> {
419
343
unsafe {
420
344
let mut msg: libc:: msghdr = zeroed ( ) ;
421
345
msg. msg_control = self . buffer . as_ptr ( ) as * mut _ ;
422
- cfg_if:: cfg_if! {
423
- if #[ cfg( any( target_os = "android" , all( target_os = "linux" , target_env = "gnu" ) ) ) ] {
424
- msg. msg_controllen = self . buffer. len( ) as libc:: size_t;
425
- } else if #[ cfg( any(
426
- target_os = "dragonfly" ,
427
- target_os = "emscripten" ,
428
- target_os = "freebsd" ,
429
- all( target_os = "linux" , target_env = "musl" , ) ,
430
- target_os = "macos" ,
431
- target_os = "netbsd" ,
432
- target_os = "openbsd" ,
433
- ) ) ] {
434
- msg. msg_controllen = self . buffer. len( ) as libc:: socklen_t;
435
- }
436
- }
346
+ msg. msg_controllen = self . buffer . len ( ) as _ ;
437
347
438
348
let cmsg = if let Some ( current) = self . current {
439
349
libc:: CMSG_NXTHDR ( & msg, current)
0 commit comments