From 189d277cfc66d6e3d1c17e5fb60d72cfb6c3f844 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 14 Jun 2018 10:26:11 -0400 Subject: Common/Random: Add convenience template for simple arithmetic values In cases where we just want a random value for a primitive arithmetic type, we can wrap this in a template to allow convenient direct assignment instead of keeping declaration and initialization separate (making it more difficult to use values uninitialized). This also allows the use of Common::Random with functions such as std::generate, making it more flexible in how random values can be generated. --- Source/Core/Common/TraversalServer.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Source/Core/Common/TraversalServer.cpp') diff --git a/Source/Core/Common/TraversalServer.cpp b/Source/Core/Common/TraversalServer.cpp index 097418b143..40c439f6b4 100644 --- a/Source/Core/Common/TraversalServer.cpp +++ b/Source/Core/Common/TraversalServer.cpp @@ -169,8 +169,7 @@ static sockaddr_in6 MakeSinAddr(const TraversalInetAddress& addr) static void GetRandomHostId(TraversalHostId* hostId) { char buf[9]; - u32 num; - Common::Random::Generate(&num, sizeof(num)); + const u32 num = Common::Random::GenerateValue(); sprintf(buf, "%08x", num); memcpy(hostId->data(), buf, 8); } -- cgit v1.2.3