From b134f22cfaf11f59ba77571b876f9d0f2513a9c9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda <commit@birarda.com> Date: Mon, 28 Mar 2016 18:51:34 -0700 Subject: [PATCH 1/3] fix an overflow in portable high resolution clock on windows --- libraries/shared/src/PortableHighResolutionClock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/PortableHighResolutionClock.cpp b/libraries/shared/src/PortableHighResolutionClock.cpp index 6e096a7ce1..9980e51805 100644 --- a/libraries/shared/src/PortableHighResolutionClock.cpp +++ b/libraries/shared/src/PortableHighResolutionClock.cpp @@ -24,7 +24,7 @@ namespace { win_high_resolution_clock::time_point win_high_resolution_clock::now() { LARGE_INTEGER count; QueryPerformanceCounter(&count); - return time_point(duration(count.QuadPart * static_cast<rep>(period::den) / g_Frequency)); + return time_point(duration(static_cast<rep>(double(count.QuadPart) * static_cast<rep>(period::den) / g_Frequency))); } #endif From 37950e99310af0d451023a3ff39f53b3979e6b76 Mon Sep 17 00:00:00 2001 From: Stephen Birarda <commit@birarda.com> Date: Tue, 29 Mar 2016 13:13:22 -0700 Subject: [PATCH 2/3] use explicit double casts for win_high_resolution_clock --- libraries/shared/src/PortableHighResolutionClock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/PortableHighResolutionClock.cpp b/libraries/shared/src/PortableHighResolutionClock.cpp index 9980e51805..b12798503e 100644 --- a/libraries/shared/src/PortableHighResolutionClock.cpp +++ b/libraries/shared/src/PortableHighResolutionClock.cpp @@ -24,7 +24,7 @@ namespace { win_high_resolution_clock::time_point win_high_resolution_clock::now() { LARGE_INTEGER count; QueryPerformanceCounter(&count); - return time_point(duration(static_cast<rep>(double(count.QuadPart) * static_cast<rep>(period::den) / g_Frequency))); + return time_point(duration(static_cast<rep>(double(count.QuadPart) * double(period::den) / double(g_Frequency)))); } #endif From b9ce427344afeda52326d4488908981b8cb060b6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda <commit@birarda.com> Date: Tue, 29 Mar 2016 13:25:03 -0700 Subject: [PATCH 3/3] use c-style casts to respect the coding standard --- libraries/shared/src/PortableHighResolutionClock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/PortableHighResolutionClock.cpp b/libraries/shared/src/PortableHighResolutionClock.cpp index b12798503e..55dd61707c 100644 --- a/libraries/shared/src/PortableHighResolutionClock.cpp +++ b/libraries/shared/src/PortableHighResolutionClock.cpp @@ -24,7 +24,7 @@ namespace { win_high_resolution_clock::time_point win_high_resolution_clock::now() { LARGE_INTEGER count; QueryPerformanceCounter(&count); - return time_point(duration(static_cast<rep>(double(count.QuadPart) * double(period::den) / double(g_Frequency)))); + return time_point(duration(static_cast<rep>((double) count.QuadPart * (double) period::den / (double)g_Frequency))); } #endif