Skip to content

Commit 63a2ff7

Browse files
Andrea CilibertiMeziu
authored andcommitted
Fixed conditional programming lint
1 parent 0674d90 commit 63a2ff7

File tree

2 files changed

+26
-14
lines changed

2 files changed

+26
-14
lines changed

src/unix/newlib/horizon/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ s! {
2929

3030
pub struct sockaddr_storage {
3131
pub ss_family: ::sa_family_t,
32-
pub __ss_padding: [c_char; 26usize],
32+
pub __ss_padding: [::c_char; 26usize],
3333
}
3434

3535
pub struct sockaddr_in {
3636
pub sin_family: ::sa_family_t,
3737
pub sin_port: in_port_t,
3838
pub sin_addr: ::in_addr,
39-
pub sin_zero: [::c_uchar; 8usize],
4039
}
4140

4241
pub struct sockaddr_in6 {
@@ -190,4 +189,6 @@ extern "C" {
190189
f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void,
191190
value: *mut ::c_void,
192191
) -> ::c_int;
192+
193+
pub fn gethostid() -> ::c_long;
193194
}

src/unix/newlib/mod.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ pub type off_t = i64;
1515
pub type pthread_t = ::c_ulong;
1616
pub type pthread_key_t = ::c_uint;
1717
pub type rlim_t = u32;
18-
#[cfg(not(target_os = "horizon"))]
19-
pub type sa_family_t = u8;
20-
#[cfg(target_os = "horizon")]
21-
pub type sa_family_t = u16;
18+
19+
cfg_if! {
20+
if #[cfg(target_os = "horizon")] {
21+
pub type sa_family_t = u16;
22+
} else {
23+
pub type sa_family_t = u8;
24+
}
25+
}
26+
2227
pub type socklen_t = u32;
2328
pub type speed_t = u32;
2429
pub type suseconds_t = i32;
@@ -480,10 +485,13 @@ pub const SO_SNDLOWAT: ::c_int = 0x1003;
480485
pub const SO_RCVLOWAT: ::c_int = 0x1004;
481486
pub const SO_SNDTIMEO: ::c_int = 0x1005;
482487
pub const SO_RCVTIMEO: ::c_int = 0x1006;
483-
#[cfg(not(target_os = "horizon"))]
484-
pub const SO_ERROR: ::c_int = 0x1007;
485-
#[cfg(target_os = "horizon")]
486-
pub const SO_ERROR: ::c_int = 0x1009;
488+
cfg_if! {
489+
if #[cfg(target_os = "horizon")] {
490+
pub const SO_ERROR: ::c_int = 0x1009;
491+
} else {
492+
pub const SO_ERROR: ::c_int = 0x1007;
493+
}
494+
}
487495
pub const SO_TYPE: ::c_int = 0x1008;
488496

489497
pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
@@ -518,10 +526,13 @@ pub const TCP_KEEPIDLE: ::c_int = 256;
518526
pub const TCP_KEEPINTVL: ::c_int = 512;
519527
pub const TCP_KEEPCNT: ::c_int = 1024;
520528

521-
#[cfg(not(target_os = "horizon"))]
522-
pub const IP_TOS: ::c_int = 3;
523-
#[cfg(target_os = "horizon")]
524-
pub const IP_TOS: ::c_int = 7;
529+
cfg_if! {
530+
if #[cfg(target_os = "horizon")] {
531+
pub const IP_TOS: ::c_int = 7;
532+
} else {
533+
pub const IP_TOS: ::c_int = 3;
534+
}
535+
}
525536
pub const IP_TTL: ::c_int = 8;
526537
pub const IP_MULTICAST_IF: ::c_int = 9;
527538
pub const IP_MULTICAST_TTL: ::c_int = 10;

0 commit comments

Comments
 (0)