mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Replace panic(fmt.tprintf( antipattern with fmt.panicf
This commit is contained in:
@@ -11,7 +11,7 @@ HAS_RAND_BYTES :: true
|
|||||||
_rand_bytes :: proc(dst: []byte) {
|
_rand_bytes :: proc(dst: []byte) {
|
||||||
err := Sec.RandomCopyBytes(count=len(dst), bytes=raw_data(dst))
|
err := Sec.RandomCopyBytes(count=len(dst), bytes=raw_data(dst))
|
||||||
if err != .Success {
|
if err != .Success {
|
||||||
msg := CF.StringCopyToOdinString(Sec.CopyErrorMessageString(err))
|
msg := CF.StringCopyToOdinString(Sec.CopyErrorMessageString(err))
|
||||||
panic(fmt.tprintf("crypto/rand_bytes: SecRandomCopyBytes returned non-zero result: %v %s", err, msg))
|
fmt.panicf("crypto/rand_bytes: SecRandomCopyBytes returned non-zero result: %v %s", err, msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ _rand_bytes :: proc (dst: []byte) {
|
|||||||
// All other failures are things that should NEVER happen
|
// All other failures are things that should NEVER happen
|
||||||
// unless the kernel interface changes (ie: the Linux
|
// unless the kernel interface changes (ie: the Linux
|
||||||
// developers break userland).
|
// developers break userland).
|
||||||
panic(fmt.tprintf("crypto: getrandom failed: %v", errno))
|
fmt.panicf("crypto: getrandom failed: %v", errno)
|
||||||
}
|
}
|
||||||
l -= n_read
|
l -= n_read
|
||||||
dst = dst[n_read:]
|
dst = dst[n_read:]
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ _rand_bytes :: proc(dst: []byte) {
|
|||||||
panic("crypto: BCryptGenRandom Invalid parameter")
|
panic("crypto: BCryptGenRandom Invalid parameter")
|
||||||
case:
|
case:
|
||||||
// Unknown error
|
// Unknown error
|
||||||
panic(fmt.tprintf("crypto: BCryptGenRandom failed: %d\n", ret))
|
fmt.panicf("crypto: BCryptGenRandom failed: %d\n", ret)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user