Skip to content

Commit edbdd06

Browse files
committed
runtime: silence unhelpful warning
This TODO has existed since the introduction of the Windows platform and has not been addressed. The implementation at this point is well tested in practice. Clean up the warning message and style and remove the warning.
1 parent 90176b3 commit edbdd06

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

stdlib/public/stubs/Random.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@ void swift_stdlib_random(void *buf, __swift_size_t nbytes) {
6262
}
6363

6464
#elif defined(_WIN32) && !defined(__CYGWIN__)
65-
#warning TODO: Test swift_stdlib_random on Windows
6665

6766
SWIFT_RUNTIME_STDLIB_API
6867
void swift_stdlib_random(void *buf, __swift_size_t nbytes) {
6968
while (nbytes > 0) {
70-
auto actual_nbytes = std::min(nbytes, (__swift_size_t)ULONG_MAX);
69+
__swift_size_t actual_nbytes =
70+
std::min(nbytes, static_cast<__swift_size_t>(ULONG_MAX));
7171
NTSTATUS status = BCryptGenRandom(nullptr,
7272
static_cast<PUCHAR>(buf),
7373
static_cast<ULONG>(actual_nbytes),
7474
BCRYPT_USE_SYSTEM_PREFERRED_RNG);
75-
if (!BCRYPT_SUCCESS(status)) {
76-
fatalError(0, "Fatal error: 0x%lX in '%s'\n", status, __func__);
77-
}
75+
if (!BCRYPT_SUCCESS(status))
76+
fatalError(0, "Fatal error: BCryptGenRandom returned 0x%lX in '%s'\n",
77+
status, __func__);
7878

7979
buf = static_cast<uint8_t *>(buf) + actual_nbytes;
8080
nbytes -= actual_nbytes;

0 commit comments

Comments
 (0)