mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-02-09 01:43:28 +00:00
Fix unreachable code places. (#459)
* Fix unreachable code. * Use implicit returns instead.
This commit is contained in:
parent
12dc36cfee
commit
8375770fe5
@ -1617,6 +1617,8 @@ elif defined(linux):
|
||||
# RTA_PRIORITY* = 6'u16
|
||||
RTA_PREFSRC* = 7'u16
|
||||
# RTA_METRICS* = 8'u16
|
||||
RTM_NEWLINK* = 16'u16
|
||||
RTM_NEWROUTE* = 24'u16
|
||||
|
||||
RTM_F_LOOKUP_TABLE* = 0x1000
|
||||
|
||||
|
@ -157,17 +157,15 @@ proc tlsWriteRec(engine: ptr SslEngineContext,
|
||||
doAssert(length != 0 and not isNil(buf))
|
||||
await writer.wsource.write(buf, int(length))
|
||||
sslEngineSendrecAck(engine[], length)
|
||||
return TLSResult.Success
|
||||
TLSResult.Success
|
||||
except AsyncStreamError as exc:
|
||||
writer.state = AsyncStreamState.Error
|
||||
writer.error = exc
|
||||
return TLSResult.Error
|
||||
TLSResult.Error
|
||||
except CancelledError:
|
||||
if writer.state == AsyncStreamState.Running:
|
||||
writer.state = AsyncStreamState.Stopped
|
||||
return TLSResult.Stopped
|
||||
|
||||
return TLSResult.Error
|
||||
TLSResult.Stopped
|
||||
|
||||
proc tlsWriteApp(engine: ptr SslEngineContext,
|
||||
writer: TLSStreamWriter): Future[TLSResult] {.async.} =
|
||||
@ -182,7 +180,6 @@ proc tlsWriteApp(engine: ptr SslEngineContext,
|
||||
# (and discarded).
|
||||
writer.state = AsyncStreamState.Finished
|
||||
return TLSResult.WriteEof
|
||||
|
||||
let toWrite = min(int(length), item.size)
|
||||
copyOut(buf, item, toWrite)
|
||||
if int(length) >= item.size:
|
||||
@ -190,7 +187,6 @@ proc tlsWriteApp(engine: ptr SslEngineContext,
|
||||
sslEngineSendappAck(engine[], uint(item.size))
|
||||
sslEngineFlush(engine[], 0)
|
||||
item.future.complete()
|
||||
return TLSResult.Success
|
||||
else:
|
||||
# BearSSL is not ready to accept whole item, so we will send
|
||||
# only part of item and adjust offset.
|
||||
@ -198,17 +194,15 @@ proc tlsWriteApp(engine: ptr SslEngineContext,
|
||||
item.size = item.size - int(length)
|
||||
writer.queue.addFirstNoWait(item)
|
||||
sslEngineSendappAck(engine[], length)
|
||||
return TLSResult.Success
|
||||
TLSResult.Success
|
||||
else:
|
||||
sslEngineClose(engine[])
|
||||
item.future.complete()
|
||||
return TLSResult.Success
|
||||
TLSResult.Success
|
||||
except CancelledError:
|
||||
if writer.state == AsyncStreamState.Running:
|
||||
writer.state = AsyncStreamState.Stopped
|
||||
return TLSResult.Stopped
|
||||
|
||||
return TLSResult.Error
|
||||
TLSResult.Stopped
|
||||
|
||||
proc tlsReadRec(engine: ptr SslEngineContext,
|
||||
reader: TLSStreamReader): Future[TLSResult] {.async.} =
|
||||
@ -219,19 +213,17 @@ proc tlsReadRec(engine: ptr SslEngineContext,
|
||||
sslEngineRecvrecAck(engine[], uint(res))
|
||||
if res == 0:
|
||||
sslEngineClose(engine[])
|
||||
return TLSResult.ReadEof
|
||||
TLSResult.ReadEof
|
||||
else:
|
||||
return TLSResult.Success
|
||||
TLSResult.Success
|
||||
except AsyncStreamError as exc:
|
||||
reader.state = AsyncStreamState.Error
|
||||
reader.error = exc
|
||||
return TLSResult.Error
|
||||
TLSResult.Error
|
||||
except CancelledError:
|
||||
if reader.state == AsyncStreamState.Running:
|
||||
reader.state = AsyncStreamState.Stopped
|
||||
return TLSResult.Stopped
|
||||
|
||||
return TLSResult.Error
|
||||
TLSResult.Stopped
|
||||
|
||||
proc tlsReadApp(engine: ptr SslEngineContext,
|
||||
reader: TLSStreamReader): Future[TLSResult] {.async.} =
|
||||
@ -240,13 +232,11 @@ proc tlsReadApp(engine: ptr SslEngineContext,
|
||||
var buf = sslEngineRecvappBuf(engine[], length)
|
||||
await upload(addr reader.buffer, buf, int(length))
|
||||
sslEngineRecvappAck(engine[], length)
|
||||
return TLSResult.Success
|
||||
TLSResult.Success
|
||||
except CancelledError:
|
||||
if reader.state == AsyncStreamState.Running:
|
||||
reader.state = AsyncStreamState.Stopped
|
||||
return TLSResult.Stopped
|
||||
|
||||
return TLSResult.Error
|
||||
TLSResult.Stopped
|
||||
|
||||
template readAndReset(fut: untyped) =
|
||||
if fut.finished():
|
||||
|
@ -677,10 +677,10 @@ when defined(linux):
|
||||
var msg = cast[ptr NlMsgHeader](addr data[0])
|
||||
var endflag = false
|
||||
while NLMSG_OK(msg, length):
|
||||
if msg.nlmsg_type == NLMSG_ERROR:
|
||||
if msg.nlmsg_type in [uint16(NLMSG_DONE), uint16(NLMSG_ERROR)]:
|
||||
endflag = true
|
||||
break
|
||||
else:
|
||||
elif msg.nlmsg_type == RTM_NEWROUTE:
|
||||
res = processRoute(msg)
|
||||
endflag = true
|
||||
break
|
||||
|
Loading…
x
Reference in New Issue
Block a user