Skip to content

Commit

Permalink
fix minor unsafe pointer type assumption issue (#397)
Browse files Browse the repository at this point in the history
Motivation:

In a test we did `assumingMemoryBound(to: in6_addr.self)` for something
that was actually bound to `UInt8`. So we should use
`bindMemory(to: in6_addr.self, count: 1)` instead

Modifications:

replace one `assumingMemoryBound` by `bindMemory`

Result:

more memory correctness is good even for tests
  • Loading branch information
weissi authored and Lukasa committed May 9, 2018
1 parent 4cbafde commit 46f2121
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Tests/NIOTests/SocketAddressTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SocketAddressTest: XCTestCase {
#endif
address.sin6_family = sa_family_t(AF_INET6)
address.sin6_addr = sampleIn6Addr.withUnsafeBytes {
$0.baseAddress!.assumingMemoryBound(to: in6_addr.self).pointee
$0.baseAddress!.bindMemory(to: in6_addr.self, capacity: 1).pointee
}

let s = address.addressDescription()
Expand Down

0 comments on commit 46f2121

Please sign in to comment.