Fix GCC-14 [-Wincompatible-pointer-types] issue. (#58)

* Fix GCC-14 [-Wincompatible-pointer-types] issue.

* Add more fixes.

* More fixes.
This commit is contained in:
Eugene Kabanov 2024-06-02 06:42:27 +03:00 committed by GitHub
parent d81b37dc20
commit ff0b47ed80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 8 deletions

View File

@ -52,9 +52,9 @@ proc hmacDrbgGetHash*(ctx: var HmacDrbgContext): ptr HashClass {.inline.} =
type
PrngSeeder* {.importc: "br_prng_seeder".} = proc (ctx: ptr ptr PrngClass): cint {.importcFunc.}
constCstringArray* {.importc: "const char**", nodecl.} = pointer
proc prngSeederSystem*(name: cstringArray): PrngSeeder {.importcFunc,
proc prngSeederSystem*(name: constCstringArray): PrngSeeder {.importcFunc,
importc: "br_prng_seeder_system", header: "bearssl_rand.h".}
# type

View File

@ -544,7 +544,7 @@ type
alert* {.importc: "alert".}: byte
closeReceived* {.importc: "close_received".}: byte
mhash* {.importc: "mhash".}: MultihashContext
x509ctx* {.importc: "x509ctx".}: ptr ptr X509Class
x509ctx* {.importc: "x509ctx".}: X509ClassPointerConst
chain* {.importc: "chain".}: ptr X509Certificate
chainLen* {.importc: "chain_len".}: uint
certCur* {.importc: "cert_cur".}: ptr byte
@ -612,9 +612,12 @@ proc sslEngineSetSuites*(cc: var SslEngineContext; suites: ptr uint16;
suitesNum: uint) {.importcFunc,
importc: "br_ssl_engine_set_suites", header: "bearssl_ssl.h".}
proc sslEngineSetX509*(cc: var SslEngineContext; x509ctx: ptr ptr X509Class) {.inline.} =
proc sslEngineSetX509*(cc: var SslEngineContext;
x509ctx: X509ClassPointerConst) =
cc.x509ctx = x509ctx
proc sslEngineSetX509*(cc: var SslEngineContext; x509ctx: ptr ptr X509Class) =
cc.x509ctx = X509ClassPointerConst(x509ctx)
proc sslEngineSetProtocolNames*(ctx: var SslEngineContext; names: cstringArray;
num: uint) {.inline.} =
@ -1077,6 +1080,7 @@ type
params: ptr SslSessionParameters): cint {.importcFunc.}
SslSessionCacheClassPointerConst* {.importc: "const br_ssl_session_cache_class**", header: "bearssl_ssl.h", bycopy.} = pointer
SslSessionCacheLru* {.importc: "br_ssl_session_cache_lru",
@ -1104,7 +1108,7 @@ type
bycopy.} = object
eng* {.importc: "eng".}: SslEngineContext
clientMaxVersion* {.importc: "client_max_version".}: uint16
cacheVtable* {.importc: "cache_vtable".}: ptr ptr SslSessionCacheClass
cacheVtable* {.importc: "cache_vtable".}: SslSessionCacheClassPointerConst
clientSuites* {.importc: "client_suites".}: array[MAX_CIPHER_SUITES,
SuiteTranslated]
clientSuitesNum* {.importc: "client_suites_num".}: byte
@ -1222,7 +1226,7 @@ proc sslServerSetTrustAnchorNamesAlt*(cc: var SslServerContext;
proc sslServerSetCache*(cc: var SslServerContext;
vtable: ptr ptr SslSessionCacheClass) {.inline.} =
vtable: SslSessionCacheClassPointerConst) {.inline.} =
cc.cacheVtable = vtable

View File

@ -200,7 +200,7 @@ type
getPkey* {.importc: "get_pkey".}: proc (ctx: ptr ptr X509Class; usages: ptr cuint): ptr X509Pkey {.
importcFunc.}
X509ClassPointerConst* {.importc: "const br_x509_class**", header: "bearssl_x509.h", bycopy.} = pointer
type
X509KnownkeyContext* {.importc: "br_x509_knownkey_context",

View File

@ -32,7 +32,7 @@ proc new*(T: type HmacDrbgContext): ref HmacDrbgContext =
##
## The context is seeded with randomness from the OS / system.
## Returns `nil` if the OS / system has no randomness API.
let seeder = prngSeederSystem(nil)
let seeder = prngSeederSystem(constCstringArray(nil))
if seeder == nil:
return nil