Skip to content

Commit 425f28b

Browse files
authored
Merge pull request #445 from kbongort/FixWarnings
Fix build warnings from use of `&` to create a pointer to `buffer`.
2 parents fbffd02 + 85f1262 commit 425f28b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ All notable changes to this project will be documented in this file. Changes not
3030
- 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)
3131
- Update `SwifterTestsHttpParser` with a test for parsing bracketed query strings. ([#423](https://github.com/httpswift/swifter/pull/423)) by [@nejcvivod](https://github.com/nejcvivod)
3232
- Use `swift_version` CocoaPods DSL. ([#425](https://github.com/httpswift/swifter/pull/425)) by [@dnkoutso](https://github.com/dnkoutso)
33+
- Fix compiler warnings in Socket+File.swift for iOS, tvOS, and Linux platforms by using `withUnsafeBytes` rather than `&` to get a scoped UnsafeRawPointer.
3334

3435
# [1.4.7]
3536

XCode/Sources/Socket+File.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ import Foundation
2020
}
2121
var writeCounter = 0
2222
while writeCounter < readResult {
23-
#if os(Linux)
24-
let writeResult = send(target, &buffer + writeCounter, readResult - writeCounter, Int32(MSG_NOSIGNAL))
25-
#else
26-
let writeResult = write(target, &buffer + writeCounter, readResult - writeCounter)
27-
#endif
23+
let writeResult = buffer.withUnsafeBytes { (ptr) -> Int in
24+
let start = ptr.baseAddress! + writeCounter
25+
let len = readResult - writeCounter
26+
#if os(Linux)
27+
return send(target, start, len, Int32(MSG_NOSIGNAL))
28+
#else
29+
return write(target, start, len)
30+
#endif
31+
}
2832
guard writeResult > 0 else {
2933
return Int32(writeResult)
3034
}

0 commit comments

Comments
 (0)