Skip to content

Commit 98e93f7

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

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/sockaddr.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ 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],
220220
};
221221
SockAddr {
222222
storage: unsafe { storage.assume_init() },
@@ -255,7 +255,17 @@ impl From<SocketAddrV6> for SockAddr {
255255
sin6_scope_id: addr.scope_id(),
256256
#[cfg(windows)]
257257
u,
258-
..unsafe { mem::zeroed() }
258+
#[cfg(any(
259+
target_os = "dragonfly",
260+
target_os = "freebsd",
261+
target_os = "ios",
262+
target_os = "macos",
263+
target_os = "netbsd",
264+
target_os = "openbsd"
265+
))]
266+
sin6_len: 0,
267+
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
268+
__sin6_src_id: 0,
259269
};
260270
SockAddr {
261271
storage: unsafe { storage.assume_init() },

0 commit comments

Comments
 (0)