Skip to content

Commit 9680b72

Browse files
authored
Make memset_s consistent with Darwin. (apple#52)
Resolves [issue#51](apple#51). In Swift 5.3, a warning is viewed on Linux because `memset_s` implemented in this module returns `Void`. This commit let the function return the same type with Darwin.
1 parent 3c632a6 commit 9680b72

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/Crypto/Util/BoringSSL/Zeroization_boring.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@
1414
#if !(os(macOS) || os(iOS) || os(watchOS) || os(tvOS))
1515
@_implementationOnly import CCryptoBoringSSL
1616

17+
typealias errno_t = CInt
18+
1719
// This is a Swift wrapper for the libc function that does not exist on Linux. We shim it via a call to OPENSSL_cleanse.
1820
// We have the same syntax, but mostly ignore it.
19-
func memset_s(_ s: UnsafeMutableRawPointer!, _ smax: Int, _ byte: CInt, _ n: Int) {
21+
@discardableResult
22+
func memset_s(_ s: UnsafeMutableRawPointer!, _ smax: Int, _ byte: CInt, _ n: Int) -> errno_t {
2023
assert(smax == n, "memset_s invariant not met")
2124
assert(byte == 0, "memset_s used to not zero anything")
2225
CCryptoBoringSSL_OPENSSL_cleanse(s, smax)
26+
return 0
2327
}
2428
#endif

0 commit comments

Comments
 (0)