Skip to content

Commit

Permalink
Fix some warnings. (#310)
Browse files Browse the repository at this point in the history
* Fix some warnings messages.

* More warning fixes.

* Address review comments.
Fix MacOS issues.

* More warning fixes.

* More Windows specific fixes.

* Fix macos and windows warnings.

* Fix warnings in timer.nim
Refactor to remove `result`.
Improve performance and behavior of timer to string procedure.
Add tests.
  • Loading branch information
cheatfate authored Nov 2, 2022
1 parent 2414646 commit 6525f4c
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 133 deletions.
4 changes: 2 additions & 2 deletions chronos/asyncloop.nim
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ func getAsyncTimestamp*(a: Duration): auto {.inline.} =
var res = nansec div milsec
let mid = nansec mod milsec
when defined(windows):
res = min(cast[int64](high(int32) - 1), res)
res = min(int64(high(int32) - 1), res)
result = cast[DWORD](res)
result += DWORD(min(1'i32, cast[int32](mid)))
else:
res = min(cast[int64](high(int32) - 1), res)
res = min(int64(high(int32) - 1), res)
result = cast[int32](res)
result += min(1, cast[int32](mid))

Expand Down
3 changes: 1 addition & 2 deletions chronos/handles.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ else:
{.push raises: [].}

import std/[net, nativesockets]
import stew/base10
import ./asyncloop

when defined(windows) or defined(nimdoc):
import os, winlean
import os, winlean, stew/base10
const
asyncInvalidSocket* = AsyncFD(-1)
TCP_NODELAY* = 1
Expand Down
2 changes: 1 addition & 1 deletion chronos/ioselects/ioselectors_epoll.nim
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ proc selectInto*[T](s: Selector[T], timeout: int,
if posix.read(cint(fdi), addr data,
sizeof(SignalFdInfo)) != sizeof(SignalFdInfo):
raiseIOSelectorsError(osLastError())
if cast[int](data.ssi_pid) == pkey.param:
if data.ssi_pid == uint32(pkey.param):
rkey.events.incl(Event.Process)
else:
inc(i)
Expand Down
2 changes: 1 addition & 1 deletion chronos/streams/tlsstream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ proc newTLSClientAsyncStream*(rsource: AsyncStreamReader,

if TLSFlags.NoVerifyHost in flags:
sslClientInitFull(res.ccontext, addr res.x509, nil, 0)
initNoAnchor(res.xwc, addr res.x509.vtable)
x509NoanchorInit(res.xwc, addr res.x509.vtable)
sslEngineSetX509(res.ccontext.eng, addr res.xwc.vtable)
else:
sslClientInitFull(res.ccontext, addr res.x509,
Expand Down
Loading

0 comments on commit 6525f4c

Please sign in to comment.