@@ -114,7 +114,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
114114 var optionLength = socklen_t ( MemoryLayout< CInt> . size)
115115
116116 guard getsockopt ( fileDescriptor, SOL_SOCKET, socketOption, & optionValue, & optionLength) == 0
117- else { throw POSIXError . fromErrno! }
117+ else { throw POSIXError . fromErrno ( ) }
118118
119119 return optionValue
120120 }
@@ -141,7 +141,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
141141
142142 // error creating socket
143143 guard internalSocket >= 0
144- else { throw POSIXError . fromErrno! }
144+ else { throw POSIXError . fromErrno ( ) }
145145
146146 // set source address
147147 var localAddress = sockaddr_l2 ( )
@@ -157,7 +157,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
157157 $0. withMemoryRebound ( to: sockaddr. self, capacity: 1 , {
158158 bind ( internalSocket, $0, socklen_t ( MemoryLayout< sockaddr_l2> . size) ) == 0
159159 } )
160- } ) else { close ( internalSocket) ; throw POSIXError . fromErrno! }
160+ } ) else { close ( internalSocket) ; throw POSIXError . fromErrno ( ) }
161161
162162 return ( internalSocket, localAddress)
163163 }
@@ -200,7 +200,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
200200 security. level = securityLevel. rawValue
201201
202202 guard setsockopt ( internalSocket, SOL_BLUETOOTH, BT_SECURITY, & security, socklen_t ( MemoryLayout< bt_security> . size) ) == 0
203- else { throw POSIXError . fromErrno! }
203+ else { throw POSIXError . fromErrno ( ) }
204204
205205 self . securityLevel = securityLevel
206206 }
@@ -210,7 +210,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
210210
211211 // put socket into listening mode
212212 guard listen ( internalSocket, Int32 ( queueLimit) ) == 0
213- else { throw POSIXError . fromErrno! }
213+ else { throw POSIXError . fromErrno ( ) }
214214 }
215215
216216 /// Blocks the caller until a new connection is recieved.
@@ -228,7 +228,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
228228 } )
229229
230230 // error accepting new connection
231- guard client >= 0 else { throw POSIXError . fromErrno! }
231+ guard client >= 0 else { throw POSIXError . fromErrno ( ) }
232232
233233 let newSocket = L2CAPSocket ( clientSocket: client,
234234 remoteAddress: remoteAddress,
@@ -257,7 +257,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
257257 $0. withMemoryRebound ( to: sockaddr. self, capacity: 1 , {
258258 connect ( internalSocket, $0, socklen_t ( MemoryLayout< sockaddr_l2> . size) ) == 0
259259 } )
260- } ) else { throw POSIXError . fromErrno! }
260+ } ) else { throw POSIXError . fromErrno ( ) }
261261
262262 // make socket non-blocking
263263 try setNonblocking ( )
@@ -276,13 +276,9 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
276276 let actualByteCount = read ( internalSocket, & buffer, bufferSize)
277277
278278 guard actualByteCount >= 0 else {
279- if let error = POSIXError . fromErrno {
280- throw error
281- } else {
282- return nil
283- }
279+ throw POSIXError . fromErrno ( )
284280 }
285-
281+
286282 let actualBytes = Array ( buffer. prefix ( actualByteCount) )
287283
288284 return Data ( actualBytes)
@@ -299,7 +295,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
299295 let fdCount = select ( internalSocket + 1 , & readSockets, nil , nil , & time)
300296
301297 guard fdCount != - 1
302- else { throw POSIXError . fromErrno! }
298+ else { throw POSIXError . fromErrno ( ) }
303299
304300 return fdCount > 0
305301 }
@@ -309,12 +305,12 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
309305 var flags = fcntl ( internalSocket, F_GETFL, 0 )
310306
311307 guard flags != - 1
312- else { throw POSIXError . fromErrno! }
308+ else { throw POSIXError . fromErrno ( ) }
313309
314310 flags = fcntl ( internalSocket, F_SETFL, flags | O_NONBLOCK) ;
315311
316312 guard flags != - 1
317- else { throw POSIXError . fromErrno! }
313+ else { throw POSIXError . fromErrno ( ) }
318314 }
319315
320316 /// Write to the socket.
@@ -325,7 +321,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
325321 let actualByteCount = write ( internalSocket, & buffer, buffer. count)
326322
327323 guard actualByteCount >= 0
328- else { throw POSIXError . fromErrno! }
324+ else { throw POSIXError . fromErrno ( ) }
329325
330326 guard actualByteCount == buffer. count
331327 else { throw L2CAPSocketError . sentLessBytes ( actualByteCount) }
@@ -338,7 +334,7 @@ public final class L2CAPSocket: L2CAPSocketProtocol {
338334 var optionLength = socklen_t ( MemoryLayout< Options> . size)
339335
340336 guard getsockopt ( internalSocket, SOL_L2CAP, L2CAP_OPTIONS, & optionValue, & optionLength) == 0
341- else { throw POSIXError . fromErrno! }
337+ else { throw POSIXError . fromErrno ( ) }
342338
343339 return optionValue
344340 }
0 commit comments