Fix potentially uninitialized struct used on MSVC
authorAndrew Krieger <andrew.krieger@oculus.com>
Tue, 29 Aug 2017 05:34:42 +0000 (22:34 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 29 Aug 2017 05:50:04 +0000 (22:50 -0700)
Summary:
MSVC warns this might be used but uninitialized. Force
the struct to be zero initialized.

Reviewed By: yfeldblum

Differential Revision: D5585320

fbshipit-source-id: 9454a2a4a66c7689f42b1eb211dc57f5d3b88fea

folly/SharedMutex.h

index 0968f5bad2d9516aa5594144ca83e11177d24ac3..b6a1a2639a919e546433482be6f0b7dc5ffa00ea 100644 (file)
@@ -850,6 +850,7 @@ class SharedMutexImpl {
                             WaitContext& ctx) {
 #ifdef RUSAGE_THREAD
     struct rusage usage;
                             WaitContext& ctx) {
 #ifdef RUSAGE_THREAD
     struct rusage usage;
+    std::memset(&usage, 0, sizeof(usage));
     long before = -1;
 #endif
     for (uint32_t yieldCount = 0; yieldCount < kMaxSoftYieldCount;
     long before = -1;
 #endif
     for (uint32_t yieldCount = 0; yieldCount < kMaxSoftYieldCount;
@@ -1005,6 +1006,7 @@ class SharedMutexImpl {
 
 #ifdef RUSAGE_THREAD
     struct rusage usage;
 
 #ifdef RUSAGE_THREAD
     struct rusage usage;
+    std::memset(&usage, 0, sizeof(usage));
     long before = -1;
 #endif
     for (uint32_t yieldCount = 0; yieldCount < kMaxSoftYieldCount;
     long before = -1;
 #endif
     for (uint32_t yieldCount = 0; yieldCount < kMaxSoftYieldCount;