Skip to content

Commit

Permalink
[backport] Fix style issues in lib/, tools/, and testament/. Fixes #1…
Browse files Browse the repository at this point in the history
  • Loading branch information
3n-k1 authored and narimiran committed Nov 28, 2019
1 parent a7aeabb commit 0944b0f
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 109 deletions.
2 changes: 1 addition & 1 deletion lib/impure/re.nim
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ proc bufSubstr(b: cstring, sPos, ePos: int): string {.inline.} =
## Don't assume cstring is '\0' terminated
let sz = ePos - sPos
result = newString(sz+1)
copyMem(addr(result[0]), unsafeaddr(b[sPos]), sz)
copyMem(addr(result[0]), unsafeAddr(b[sPos]), sz)
result.setLen(sz)

proc matchOrFind(buf: cstring, pattern: Regex, matches: var openArray[string],
Expand Down
22 changes: 11 additions & 11 deletions lib/pure/asyncnet.nim
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ proc newAsyncSocket*(domain, sockType, protocol: cint,
when defineSsl:
proc getSslError(handle: SslPtr, err: cint): cint =
assert err < 0
var ret = SSLGetError(handle, err.cint)
var ret = SSL_get_error(handle, err.cint)
case ret
of SSL_ERROR_ZERO_RETURN:
raiseSSLError("TLS/SSL connection failed to initiate, socket closed prematurely.")
Expand All @@ -211,9 +211,9 @@ when defineSsl:
let read = bioRead(socket.bioOut, addr data[0], len)
assert read != 0
if read < 0:
raiseSslError()
raiseSSLError()
data.setLen(read)
await socket.fd.AsyncFd.send(data, flags)
await socket.fd.AsyncFD.send(data, flags)

proc appeaseSsl(socket: AsyncSocket, flags: set[SocketFlag],
sslError: cint): owned(Future[bool]) {.async.} =
Expand Down Expand Up @@ -692,13 +692,13 @@ proc close*(socket: AsyncSocket) =
defer:
socket.fd.AsyncFD.closeSocket()
when defineSsl:
if socket.isSSL:
let res = SslShutdown(socket.sslHandle)
SSLFree(socket.sslHandle)
if socket.isSsl:
let res = SSL_shutdown(socket.sslHandle)
SSL_free(socket.sslHandle)
if res == 0:
discard
elif res != 1:
raiseSslError()
raiseSSLError()
socket.closed = true # TODO: Add extra debugging checks for this.

when defineSsl:
Expand All @@ -710,12 +710,12 @@ when defineSsl:
## prone to security vulnerabilities.
socket.isSsl = true
socket.sslContext = ctx
socket.sslHandle = SSLNew(socket.sslContext.context)
socket.sslHandle = SSL_new(socket.sslContext.context)
if socket.sslHandle == nil:
raiseSslError()
raiseSSLError()

socket.bioIn = bioNew(bio_s_mem())
socket.bioOut = bioNew(bio_s_mem())
socket.bioIn = bioNew(bioSMem())
socket.bioOut = bioNew(bioSMem())
sslSetBio(socket.sslHandle, socket.bioIn, socket.bioOut)

proc wrapConnectedSocket*(ctx: SslContext, socket: AsyncSocket,
Expand Down
4 changes: 2 additions & 2 deletions lib/pure/base64.nim
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ template encodeInternal(s: typed): untyped =

result.setLen(outputIndex)

proc encode*[T: SomeInteger|char](s: openarray[T]): string =
proc encode*[T: SomeInteger|char](s: openArray[T]): string =
## Encodes `s` into base64 representation.
##
## This procedure encodes an openarray (array or sequence) of either integers
Expand Down Expand Up @@ -186,7 +186,7 @@ proc decode*(s: string): string =
return (size * 3 div 4) + 6

template inputChar(x: untyped) =
let x = int decode_table[ord(s[inputIndex])]
let x = int decodeTable[ord(s[inputIndex])]
inc inputIndex
if x == invalidChar:
raise newException(ValueError,
Expand Down
6 changes: 3 additions & 3 deletions lib/pure/httpclient.nim
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ proc fileError(msg: string) =


when not defined(ssl):
type SSLContext = ref object
var defaultSslContext {.threadvar.}: SSLContext
type SslContext = ref object
var defaultSslContext {.threadvar.}: SslContext

proc getDefaultSSL(): SSLContext =
proc getDefaultSSL(): SslContext =
result = defaultSslContext
when defined(ssl):
if result == nil:
Expand Down
Loading

0 comments on commit 0944b0f

Please sign in to comment.