Skip to content

Commit 7cef159

Browse files
committed
Replace ..mem::zeroed() with conditional real fields
1 parent 2c084f0 commit 7cef159

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/sockaddr.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,16 @@ impl From<SocketAddrV4> for SockAddr {
216216
sin_family: AF_INET as sa_family_t,
217217
sin_port: addr.port().to_be(),
218218
sin_addr,
219-
..unsafe { mem::zeroed() }
219+
sin_zero: [0; 8],
220+
#[cfg(any(
221+
target_os = "dragonfly",
222+
target_os = "freebsd",
223+
target_os = "ios",
224+
target_os = "macos",
225+
target_os = "netbsd",
226+
target_os = "openbsd"
227+
))]
228+
sin_len: 0,
220229
};
221230
SockAddr {
222231
storage: unsafe { storage.assume_init() },
@@ -255,7 +264,17 @@ impl From<SocketAddrV6> for SockAddr {
255264
sin6_scope_id: addr.scope_id(),
256265
#[cfg(windows)]
257266
u,
258-
..unsafe { mem::zeroed() }
267+
#[cfg(any(
268+
target_os = "dragonfly",
269+
target_os = "freebsd",
270+
target_os = "ios",
271+
target_os = "macos",
272+
target_os = "netbsd",
273+
target_os = "openbsd"
274+
))]
275+
sin6_len: 0,
276+
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
277+
__sin6_src_id: 0,
259278
};
260279
SockAddr {
261280
storage: unsafe { storage.assume_init() },

0 commit comments

Comments
 (0)