Skip to content

Commit 7e1b162

Browse files
committed
Don't borrow from packed struct on NetBSD
1 parent 9e528d3 commit 7e1b162

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/sys/unix.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,12 +1113,15 @@ from!(crate::Socket, UnixDatagram);
11131113
fn in_addr_convertion() {
11141114
let ip = Ipv4Addr::new(127, 0, 0, 1);
11151115
let raw = to_in_addr(&ip);
1116-
assert_eq!(raw.s_addr, 127 << 0 | 1 << 24);
1116+
// NOTE: `in_addr` is packed on NetBSD and it's unsafe to borrow.
1117+
let a = raw.s_addr;
1118+
assert_eq!(a, 127 << 0 | 1 << 24);
11171119
assert_eq!(from_in_addr(raw), ip);
11181120

11191121
let ip = Ipv4Addr::new(127, 34, 4, 12);
11201122
let raw = to_in_addr(&ip);
1121-
assert_eq!(raw.s_addr, 127 << 0 | 34 << 8 | 4 << 16 | 12 << 24);
1123+
let a = raw.s_addr;
1124+
assert_eq!(a, 127 << 0 | 34 << 8 | 4 << 16 | 12 << 24);
11221125
assert_eq!(from_in_addr(raw), ip);
11231126
}
11241127

0 commit comments

Comments
 (0)