diff --git a/Sources/NIO/System.swift b/Sources/NIO/System.swift index 828c20ea7..7f020547d 100644 --- a/Sources/NIO/System.swift +++ b/Sources/NIO/System.swift @@ -118,10 +118,9 @@ internal func wrapSyscall(where function: StaticString = # /* Sorry, we really try hard to not use underscored attributes. In this case however we seem to break the inlining threshold which makes a system call take twice the time, ie. we need this exception. */ @inline(__always) -internal func wrapErrorIsNullReturnCall(where function: StaticString = #function, _ body: () throws -> UnsafePointer?) throws -> UnsafePointer? { +internal func wrapErrorIsNullReturnCall(where function: StaticString = #function, _ body: () throws -> T?) throws -> T { while true { - let res = try body() - if res == nil { + guard let res = try body() else { let err = errno if err == EINTR { continue @@ -368,7 +367,7 @@ internal enum Posix { @discardableResult @inline(never) - public static func inet_ntop(addressFamily: CInt, addressBytes: UnsafeRawPointer, addressDescription: UnsafeMutablePointer, addressDescriptionLength: socklen_t) throws -> UnsafePointer? { + public static func inet_ntop(addressFamily: CInt, addressBytes: UnsafeRawPointer, addressDescription: UnsafeMutablePointer, addressDescriptionLength: socklen_t) throws -> UnsafePointer { return try wrapErrorIsNullReturnCall { sysInet_ntop(addressFamily, addressBytes, addressDescription, addressDescriptionLength) }