From 4dc12816ace11eceee05c1ad24dd925f420a0bda Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 30 Dec 2022 12:08:17 +0000 Subject: [PATCH 1/3] random: use int for MAX_TRIES Removing the use of ssize_t, removes the need to include compat.h, just to make Windows happy. --- src/random.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/random.cpp b/src/random.cpp index 5f50c001cd0..c45cf515266 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -634,7 +634,7 @@ bool Random_SanityCheck() * GetOSRand() overwrites all 32 bytes of the output given a maximum * number of tries. */ - static const ssize_t MAX_TRIES = 1024; + static constexpr int MAX_TRIES{1024}; uint8_t data[NUM_OS_RANDOM_BYTES]; bool overwritten[NUM_OS_RANDOM_BYTES] = {}; /* Tracks which bytes have been overwritten at least once */ int num_overwritten; From 75ec6275e6780b9ed18e271e6b24bef46d1af96d Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 30 Dec 2022 12:09:28 +0000 Subject: [PATCH 2/3] random: remove compat.h include We no-longer need ssize_t. Add windows.h, which was being indirectly included via compat.h. It isn't actually included in compat.h itself, but was being included as a side-effect of other includes, like winsock2.h. --- src/random.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/random.cpp b/src/random.cpp index c45cf515266..9fd39e89508 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -10,7 +10,7 @@ #include #include #ifdef WIN32 -#include +#include #include #endif #include From 621cfb77227b5a240d66547947f73130f0c51f44 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 30 Dec 2022 12:25:50 +0000 Subject: [PATCH 3/3] random: consolidate WIN32 #ifdefs Order includes Remove // for xyz comments --- src/random.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/random.cpp b/src/random.cpp index 9fd39e89508..432592589a0 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -8,23 +8,22 @@ #include #include #include -#include -#ifdef WIN32 -#include -#include -#endif #include #include -#include #include -#include // for Mutex -#include // for GetTimeMicros() +#include +#include +#include +#include #include #include #include -#ifndef WIN32 +#ifdef WIN32 +#include +#include +#else #include #include #endif