Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix build warnings from use of & to create a pointer to buffer.
Use withUnsafeBytes() instead, as recommended.
  • Loading branch information
ken-broadsheet committed Apr 10, 2020
commit 4d89ac464d2d3b931cadc4a13696b32b2fd0dd3e
14 changes: 9 additions & 5 deletions XCode/Sources/Socket+File.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ import Foundation
}
var writeCounter = 0
while writeCounter < readResult {
#if os(Linux)
let writeResult = send(target, &buffer + writeCounter, readResult - writeCounter, Int32(MSG_NOSIGNAL))
#else
let writeResult = write(target, &buffer + writeCounter, readResult - writeCounter)
#endif
let writeResult = buffer.withUnsafeBytes { (ptr) -> Int in
let start = ptr.baseAddress! + writeCounter
let len = readResult - writeCounter
#if os(Linux)
return send(target, start, len, Int32(MSG_NOSIGNAL))
#else
return write(target, start, len)
#endif
}
guard writeResult > 0 else {
return Int32(writeResult)
}
Expand Down