This is an automated email from the ASF dual-hosted git repository.

jbarrett pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new a38ce7a  GEODE-5713: Fix valgrind uninitialized value (#348)
a38ce7a is described below

commit a38ce7a2eeafc4625a23bdb333b4a1ae97a200dd
Author: Blake Bender <[email protected]>
AuthorDate: Wed Sep 12 08:57:34 2018 -0700

    GEODE-5713: Fix valgrind uninitialized value (#348)
    
    * WIP - replace use of member variable with local variable
    * Remove unused member variable
    
    Co-authored-by: Ivan Godwin <[email protected]>
---
 cppcache/src/statistics/StatArchiveWriter.cpp | 20 ++++++++++----------
 cppcache/src/statistics/StatArchiveWriter.hpp |  2 --
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/cppcache/src/statistics/StatArchiveWriter.cpp 
b/cppcache/src/statistics/StatArchiveWriter.cpp
index f080001..d6c0de2 100644
--- a/cppcache/src/statistics/StatArchiveWriter.cpp
+++ b/cppcache/src/statistics/StatArchiveWriter.cpp
@@ -170,16 +170,15 @@ ResourceInst::ResourceInst(int32_t idArg, Statistics 
*resourceArg,
                            const ResourceType *typeArg,
                            StatDataOutput *dataOutArg)
     : type(typeArg) {
-  this->id = idArg;
-  this->resource = resourceArg;
-  this->dataOut = dataOutArg;
+  id = idArg;
+  resource = resourceArg;
+  dataOut = dataOutArg;
   int32_t cnt = type->getNumOfDescriptors();
   archivedStatValues = new int64_t[cnt];
   // initialize to zero
   for (int32_t i = 0; i < cnt; i++) {
     archivedStatValues[i] = 0;
   }
-  numOfDescps = cnt;
   firstTime = true;
 }
 
@@ -198,31 +197,32 @@ int64_t ResourceInst::getStatValue(StatisticDescriptor 
*f) {
 void ResourceInst::writeSample() {
   bool wroteInstId = false;
   bool checkForChange = true;
-  StatisticDescriptor **stats = this->type->getStats();
+  StatisticDescriptor **stats = type->getStats();
   GF_D_ASSERT(stats != nullptr);
   GF_D_ASSERT(*stats != nullptr);
-  if (this->resource->isClosed()) {
+  if (resource->isClosed()) {
     return;
   }
   if (firstTime) {
     firstTime = false;
     checkForChange = false;
   }
-  for (int32_t i = 0; i < numOfDescps; i++) {
+  auto count = type->getNumOfDescriptors();
+  for (int32_t i = 0; i < count; i++) {
     int64_t value = getStatValue(stats[i]);
     if (!checkForChange || value != archivedStatValues[i]) {
       int64_t delta = value - archivedStatValues[i];
       archivedStatValues[i] = value;
       if (!wroteInstId) {
         wroteInstId = true;
-        writeResourceInst(this->dataOut, this->id);
+        writeResourceInst(dataOut, id);
       }
-      this->dataOut->writeByte(i);
+      dataOut->writeByte(i);
       writeStatValue(stats[i], delta);
     }
   }
   if (wroteInstId) {
-    this->dataOut->writeByte(static_cast<unsigned char>(ILLEGAL_STAT_OFFSET));
+    dataOut->writeByte(static_cast<unsigned char>(ILLEGAL_STAT_OFFSET));
   }
 }
 
diff --git a/cppcache/src/statistics/StatArchiveWriter.hpp 
b/cppcache/src/statistics/StatArchiveWriter.hpp
index f20ff7c..369ff1d 100644
--- a/cppcache/src/statistics/StatArchiveWriter.hpp
+++ b/cppcache/src/statistics/StatArchiveWriter.hpp
@@ -192,8 +192,6 @@ class APACHE_GEODE_EXPORT ResourceInst : private 
NonCopyable,
   /* This will contain the previous values of the descriptors */
   int64_t *archivedStatValues;
   StatDataOutput *dataOut;
-  /* Number of descriptors this resource instnace has */
-  int32_t numOfDescps;
   /* To know whether the instance has come for the first time */
   bool firstTime;
 };

Reply via email to