Skip to content

Commit 239a7d9

Browse files
author
Vita Batrla
committed
refactor fix using cfg_if! (fix build)
1 parent dda32e4 commit 239a7d9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/libstd/sys_common/net.rs

+16-6
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ cfg_if::cfg_if! {
4444
target_os = "dragonfly", target_os = "freebsd",
4545
target_os = "openbsd", target_os = "netbsd",
4646
target_os = "solaris"))] {
47-
type ip_mcast_type_v4 = c_uchar;
47+
type IpV4MultiCastType = c_uchar;
4848
} else {
49-
type ip_mcast_type_v4 = c_int;
49+
type IpV4MultiCastType = c_int;
5050
}
5151
}
5252

@@ -533,20 +533,30 @@ impl UdpSocket {
533533
}
534534

535535
pub fn set_multicast_loop_v4(&self, multicast_loop_v4: bool) -> io::Result<()> {
536-
setsockopt(&self.inner, c::IPPROTO_IP, c::IP_MULTICAST_LOOP, multicast_loop_v4 as ip_mcast_type_v4)
536+
setsockopt(
537+
&self.inner,
538+
c::IPPROTO_IP,
539+
c::IP_MULTICAST_LOOP,
540+
multicast_loop_v4 as IpV4MultiCastType,
541+
)
537542
}
538543

539544
pub fn multicast_loop_v4(&self) -> io::Result<bool> {
540-
let raw: ip_mcast_type_v4 = getsockopt(&self.inner, c::IPPROTO_IP, c::IP_MULTICAST_LOOP)?;
545+
let raw: IpV4MultiCastType = getsockopt(&self.inner, c::IPPROTO_IP, c::IP_MULTICAST_LOOP)?;
541546
Ok(raw != 0)
542547
}
543548

544549
pub fn set_multicast_ttl_v4(&self, multicast_ttl_v4: u32) -> io::Result<()> {
545-
setsockopt(&self.inner, c::IPPROTO_IP, c::IP_MULTICAST_TTL, multicast_ttl_v4 as ip_mcast_type_v4)
550+
setsockopt(
551+
&self.inner,
552+
c::IPPROTO_IP,
553+
c::IP_MULTICAST_TTL,
554+
multicast_ttl_v4 as IpV4MultiCastType,
555+
)
546556
}
547557

548558
pub fn multicast_ttl_v4(&self) -> io::Result<u32> {
549-
let raw: ip_mcast_type_v4 = getsockopt(&self.inner, c::IPPROTO_IP, c::IP_MULTICAST_TTL)?;
559+
let raw: IpV4MultiCastType = getsockopt(&self.inner, c::IPPROTO_IP, c::IP_MULTICAST_TTL)?;
550560
Ok(raw as u32)
551561
}
552562

0 commit comments

Comments
 (0)