Skip to content

Commit ef3f285

Browse files
authored
Merge pull request #78168 from compnerd/silence
runtime: silence unhelpful warning
2 parents c5d47f5 + edbdd06 commit ef3f285

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)