From 4d89ac464d2d3b931cadc4a13696b32b2fd0dd3e Mon Sep 17 00:00:00 2001 From: Kenneth Bongort Date: Fri, 10 Apr 2020 14:52:58 -0700 Subject: [PATCH 1/2] Fix build warnings from use of & to create a pointer to `buffer`. Use withUnsafeBytes() instead, as recommended. --- XCode/Sources/Socket+File.swift | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/XCode/Sources/Socket+File.swift b/XCode/Sources/Socket+File.swift index 0f9aa721..e0a9e82a 100644 --- a/XCode/Sources/Socket+File.swift +++ b/XCode/Sources/Socket+File.swift @@ -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) } From 85f126214de6db367dea75e68a603bad02612cc7 Mon Sep 17 00:00:00 2001 From: Kenneth Bongort Date: Fri, 10 Apr 2020 15:03:55 -0700 Subject: [PATCH 2/2] Add to changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78093f44..f9594919 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file. Changes not - Update `HttpParser` so it percent-encodes the URL components before initializing `URLComponents`. ([#423](https://github.com/httpswift/swifter/pull/423)) by [@nejcvivod](https://github.com/nejcvivod) - Update `SwifterTestsHttpParser` with a test for parsing bracketed query strings. ([#423](https://github.com/httpswift/swifter/pull/423)) by [@nejcvivod](https://github.com/nejcvivod) - Use `swift_version` CocoaPods DSL. ([#425](https://github.com/httpswift/swifter/pull/425)) by [@dnkoutso](https://github.com/dnkoutso) +- Fix compiler warnings in Socket+File.swift for iOS, tvOS, and Linux platforms by using `withUnsafeBytes` rather than `&` to get a scoped UnsafeRawPointer. # [1.4.7]