diff --git a/Sources/NIO/Selector.swift b/Sources/NIO/Selector.swift index 4a85a43c..8ed55505 100644 --- a/Sources/NIO/Selector.swift +++ b/Sources/NIO/Selector.swift @@ -28,8 +28,8 @@ private extension timespec { init(timeAmount amount: TimeAmount) { let nsecPerSec: Int = 1_000_000_000 let ns = amount.nanoseconds - self.tv_sec = ns / nsecPerSec - self.tv_nsec = ns - self.tv_sec * nsecPerSec + let sec = ns / nsecPerSec + self = timespec(tv_sec: sec, tv_nsec: ns - sec * nsecPerSec) } } diff --git a/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests+XCTest.swift b/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests+XCTest.swift index 61ccfd85..2b9dd4ca 100644 --- a/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests+XCTest.swift +++ b/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests+XCTest.swift @@ -26,7 +26,7 @@ extension NIOConcurrencyHelpersTests { static var allTests : [(String, (NIOConcurrencyHelpersTests) -> () throws -> Void)] { return [ - ("testLargeContentedAtomicSum", testLargeContentedAtomicSum), + ("testLargeContendedAtomicSum", testLargeContendedAtomicSum), ("testCompareAndExchangeBool", testCompareAndExchangeBool), ("testAllOperationsBool", testAllOperationsBool), ("testCompareAndExchangeUInts", testCompareAndExchangeUInts), diff --git a/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests.swift b/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests.swift index b7b33643..606cacb3 100644 --- a/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests.swift +++ b/Tests/NIOConcurrencyHelpersTests/NIOConcurrencyHelpersTests.swift @@ -25,7 +25,7 @@ class NIOConcurrencyHelpersTests: XCTestCase { return n*(n+1)/2 } - func testLargeContentedAtomicSum() { + func testLargeContendedAtomicSum() { let noAsyncs: UInt64 = 64 let noCounts: UInt64 = 200_000 diff --git a/Tests/NIOHTTP1Tests/HTTPResponseCompressorTest.swift b/Tests/NIOHTTP1Tests/HTTPResponseCompressorTest.swift index 5dd9fc34..4ad2ef18 100644 --- a/Tests/NIOHTTP1Tests/HTTPResponseCompressorTest.swift +++ b/Tests/NIOHTTP1Tests/HTTPResponseCompressorTest.swift @@ -89,7 +89,7 @@ private extension z_stream { private static func decompress(compressedBytes: inout ByteBuffer, outputBuffer: inout ByteBuffer, windowSize: Int32) { compressedBytes.withUnsafeMutableReadableUInt8Bytes { inputPointer in - outputBuffer.withUnsafeMutableWriteableUInt8Bytes { outputPointer in + let forwardAmount = outputBuffer.withUnsafeMutableWriteableUInt8Bytes { outputPointer -> Int in var stream = z_stream() // zlib requires we initialize next_in, avail_in, zalloc, zfree and opaque before calling inflateInit2. @@ -111,8 +111,9 @@ private extension z_stream { rc = inflateEnd(&stream) XCTAssertEqual(rc, Z_OK) - outputBuffer.moveWriterIndex(forwardBy: outputPointer.count - Int(stream.avail_out)) + return outputPointer.count - Int(stream.avail_out) } + outputBuffer.moveWriterIndex(forwardBy: forwardAmount) } } }