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 a905e8b GEODE-5753: Fixes google-readability-casting clang-tidy
warning. (#368)
a905e8b is described below
commit a905e8ba60b1a342274ee540f5fdc500fa211cea
Author: Jacob Barrett <[email protected]>
AuthorDate: Mon Oct 8 12:30:28 2018 -0700
GEODE-5753: Fixes google-readability-casting clang-tidy warning. (#368)
* Uses static_cast<> over C-style cast.
* Fixes ACE thread id to string.
---
.clang-tidy | 4 +-
cppcache/include/geode/DataOutput.hpp | 6 ++-
cppcache/include/geode/Serializer.hpp | 10 ++---
cppcache/include/geode/internal/CacheableKeys.hpp | 4 +-
.../integration-test/BuiltinCacheableWrappers.hpp | 7 ++--
.../integration-test/ThinClientSecurityHelper.hpp | 20 +++++-----
cppcache/integration-test/fw_dunit.cpp | 5 +--
cppcache/integration-test/testDataOutput.cpp | 2 +-
cppcache/integration-test/testSerialization.cpp | 2 +-
.../integration-test/testThinClientCacheables.cpp | 2 +-
.../testThinClientCacheablesLimits.cpp | 2 +-
.../integration-test/testThinClientClearRegion.cpp | 2 +-
.../testThinClientContainsKeyOnServer.cpp | 2 +-
.../integration-test/testThinClientPdxInstance.cpp | 15 ++++---
...ThinClientRegionQueryDifferentServerConfigs.cpp | 8 ++--
.../testXmlCacheCreationWithPools.cpp | 2 +-
.../testXmlCacheInitialization.cpp | 2 +-
.../hacks/AceThreadId.h} | 35 ++++++++--------
cppcache/src/ClientProxyMembershipID.cpp | 2 +-
cppcache/src/DataOutput.cpp | 2 +-
cppcache/src/FairQueue.hpp | 2 +-
cppcache/src/Log.cpp | 5 ++-
cppcache/src/PdxHelper.cpp | 2 +-
cppcache/src/PdxSerializable.cpp | 4 +-
cppcache/src/QueueConnectionRequest.cpp | 2 +-
cppcache/src/TcpConn.cpp | 4 +-
cppcache/src/TcpConn.hpp | 4 +-
cppcache/src/TcpSslConn.cpp | 4 +-
cppcache/src/TcrConnection.cpp | 25 +++++++-----
cppcache/src/TcrMessage.cpp | 33 ++++++++--------
cppcache/src/ThinClientLocatorHelper.cpp | 6 +--
cppcache/src/ThinClientPoolDM.cpp | 8 ++--
cppcache/src/Utils.cpp | 2 +-
cppcache/src/VersionTag.cpp | 2 +-
cppcache/src/statistics/StatArchiveWriter.cpp | 6 +--
cppcache/src/util/string.hpp | 2 +-
cppcache/test/CacheableStringTests.cpp | 2 +-
cppcache/test/DataOutputTest.cpp | 6 +--
cryptoimpl/DHImpl.cpp | 46 +++++++++++-----------
dhimpl/DHImpl.cpp | 31 +++++++--------
tests/cpp/fwklib/CMakeLists.txt | 7 ++--
tests/cpp/fwklib/FwkLog.cpp | 9 +++--
tests/cpp/fwklib/IpcHandler.cpp | 24 +++++------
tests/cpp/fwklib/TcpIpc.cpp | 2 +-
tests/cpp/fwklib/UDPIpc.cpp | 2 +-
tests/cpp/testobject/PdxClassV2.cpp | 8 ++--
46 files changed, 195 insertions(+), 187 deletions(-)
diff --git a/.clang-tidy b/.clang-tidy
index 3c40447..09a1256 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,6 +1,6 @@
---
-Checks:
'-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references'
-WarningsAsErrors:
'google-build-using-namespace,google-readability-redundant-smartptr-get,google-explicit-constructor,google-global-names-in-headers,google-runtime-int'
+Checks:
'-*,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-alpha*,google-*,-google-readability-todo,-google-runtime-references,-google-default-arguments'
+WarningsAsErrors:
'google-build-using-namespace,google-readability-redundant-smartptr-get,google-explicit-constructor,google-global-names-in-headers,google-runtime-int,google-readability-casting'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: file
diff --git a/cppcache/include/geode/DataOutput.hpp
b/cppcache/include/geode/DataOutput.hpp
index e7bba27..c95db70 100644
--- a/cppcache/include/geode/DataOutput.hpp
+++ b/cppcache/include/geode/DataOutput.hpp
@@ -417,7 +417,8 @@ class APACHE_GEODE_EXPORT DataOutput {
inline void reset() {
if (m_haveBigBuffer) {
// create smaller buffer
- m_bytes.reset((uint8_t*)std::malloc(m_lowWaterMark * sizeof(uint8_t)));
+ m_bytes.reset(
+ static_cast<uint8_t*>(std::malloc(m_lowWaterMark *
sizeof(uint8_t))));
if (m_bytes == nullptr) {
throw OutOfMemoryException("Out of Memory while resizing buffer");
}
@@ -444,7 +445,8 @@ class APACHE_GEODE_EXPORT DataOutput {
m_size = newSize;
auto bytes = m_bytes.release();
- auto tmp = (uint8_t*)std::realloc(bytes, m_size * sizeof(uint8_t));
+ auto tmp =
+ static_cast<uint8_t*>(std::realloc(bytes, m_size * sizeof(uint8_t)));
if (tmp == nullptr) {
throw OutOfMemoryException("Out of Memory while resizing buffer");
}
diff --git a/cppcache/include/geode/Serializer.hpp
b/cppcache/include/geode/Serializer.hpp
index 9f4ec45..3c3898b 100644
--- a/cppcache/include/geode/Serializer.hpp
+++ b/cppcache/include/geode/Serializer.hpp
@@ -261,19 +261,19 @@ inline void readObject(apache::geode::client::DataInput&
input, TObj*& array,
template <typename TObj,
typename std::enable_if<!std::is_base_of<Serializable, TObj>::value,
Serializable>::type* = nullptr>
-inline uint32_t objectArraySize(const std::vector<TObj>& array) {
- return (uint32_t)(sizeof(TObj) * array.size());
+inline size_t objectArraySize(const std::vector<TObj>& array) {
+ return sizeof(TObj) * array.size();
}
template <typename TObj,
typename std::enable_if<std::is_base_of<Serializable, TObj>::value,
Serializable>::type* = nullptr>
-inline uint32_t objectArraySize(const std::vector<TObj>& array) {
- uint32_t size = 0;
+inline size_t objectArraySize(const std::vector<TObj>& array) {
+ size_t size = 0;
for (auto obj : array) {
size += obj.objectArraySize();
}
- size += (uint32_t)(sizeof(TObj) * array.size());
+ size += sizeof(TObj) * array.size();
return size;
}
diff --git a/cppcache/include/geode/internal/CacheableKeys.hpp
b/cppcache/include/geode/internal/CacheableKeys.hpp
index 22e8be3..59aae9c 100644
--- a/cppcache/include/geode/internal/CacheableKeys.hpp
+++ b/cppcache/include/geode/internal/CacheableKeys.hpp
@@ -48,9 +48,7 @@ inline int32_t hashcode(const int16_t value) {
return static_cast<int32_t>(value);
}
-inline int32_t hashcode(const int32_t value) {
- return static_cast<int32_t>(value);
-}
+inline int32_t hashcode(const int32_t value) { return value; }
inline int32_t hashcode(const int64_t value) {
int32_t hash = static_cast<int32_t>(value);
diff --git a/cppcache/integration-test/BuiltinCacheableWrappers.hpp
b/cppcache/integration-test/BuiltinCacheableWrappers.hpp
index 9726b64..951b03f 100644
--- a/cppcache/integration-test/BuiltinCacheableWrappers.hpp
+++ b/cppcache/integration-test/BuiltinCacheableWrappers.hpp
@@ -129,7 +129,7 @@ inline double random(double maxValue) {
template <typename TPRIM>
inline TPRIM random(TPRIM maxValue) {
- return (TPRIM)random((double)maxValue);
+ return static_cast<TPRIM>(random(static_cast<double>(maxValue)));
}
// This returns an array allocated on heap
@@ -338,7 +338,8 @@ class CacheableDateWrapper : public CacheableWrapper {
const ACE_Time_Value currentTime = ACE_OS::gettimeofday();
timeofday = currentTime.sec();
- time_t epoctime = (time_t)(timeofday + (rnd * (rnd % 2 == 0 ? 1 : -1)));
+ time_t epoctime =
+ static_cast<time_t>(timeofday + (rnd * (rnd % 2 == 0 ? 1 : -1)));
m_cacheableObject = CacheableDate::create(epoctime);
}
@@ -1035,7 +1036,7 @@ class CacheableNullStringWrapper : public
CacheableWrapper {
// CacheableWrapper members
void initRandomValue(int32_t) override {
- m_cacheableObject = CacheableString::create((char*)nullptr);
+ m_cacheableObject = CacheableString::create(static_cast<char*>(nullptr));
}
uint32_t getCheckSum(const std::shared_ptr<Cacheable> object) const override
{
diff --git a/cppcache/integration-test/ThinClientSecurityHelper.hpp
b/cppcache/integration-test/ThinClientSecurityHelper.hpp
index d6fe51f..2091ecc 100644
--- a/cppcache/integration-test/ThinClientSecurityHelper.hpp
+++ b/cppcache/integration-test/ThinClientSecurityHelper.hpp
@@ -1,8 +1,3 @@
-#pragma once
-
-#ifndef GEODE_INTEGRATION_TEST_THINCLIENTSECURITYHELPER_H_
-#define GEODE_INTEGRATION_TEST_THINCLIENTSECURITYHELPER_H_
-
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -19,9 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
+#pragma once
+
+#ifndef GEODE_INTEGRATION_TEST_THINCLIENTSECURITYHELPER_H_
+#define GEODE_INTEGRATION_TEST_THINCLIENTSECURITYHELPER_H_
+
+#include <ace/Process.h>
+
#include "fw_dunit.hpp"
#include "ThinClientHelper.hpp"
-#include "ace/Process.h"
+#include "hacks/AceThreadId.h"
namespace {
@@ -214,7 +217,6 @@ class putThread : public ACE_Task_Base {
int svc(void) {
int ops = 0;
auto pid = ACE_OS::getpid();
- auto thr_id = ACE_OS::thr_self();
std::shared_ptr<CacheableKey> key;
std::shared_ptr<CacheableString> value;
std::vector<std::shared_ptr<CacheableKey>> keys0;
@@ -262,8 +264,8 @@ class putThread : public ACE_Task_Base {
m_reg->destroy(key);
}
} catch (Exception& ex) {
- printf("%d: %" PRIuPTR " exception got and exception message = %s\n",
- pid, (uintptr_t)thr_id, ex.what());
+ printf("%d: %" PRIu64 " exception got and exception message = %s\n",
+ pid, hacks::aceThreadId(ACE_OS::thr_self()), ex.what());
}
}
}
diff --git a/cppcache/integration-test/fw_dunit.cpp
b/cppcache/integration-test/fw_dunit.cpp
index ab6fa53..522b68b 100644
--- a/cppcache/integration-test/fw_dunit.cpp
+++ b/cppcache/integration-test/fw_dunit.cpp
@@ -176,10 +176,7 @@ class NamingContextImpl : virtual public NamingContext {
* otherwise returns 0.
*/
virtual int rebind(const char* key, int value) {
- char buf[VALUE_MAX] = {0};
- ACE_OS::sprintf(buf, "%d", value);
- int res = rebind(key, (const char*)buf);
- return res;
+ return rebind(key, std::to_string(value).c_str());
}
/**
diff --git a/cppcache/integration-test/testDataOutput.cpp
b/cppcache/integration-test/testDataOutput.cpp
index ca91131..348ce23 100644
--- a/cppcache/integration-test/testDataOutput.cpp
+++ b/cppcache/integration-test/testDataOutput.cpp
@@ -103,7 +103,7 @@ BEGIN_TEST(int_t)
{
DataOutputInternal dataOutput;
- dataOutput.writeInt((int32_t)0x11223344);
+ dataOutput.writeInt(static_cast<int32_t>(0x11223344));
const uint8_t* buffer = dataOutput.getBuffer();
dumpnbytes(buffer, 4);
ASSERT(buffer[0] == (uint8_t)0x11, "expected 0x11.");
diff --git a/cppcache/integration-test/testSerialization.cpp
b/cppcache/integration-test/testSerialization.cpp
index f424e7f..fd7a25b 100644
--- a/cppcache/integration-test/testSerialization.cpp
+++ b/cppcache/integration-test/testSerialization.cpp
@@ -101,7 +101,7 @@ class OtherType : public DataSerializable {
static std::shared_ptr<Cacheable> uniqueCT(int32_t i) {
auto ot = std::make_shared<OtherType>();
- ot->m_struct.a = (int)i;
+ ot->m_struct.a = static_cast<int>(i);
ot->m_struct.b = (i % 2 == 0) ? true : false;
ot->m_struct.c = static_cast<char>(65) + i;
ot->m_struct.d = ((2.0) * static_cast<double>(i));
diff --git a/cppcache/integration-test/testThinClientCacheables.cpp
b/cppcache/integration-test/testThinClientCacheables.cpp
index 1470eed..edd59b7 100644
--- a/cppcache/integration-test/testThinClientCacheables.cpp
+++ b/cppcache/integration-test/testThinClientCacheables.cpp
@@ -261,7 +261,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, GetsTask)
// have deserialized on server so checks serialization/deserialization
// compatibility with java server.
std::string queryStr = "SELECT DISTINCT iter.key, iter.value FROM /";
- queryStr += ((std::string)regionNames[0] + ".entrySet AS iter");
+ queryStr += (std::string(regionNames[0]) + ".entrySet AS iter");
dataReg->query(queryStr.c_str());
dataReg->localInvalidateRegion();
verifyReg->localInvalidateRegion();
diff --git a/cppcache/integration-test/testThinClientCacheablesLimits.cpp
b/cppcache/integration-test/testThinClientCacheablesLimits.cpp
index 4ca8566..8d0a826 100644
--- a/cppcache/integration-test/testThinClientCacheablesLimits.cpp
+++ b/cppcache/integration-test/testThinClientCacheablesLimits.cpp
@@ -79,7 +79,7 @@ uint8_t* createRandByteArray(int size) {
}
char* createRandCharArray(int size) {
char* ch;
- ch = (char *) std::malloc((size + 1) * sizeof(char));
+ ch = static_cast<char*>(std::malloc((size + 1) * sizeof(char)));
if (ch == nullptr) {
throw OutOfMemoryException(
"Out of Memory while resizing buffer");
diff --git a/cppcache/integration-test/testThinClientClearRegion.cpp
b/cppcache/integration-test/testThinClientClearRegion.cpp
index 76fc3bb..d869989 100644
--- a/cppcache/integration-test/testThinClientClearRegion.cpp
+++ b/cppcache/integration-test/testThinClientClearRegion.cpp
@@ -91,7 +91,7 @@ DUNIT_TASK(CLIENT2, SetupClient2)
"__TEST_POOL1__", true, true);
auto regPtr = getHelper()->getRegion(regionNames[0]);
regPtr->registerAllKeys();
- auto keyPtr = CacheableKey::create((const char*)"key01");
+ auto keyPtr = CacheableKey::create("key01");
auto valPtr =
CacheableBytes::create(std::vector<int8_t>{'v','a','l','u','e','0','1'});
regPtr->put(keyPtr, valPtr);
diff --git a/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
b/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
index c1e0d55..6f17ce5 100644
--- a/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
+++ b/cppcache/integration-test/testThinClientContainsKeyOnServer.cpp
@@ -44,7 +44,7 @@ DUNIT_TASK(CLIENT1, SetupClient1)
getHelper()->createPooledRegion(regionNames[0], false, locatorsG,
"__TEST_POOL1__", true, true);
auto regPtr = getHelper()->getRegion(regionNames[0]);
- auto key = CacheableKey::create((const char*)"key01");
+ auto key = CacheableKey::create("key01");
ASSERT(!regPtr->containsKeyOnServer(key), "key should not be there");
}
END_TASK(SetupClient1)
diff --git a/cppcache/integration-test/testThinClientPdxInstance.cpp
b/cppcache/integration-test/testThinClientPdxInstance.cpp
index bc812b2..5efe64a 100644
--- a/cppcache/integration-test/testThinClientPdxInstance.cpp
+++ b/cppcache/integration-test/testThinClientPdxInstance.cpp
@@ -1673,7 +1673,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
auto setVec = CacheableVector::create();
setVec->push_back(CacheableInt32::create(3));
setVec->push_back(CacheableInt32::create(4));
- wpiPtr->setField("m_vector", (std::shared_ptr<Cacheable>)setVec);
+ wpiPtr->setField("m_vector", setVec);
rptr->put(keyport, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport));
ASSERT(newPiPtr->hasField("m_vector") == true, "m_vector = true expected");
@@ -1702,7 +1702,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
setarr->push_back(CacheableInt32::create(3));
setarr->push_back(CacheableInt32::create(4));
setarr->push_back(CacheableInt32::create(5));
- wpiPtr->setField("m_arraylist", (std::shared_ptr<Cacheable>)setarr);
+ wpiPtr->setField("m_arraylist", setarr);
rptr->put(keyport, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport));
ASSERT(newPiPtr->hasField("m_arraylist") == true,
@@ -1733,7 +1733,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
hashset->insert(CacheableInt32::create(3));
hashset->insert(CacheableInt32::create(4));
hashset->insert(CacheableInt32::create(5));
- wpiPtr->setField("m_chs", (std::shared_ptr<Cacheable>)hashset);
+ wpiPtr->setField("m_chs", hashset);
rptr->put(keyport, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport));
ASSERT(newPiPtr->hasField("m_chs") == true, "m_chs = true expected");
@@ -1759,7 +1759,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
hashmap->emplace(CacheableInt32::create(3), CacheableInt32::create(3));
hashmap->emplace(CacheableInt32::create(4), CacheableInt32::create(4));
hashmap->emplace(CacheableInt32::create(5), CacheableInt32::create(5));
- wpiPtr->setField("m_map", (std::shared_ptr<Cacheable>)hashmap);
+ wpiPtr->setField("m_map", hashmap);
rptr->put(keyport, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport));
ASSERT(newPiPtr->hasField("m_map") == true, "m_map = true expected");
@@ -1785,7 +1785,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
linkedhashset->insert(CacheableInt32::create(3));
linkedhashset->insert(CacheableInt32::create(4));
linkedhashset->insert(CacheableInt32::create(5));
- wpiPtr->setField("m_clhs", (std::shared_ptr<Cacheable>)linkedhashset);
+ wpiPtr->setField("m_clhs", linkedhashset);
rptr->put(keyport, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport));
ASSERT(newPiPtr->hasField("m_clhs") == true, "m_clhs = true expected");
@@ -1851,8 +1851,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
wpiPtr = pIPtr->createWriter();
try {
- wpiPtr->setField("m_byteByteArray",
- (std::shared_ptr<Cacheable>)linkedhashset);
+ wpiPtr->setField("m_byteByteArray", linkedhashset);
FAIL(
"setField on m_byteByteArray with linkedhashset value should throw "
"expected IllegalStateException");
@@ -1888,7 +1887,7 @@ DUNIT_TASK_DEFINITION(CLIENT2, modifyPdxInstance)
wpiPtr = pIPtr->createWriter();
auto childpdxobjPtr = std::make_shared<ChildPdx>(2);
LOGINFO("created new childPdx");
- wpiPtr->setField("m_childPdx", (std::shared_ptr<Cacheable>)childpdxobjPtr);
+ wpiPtr->setField("m_childPdx", childpdxobjPtr);
LOGINFO("childPdx seField done");
rptr->put(keyport1, wpiPtr);
newPiPtr = std::dynamic_pointer_cast<PdxInstance>(rptr->get(keyport1));
diff --git
a/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
b/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
index a2b7293..572df63 100644
---
a/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
+++
b/cppcache/integration-test/testThinClientRegionQueryDifferentServerConfigs.cpp
@@ -102,8 +102,8 @@ DUNIT_TASK_DEFINITION(CLIENT1,
InitClientCreateRegionAndRunQueries)
qh.populatePortfolioData(reg, qh.getPortfolioSetSize(),
qh.getPortfolioNumSets());
- std::string qry1Str = (std::string) "select * from /" + qRegionNames[0];
- std::string qry2Str = (std::string) "select * from /" + qRegionNames[1];
+ std::string qry1Str = std::string("select * from /") + qRegionNames[0];
+ std::string qry2Str = std::string("select * from /") + qRegionNames[1];
std::shared_ptr<QueryService> qs = nullptr;
qs = pool1->getQueryService();
@@ -164,8 +164,8 @@ DUNIT_TASK_DEFINITION(CLIENT1, CreateRegionAndRunQueries)
qh.populatePositionData(reg, qh.getPositionSetSize(),
qh.getPositionNumSets());
- std::string qry1Str = (std::string) "select * from /" + qRegionNames[0];
- std::string qry2Str = (std::string) "select * from /" + qRegionNames[1];
+ std::string qry1Str = std::string("select * from /") + qRegionNames[0];
+ std::string qry2Str = std::string("select * from /") + qRegionNames[1];
std::shared_ptr<QueryService> qs = nullptr;
qs = pool2->getQueryService();
diff --git a/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
b/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
index 19ad5f3..73edbd9 100644
--- a/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
+++ b/cppcache/integration-test/testXmlCacheCreationWithPools.cpp
@@ -41,7 +41,7 @@ using apache::geode::client::Pool;
static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char* endPoints = (const char*)nullptr;
+const char* endPoints = nullptr;
const char* locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer,
numberOfLocators);
diff --git a/cppcache/integration-test/testXmlCacheInitialization.cpp
b/cppcache/integration-test/testXmlCacheInitialization.cpp
index 76e3b69..8002e15 100644
--- a/cppcache/integration-test/testXmlCacheInitialization.cpp
+++ b/cppcache/integration-test/testXmlCacheInitialization.cpp
@@ -37,7 +37,7 @@ using apache::geode::client::Exception;
static bool isLocalServer = false;
static bool isLocator = false;
static int numberOfLocators = 1;
-const char* endPoints = (const char*)nullptr;
+const char* endPoints = nullptr;
const char* locatorsG =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer,
numberOfLocators);
diff --git a/cppcache/src/PdxSerializable.cpp
b/cppcache/internal/hacks/AceThreadId.h
similarity index 57%
copy from cppcache/src/PdxSerializable.cpp
copy to cppcache/internal/hacks/AceThreadId.h
index 88816c5..1783c19 100644
--- a/cppcache/src/PdxSerializable.cpp
+++ b/cppcache/internal/hacks/AceThreadId.h
@@ -15,27 +15,30 @@
* limitations under the License.
*/
-#include <geode/PdxSerializable.hpp>
-#include <geode/CacheableString.hpp>
-#include <geode/internal/CacheableKeys.hpp>
+#pragma once
-#include "PdxHelper.hpp"
+#ifndef INTERNAL_HACKS_ACETHREADID_H_
+#define INTERNAL_HACKS_ACETHREADID_H_
-namespace apache {
-namespace geode {
-namespace client {
+#include <cstdint>
+#include <type_traits>
-std::string PdxSerializable::toString() const { return getClassName(); }
+namespace hacks {
-bool PdxSerializable::operator==(const CacheableKey& other) const {
- return (this == &other);
+template <class _T>
+uint64_t aceThreadId(
+ _T&& thread,
+ typename std::enable_if<std::is_pointer<_T>::value>::type* = nullptr) {
+ return reinterpret_cast<uintptr_t>(thread);
}
-int32_t PdxSerializable::hashcode() const {
- int64_t hash = static_cast<int64_t>((intptr_t)this);
- return apache::geode::client::internal::hashcode(hash);
+template <class _T>
+uint64_t aceThreadId(
+ _T&& thread,
+ typename std::enable_if<std::is_integral<_T>::value>::type* = nullptr) {
+ return thread;
}
-} // namespace client
-} // namespace geode
-} // namespace apache
+} // namespace hacks
+
+#endif // INTERNAL_HACKS_ACETHREADID_H_
diff --git a/cppcache/src/ClientProxyMembershipID.cpp
b/cppcache/src/ClientProxyMembershipID.cpp
index f5a10dd..faf38f1 100644
--- a/cppcache/src/ClientProxyMembershipID.cpp
+++ b/cppcache/src/ClientProxyMembershipID.cpp
@@ -127,7 +127,7 @@ void ClientProxyMembershipID::initObjectVars(
memcpy(&temp, hostAddr, 4);
m_memID.writeInt(static_cast<int32_t>(temp));
// m_memID.writeInt((int32_t)hostPort);
- m_memID.writeInt((int32_t)synch_counter);
+ m_memID.writeInt(static_cast<int32_t>(synch_counter));
m_memID.writeString(hostname);
m_memID.write(splitBrainFlag); // splitbrain flags
diff --git a/cppcache/src/DataOutput.cpp b/cppcache/src/DataOutput.cpp
index 0b713ba..be1f3d0 100644
--- a/cppcache/src/DataOutput.cpp
+++ b/cppcache/src/DataOutput.cpp
@@ -80,7 +80,7 @@ class TSSDataOutput {
} else {
uint8_t* buf;
*size = 8192;
- buf = (uint8_t*)std::malloc(8192 * sizeof(uint8_t));
+ buf = static_cast<uint8_t*>(std::malloc(8192 * sizeof(uint8_t)));
if (buf == nullptr) {
throw OutOfMemoryException("Out of Memory while resizing buffer");
}
diff --git a/cppcache/src/FairQueue.hpp b/cppcache/src/FairQueue.hpp
index 9530c89..a0faff9 100644
--- a/cppcache/src/FairQueue.hpp
+++ b/cppcache/src/FairQueue.hpp
@@ -58,7 +58,7 @@ class FairQueue {
T* mp = getNoGetLock(isClosed);
if (mp == nullptr && !isClosed) {
- mp = getUntilWithToken(sec, isClosed, (void*)nullptr);
+ mp = getUntilWithToken(sec, isClosed, static_cast<void*>(nullptr));
}
return mp;
}
diff --git a/cppcache/src/Log.cpp b/cppcache/src/Log.cpp
index b6f91ed..1e71e78 100644
--- a/cppcache/src/Log.cpp
+++ b/cppcache/src/Log.cpp
@@ -42,6 +42,7 @@
#include "util/Log.hpp"
#include "geodeBanner.hpp"
#include "Assert.hpp"
+#include "../internal/hacks/AceThreadId.h"
#if defined(_WIN32)
#include <io.h>
@@ -561,12 +562,12 @@ char* Log::formatLogLine(char* buf, LogLevel level) {
char* pbuf = buf;
pbuf += ACE_OS::snprintf(pbuf, 15, "[%s ", Log::levelToChars(level));
pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", tm_val);
- pbuf += ACE_OS::snprintf(pbuf, 15, ".%06" PRIu64 " ",
+ pbuf += ACE_OS::snprintf(pbuf, 15, ".%06" PRId64 " ",
static_cast<int64_t>(clock.usec()));
pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val);
ACE_OS::snprintf(pbuf, 300, "%s:%d %" PRIu64 "] ", g_uname.nodename, g_pid,
- (uint64_t)ACE_OS::thr_self());
+ hacks::aceThreadId(ACE_OS::thr_self()));
return buf;
}
diff --git a/cppcache/src/PdxHelper.cpp b/cppcache/src/PdxHelper.cpp
index 684cef8..b12caf2 100644
--- a/cppcache/src/PdxHelper.cpp
+++ b/cppcache/src/PdxHelper.cpp
@@ -272,7 +272,7 @@ std::shared_ptr<PdxSerializable> PdxHelper::deserializePdx(
cachePerfStats.incPdxDeSerialization(len + 9); // pdxLen + 1 + 2*4
- return PdxHelper::deserializePdx(dataInput, (int32_t)typeId, (int32_t)len);
+ return PdxHelper::deserializePdx(dataInput, typeId, len);
} else {
// Read Length
diff --git a/cppcache/src/PdxSerializable.cpp b/cppcache/src/PdxSerializable.cpp
index 88816c5..8bc3528 100644
--- a/cppcache/src/PdxSerializable.cpp
+++ b/cppcache/src/PdxSerializable.cpp
@@ -32,8 +32,8 @@ bool PdxSerializable::operator==(const CacheableKey& other)
const {
}
int32_t PdxSerializable::hashcode() const {
- int64_t hash = static_cast<int64_t>((intptr_t)this);
- return apache::geode::client::internal::hashcode(hash);
+ return internal::hashcode(
+ static_cast<int64_t>(reinterpret_cast<uintptr_t>(this)));
}
} // namespace client
diff --git a/cppcache/src/QueueConnectionRequest.cpp
b/cppcache/src/QueueConnectionRequest.cpp
index 4fc3d60..39f26d6 100644
--- a/cppcache/src/QueueConnectionRequest.cpp
+++ b/cppcache/src/QueueConnectionRequest.cpp
@@ -29,7 +29,7 @@ void QueueConnectionRequest::toData(DataOutput& output) const
{
output.write(static_cast<int8_t>(DSCode::ClientProxyMembershipId));
uint32_t buffLen = 0;
output.writeBytes(reinterpret_cast<uint8_t*>(const_cast<char*>(m_membershipID.getDSMemberId(buffLen))),
buffLen);
- output.writeInt((int32_t)1);
+ output.writeInt(static_cast<int32_t>(1));
output.writeInt(static_cast<int32_t>(m_redundantCopies));
writeSetOfServerLocation(output);
output.writeBoolean(m_findDurable);
diff --git a/cppcache/src/TcpConn.cpp b/cppcache/src/TcpConn.cpp
index 2618818..f2e91df 100644
--- a/cppcache/src/TcpConn.cpp
+++ b/cppcache/src/TcpConn.cpp
@@ -86,7 +86,7 @@ int32_t TcpConn::maxSize(ACE_HANDLE sock, int32_t flag,
int32_t size) {
void TcpConn::createSocket(ACE_HANDLE sock) {
LOGDEBUG("Creating plain socket stream");
- m_io = new ACE_SOCK_Stream((ACE_HANDLE)sock);
+ m_io = new ACE_SOCK_Stream(sock);
// m_io->enable(ACE_NONBLOCK);
}
@@ -356,7 +356,7 @@ uint16_t TcpConn::getPort() {
GF_DEV_ASSERT(m_io != nullptr);
ACE_INET_Addr localAddr;
- m_io->get_local_addr(*(ACE_Addr *)&localAddr);
+ m_io->get_local_addr(localAddr);
return localAddr.get_port_number();
}
diff --git a/cppcache/src/TcpConn.hpp b/cppcache/src/TcpConn.hpp
index 2fc9cd7..939944c 100644
--- a/cppcache/src/TcpConn.hpp
+++ b/cppcache/src/TcpConn.hpp
@@ -129,11 +129,11 @@ class APACHE_GEODE_EXPORT TcpConn : public Connector {
}
void setIntOption(int32_t level, int32_t option, int32_t val) {
- setOption(level, option, (void*)&val, sizeof(int32_t));
+ setOption(level, option, &val, sizeof(int32_t));
}
void setBoolOption(int32_t level, int32_t option, bool val) {
- setOption(level, option, (void*)&val, sizeof(bool));
+ setOption(level, option, &val, sizeof(bool));
}
virtual uint16_t getPort() override;
diff --git a/cppcache/src/TcpSslConn.cpp b/cppcache/src/TcpSslConn.cpp
index 54f3b23..104facf 100644
--- a/cppcache/src/TcpSslConn.cpp
+++ b/cppcache/src/TcpSslConn.cpp
@@ -119,7 +119,7 @@ void TcpSslConn::close() {
m_ssl->close();
gf_destroy_SslImpl func = reinterpret_cast<gf_destroy_SslImpl>(
m_dll.symbol("gf_destroy_SslImpl"));
- func((void*)m_ssl);
+ func(m_ssl);
m_ssl = nullptr;
}
}
@@ -202,7 +202,7 @@ uint16_t TcpSslConn::getPort() {
GF_DEV_ASSERT(m_ssl != nullptr);
ACE_INET_Addr localAddr;
- m_ssl->getLocalAddr(*(ACE_Addr*)&localAddr);
+ m_ssl->getLocalAddr(localAddr);
return localAddr.get_port_number();
}
diff --git a/cppcache/src/TcrConnection.cpp b/cppcache/src/TcrConnection.cpp
index 5155d6b..8565eed 100644
--- a/cppcache/src/TcrConnection.cpp
+++ b/cppcache/src/TcrConnection.cpp
@@ -139,7 +139,7 @@ bool TcrConnection::InitTcrConnection(
// permissible value for bug #232 for now.
// minus 10 sec because the GFE 5.7 gridDev branch adds a
// 5 sec buffer which was causing an int overflow.
- handShakeMsg.writeInt((int32_t)0x7fffffff - 10000);
+ handShakeMsg.writeInt(static_cast<int32_t>(0x7fffffff) - 10000);
}
// Write header for byte FixedID since GFE 5.7
@@ -174,7 +174,7 @@ bool TcrConnection::InitTcrConnection(
auto memIdBuffer = memId->getDSMemberId(memIdBufferLength);
handShakeMsg.writeBytes(reinterpret_cast<int8_t*>(const_cast<char*>(memIdBuffer)),
memIdBufferLength);
}
- handShakeMsg.writeInt((int32_t)1);
+ handShakeMsg.writeInt(static_cast<int32_t>(1));
bool isDhOn = false;
bool requireServerAuth = false;
@@ -475,17 +475,20 @@ bool TcrConnection::InitTcrConnection(
if (isClientNotification) readHandshakeInstantiatorMsg(connectTimeout);
break;
case REPLY_AUTHENTICATION_FAILED: {
- AuthenticationFailedException ex((char*)recvMessage.data());
+ AuthenticationFailedException ex(
+ reinterpret_cast<char*>(recvMessage.data()));
GF_SAFE_DELETE_CON(m_conn);
throwException(ex);
}
case REPLY_AUTHENTICATION_REQUIRED: {
- AuthenticationRequiredException ex((char*)recvMessage.data());
+ AuthenticationRequiredException ex(
+ reinterpret_cast<char*>(recvMessage.data()));
GF_SAFE_DELETE_CON(m_conn);
throwException(ex);
}
case REPLY_DUPLICATE_DURABLE_CLIENT: {
- DuplicateDurableClientException ex((char*)recvMessage.data());
+ DuplicateDurableClientException ex(
+ reinterpret_cast<char*>(recvMessage.data()));
GF_SAFE_DELETE_CON(m_conn);
throwException(ex);
}
@@ -493,10 +496,11 @@ bool TcrConnection::InitTcrConnection(
case REPLY_INVALID:
case UNSUCCESSFUL_SERVER_TO_CLIENT: {
LOGERROR("Handshake rejected by server[%s]: %s",
- m_endpointObj->name().c_str(), (char*)recvMessage.data());
- auto message =
- std::string("TcrConnection::TcrConnection: ") +
- "Handshake rejected by server: " + (char*)recvMessage.data();
+ m_endpointObj->name().c_str(),
+ reinterpret_cast<char*>(recvMessage.data()));
+ auto message = std::string("TcrConnection::TcrConnection: ") +
+ "Handshake rejected by server: " +
+ reinterpret_cast<char*>(recvMessage.data());
CacheServerException ex(message);
GF_SAFE_DELETE_CON(m_conn);
throw ex;
@@ -509,7 +513,8 @@ bool TcrConnection::InitTcrConnection(
recvMessage.data());
auto message =
std::string("TcrConnection::TcrConnection: Unknown error") +
- " received from server in handshake: " + (char*)recvMessage.data();
+ " received from server in handshake: " +
+ reinterpret_cast<char*>(recvMessage.data());
MessageException ex(message);
GF_SAFE_DELETE_CON(m_conn);
throw ex;
diff --git a/cppcache/src/TcrMessage.cpp b/cppcache/src/TcrMessage.cpp
index 2d0d7a4..f21bb31 100644
--- a/cppcache/src/TcrMessage.cpp
+++ b/cppcache/src/TcrMessage.cpp
@@ -84,7 +84,7 @@ void TcrMessage::setKeepAlive(bool keepalive) {
}
void TcrMessage::writeInterestResultPolicyPart(InterestResultPolicy policy) {
- m_request->writeInt((int32_t)3); // size
+ m_request->writeInt(static_cast<int32_t>(3)); // size
m_request->write(static_cast<int8_t>(1)); // isObject
m_request->write(static_cast<int8_t>(DSCode::FixedIDByte));
m_request->write(static_cast<int8_t>(DSCode::InterestResultPolicy));
@@ -92,20 +92,20 @@ void
TcrMessage::writeInterestResultPolicyPart(InterestResultPolicy policy) {
}
void TcrMessage::writeIntPart(int32_t intValue) {
- m_request->writeInt((int32_t)4);
+ m_request->writeInt(static_cast<int32_t>(4));
m_request->write(static_cast<int8_t>(0));
m_request->writeInt(intValue);
}
void TcrMessage::writeBytePart(uint8_t byteValue) {
- m_request->writeInt((int32_t)1);
+ m_request->writeInt(static_cast<int32_t>(1));
m_request->write(static_cast<int8_t>(0));
m_request->write(byteValue);
}
void TcrMessage::writeByteAndTimeOutPart(uint8_t byteValue,
std::chrono::milliseconds timeout) {
- m_request->writeInt((int32_t)5); // 1 (byte) + 4 (timeout)
+ m_request->writeInt(static_cast<int32_t>(5)); // 1 (byte) + 4 (timeout)
m_request->write(static_cast<int8_t>(0));
m_request->write(byteValue);
m_request->writeInt(static_cast<int32_t>(timeout.count()));
@@ -592,9 +592,10 @@ void TcrMessage::writeHeader(uint32_t msgType, uint32_t
numOfParts) {
LOGDEBUG("TcrMessage::writeHeader earlyAck = %d", earlyAck);
m_request->writeInt(static_cast<int32_t>(msgType));
- m_request->writeInt((int32_t)0); // write a dummy message len('0' here). At
- // the end write the length at the (buffer
+
- // 4) offset.
+ m_request->writeInt(
+ static_cast<int32_t>(0)); // write a dummy message len('0' here). At
+ // the end write the length at the (buffer +
+ // 4) offset.
m_request->writeInt(static_cast<int32_t>(numOfParts));
TXState* txState = TSSTXStateWrapper::s_geodeTSSTXState->getTXState();
if (txState == nullptr) {
@@ -1803,14 +1804,14 @@ TcrMessagePing::TcrMessagePing(DataOutput* dataOutput,
bool decodeAll) {
m_decodeAll = decodeAll;
m_request.reset(dataOutput);
m_request->writeInt(m_msgType);
- m_request->writeInt(
- (int32_t)0); // 17 is fixed message len ... PING only has a header.
- m_request->writeInt((int32_t)0); // Number of parts.
+ m_request->writeInt(static_cast<int32_t>(
+ 0)); // 17 is fixed message len ... PING only has a header.
+ m_request->writeInt(static_cast<int32_t>(0)); // Number of parts.
// int32_t txId = TcrMessage::m_transactionId++;
// Setting the txId to 0 for all ping message as it is not being used on the
// SERVER side or the
// client side.
- m_request->writeInt((int32_t)0);
+ m_request->writeInt(static_cast<int32_t>(0));
m_request->write(static_cast<int8_t>(0)); // Early ack is '0'.
m_msgLength = g_headerLen;
m_txId = 0;
@@ -1822,13 +1823,13 @@
TcrMessageCloseConnection::TcrMessageCloseConnection(DataOutput* dataOutput,
m_decodeAll = decodeAll;
m_request.reset(dataOutput);
m_request->writeInt(m_msgType);
- m_request->writeInt((int32_t)6);
- m_request->writeInt((int32_t)1); // Number of parts.
+ m_request->writeInt(static_cast<int32_t>(6));
+ m_request->writeInt(static_cast<int32_t>(1)); // Number of parts.
// int32_t txId = TcrMessage::m_transactionId++;
- m_request->writeInt((int32_t)0);
+ m_request->writeInt(static_cast<int32_t>(0));
m_request->write(static_cast<int8_t>(0)); // Early ack is '0'.
// last two parts are not used ... setting zero in both the parts.
- m_request->writeInt((int32_t)1); // len is 1
+ m_request->writeInt(static_cast<int32_t>(1)); // len is 1
m_request->write(static_cast<int8_t>(0)); // is obj is '0'.
// cast away constness here since we want to modify this
TcrMessage::m_keepalive = const_cast<uint8_t*>(m_request->getCursor());
@@ -2887,7 +2888,7 @@ std::shared_ptr<DSMemberForVersionStamp>
TcrMessage::readDSMember(
auto memId =
std::shared_ptr<ClientProxyMembershipID>(new
ClientProxyMembershipID());
memId->fromData(input);
- return (std::shared_ptr<DSMemberForVersionStamp>)memId;
+ return std::shared_ptr<DSMemberForVersionStamp>(memId);
} else if (typeidLen == 2) {
auto typeidofMember = input.readInt16();
if (typeidofMember != static_cast<int16_t>(DSFid::DiskStoreId)) {
diff --git a/cppcache/src/ThinClientLocatorHelper.cpp
b/cppcache/src/ThinClientLocatorHelper.cpp
index 6e701f1..df7d5e9 100644
--- a/cppcache/src/ThinClientLocatorHelper.cpp
+++ b/cppcache/src/ThinClientLocatorHelper.cpp
@@ -108,7 +108,7 @@ GfErrType ThinClientLocatorHelper::getAllServers(
std::make_shared<GetAllServersRequest>(serverGrp);
auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
- data.writeInt((int32_t)1001); // GOSSIPVERSION
+ data.writeInt(static_cast<int32_t>(1001)); // GOSSIPVERSION
data.writeObject(request);
auto sentLength = conn->send(
reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())),
data.getBufferLength(),
@@ -195,7 +195,7 @@ GfErrType
ThinClientLocatorHelper::getEndpointForNewCallBackConn(
memId, exclEndPts, redundancy, false, serverGrp);
auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
- data.writeInt((int32_t)1001); // GOSSIPVERSION
+ data.writeInt(static_cast<int32_t>(1001)); // GOSSIPVERSION
data.writeObject(request);
auto sentLength = conn->send(
reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())),
data.getBufferLength(),
@@ -373,7 +373,7 @@ GfErrType ThinClientLocatorHelper::updateLocators(
std::make_shared<LocatorListRequest>(serverGrp);
auto data =
m_poolDM->getConnectionManager().getCacheImpl()->createDataOutput();
- data.writeInt((int32_t)1001); // GOSSIPVERSION
+ data.writeInt(static_cast<int32_t>(1001)); // GOSSIPVERSION
data.writeObject(request);
auto sentLength = conn->send(
reinterpret_cast<char*>(const_cast<uint8_t*>(data.getBuffer())),
data.getBufferLength(),
diff --git a/cppcache/src/ThinClientPoolDM.cpp
b/cppcache/src/ThinClientPoolDM.cpp
index 3bd298b..cd83156 100644
--- a/cppcache/src/ThinClientPoolDM.cpp
+++ b/cppcache/src/ThinClientPoolDM.cpp
@@ -559,15 +559,14 @@ std::string ThinClientPoolDM::selectEndpoint(
// Update Locator Request Stats
getStats().incLoctorRequests();
- if (GF_NOERR != ((ThinClientLocatorHelper*)m_locHelper)
+ if (GF_NOERR != (m_locHelper)
->getEndpointForNewFwdConn(
outEndpoint, additionalLoc, excludeServers,
m_attrs->m_serverGrp, currentServer)) {
throw IllegalStateException("Locator query failed");
}
// Update Locator stats
- getStats().setLocators(
- ((ThinClientLocatorHelper*)m_locHelper)->getCurLocatorsNum());
+ getStats().setLocators((m_locHelper)->getCurLocatorsNum());
getStats().incLoctorResposes();
char epNameStr[128] = {0};
@@ -2110,8 +2109,7 @@ int ThinClientPoolDM::updateLocatorList(volatile bool&
isRunning) {
while (isRunning) {
m_updateLocatorListSema.acquire();
if (isRunning && !m_connManager.isNetDown()) {
- ((ThinClientLocatorHelper*)m_locHelper)
- ->updateLocators(this->getServerGroup());
+ (m_locHelper)->updateLocators(this->getServerGroup());
}
}
LOGFINE("Ending updateLocatorList thread for pool %s", m_poolName.c_str());
diff --git a/cppcache/src/Utils.cpp b/cppcache/src/Utils.cpp
index 7dd32b7..671086f 100644
--- a/cppcache/src/Utils.cpp
+++ b/cppcache/src/Utils.cpp
@@ -173,7 +173,7 @@ std::string Utils::convertBytesToString(const uint8_t*
bytes, size_t length,
std::stringstream ss;
ss << std::setfill('0') << std::hex;
for (size_t i = 0; i < length; ++i) {
- ss << std::setw(2) << (int)bytes[i];
+ ss << std::setw(2) << static_cast<int>(bytes[i]);
}
return ss.str();
}
diff --git a/cppcache/src/VersionTag.cpp b/cppcache/src/VersionTag.cpp
index 00a2e42..18741da 100644
--- a/cppcache/src/VersionTag.cpp
+++ b/cppcache/src/VersionTag.cpp
@@ -81,7 +81,7 @@ void VersionTag::readMembers(uint16_t flags, DataInput&
input) {
auto internalMemId = std::make_shared<ClientProxyMembershipID>();
internalMemId->readEssentialData(input);
m_internalMemId = m_memberListForVersionStamp.add(
- (std::shared_ptr<DSMemberForVersionStamp>)internalMemId);
+ std::dynamic_pointer_cast<DSMemberForVersionStamp>(internalMemId));
}
if ((flags & HAS_PREVIOUS_MEMBER_ID) != 0) {
if ((flags & DUPLICATE_MEMBER_IDS) != 0) {
diff --git a/cppcache/src/statistics/StatArchiveWriter.cpp
b/cppcache/src/statistics/StatArchiveWriter.cpp
index d6c0de2..019cd23 100644
--- a/cppcache/src/statistics/StatArchiveWriter.cpp
+++ b/cppcache/src/statistics/StatArchiveWriter.cpp
@@ -105,7 +105,7 @@ void StatDataOutput::resetBuffer() {
}
void StatDataOutput::writeByte(int8_t v) {
- dataBuffer->write((int8_t)v);
+ dataBuffer->write(v);
bytesWritten += 1;
}
@@ -227,7 +227,7 @@ void ResourceInst::writeSample() {
}
void ResourceInst::writeStatValue(StatisticDescriptor *sd, int64_t v) {
- StatisticDescriptorImpl *sdImpl = (StatisticDescriptorImpl *)sd;
+ auto sdImpl = static_cast<StatisticDescriptorImpl *>(sd);
if (sdImpl == nullptr) {
throw NullPointerException("could not downcast to
StatisticDescriptorImpl");
}
@@ -581,7 +581,7 @@ const ResourceType
*StatArchiveWriter::getResourceType(const Statistics *s) {
for (int32_t i = 0; i < descCnt; i++) {
std::string statsName = stats[i]->getName();
this->dataBuffer->writeUTF(statsName);
- StatisticDescriptorImpl *sdImpl = (StatisticDescriptorImpl *)stats[i];
+ auto sdImpl = static_cast<StatisticDescriptorImpl *>(stats[i]);
if (sdImpl == nullptr) {
throw NullPointerException(
"could not down cast to StatisticDescriptorImpl");
diff --git a/cppcache/src/util/string.hpp b/cppcache/src/util/string.hpp
index b17fb20..76869cc 100644
--- a/cppcache/src/util/string.hpp
+++ b/cppcache/src/util/string.hpp
@@ -35,7 +35,7 @@ namespace client {
*/
constexpr std::codecvt_mode codecvt_mode_native_endian =
endian::native == endian::little ? std::little_endian
- : (std::codecvt_mode)0;
+ : static_cast<std::codecvt_mode>(0);
inline std::u16string to_utf16(const std::string& utf8) {
#if defined(_MSC_VER) && _MSC_VER >= 1900
diff --git a/cppcache/test/CacheableStringTests.cpp
b/cppcache/test/CacheableStringTests.cpp
index 0379f42..6f1cb65 100644
--- a/cppcache/test/CacheableStringTests.cpp
+++ b/cppcache/test/CacheableStringTests.cpp
@@ -79,7 +79,7 @@ inline std::string to_hex(const uint8_t* bytes, size_t len) {
std::stringstream ss;
ss << std::setfill('0') << std::hex;
for (size_t i(0); i < len; ++i) {
- ss << std::setw(2) << (int)bytes[i];
+ ss << std::setw(2) << static_cast<int>(bytes[i]);
}
return ss.str();
}
diff --git a/cppcache/test/DataOutputTest.cpp b/cppcache/test/DataOutputTest.cpp
index 9eb85e7..15564d5 100644
--- a/cppcache/test/DataOutputTest.cpp
+++ b/cppcache/test/DataOutputTest.cpp
@@ -114,9 +114,9 @@ TEST_F(DataOutputTest, TestWriteInt8) {
TEST_F(DataOutputTest, TestWriteSequenceNumber) {
TestDataOutput dataOutput(nullptr);
- dataOutput.writeInt((int32_t)55);
- dataOutput.writeInt((int32_t)17);
- dataOutput.writeInt((int32_t)0);
+ dataOutput.writeInt(static_cast<int32_t>(55));
+ dataOutput.writeInt(static_cast<int32_t>(17));
+ dataOutput.writeInt(static_cast<int32_t>(0));
dataOutput.writeInt(getRandomSequenceNumber());
dataOutput.write(static_cast<uint8_t>(0U));
EXPECT_BYTEARRAY_EQ("000000370000001100000000\\h{8}00",
diff --git a/cryptoimpl/DHImpl.cpp b/cryptoimpl/DHImpl.cpp
index 81425b7..fe7e754 100644
--- a/cryptoimpl/DHImpl.cpp
+++ b/cryptoimpl/DHImpl.cpp
@@ -76,8 +76,8 @@ ASN1_SEQUENCE(
int gf_initDhKeys(void **dhCtx, const char *dhAlgo, const char *ksPath) {
int errorCode = DH_ERR_NO_ERROR; // No error;
- DHImpl *dhimpl = new DHImpl();
- *dhCtx = (void *)dhimpl;
+ auto dhimpl = new DHImpl();
+ *dhCtx = dhimpl;
// ksPath can be null
if (dhimpl->m_dh || !dhAlgo || strlen(dhAlgo) == 0) {
@@ -99,9 +99,10 @@ ASN1_SEQUENCE(
dhimpl->m_dh = DH_new();
- BIGNUM* pbn = nullptr;
- BIGNUM* gbn = nullptr;
- DH_get0_pqg(dhimpl->m_dh, const_cast<const BIGNUM**>(&pbn), nullptr,
const_cast<const BIGNUM**>(&gbn));
+ BIGNUM *pbn = nullptr;
+ BIGNUM *gbn = nullptr;
+ DH_get0_pqg(dhimpl->m_dh, const_cast<const BIGNUM **>(&pbn), nullptr,
+ const_cast<const BIGNUM **>(&gbn));
BN_dec2bn(&pbn, dhP);
LOGDH(" DHInit: P ptr is %p", pbn);
@@ -360,18 +361,18 @@ unsigned char *gf_encryptDH(void *dhCtx, const unsigned
char *cleartext,
// init openssl cipher context
if (dhimpl->m_skAlgo == "AES") {
int keySize = dhimpl->m_keySize > 128 ? dhimpl->m_keySize / 8 : 16;
- EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, (unsigned char
*)dhimpl->m_key,
- (unsigned char *)dhimpl->m_key + keySize);
+ EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, dhimpl->m_key,
+ dhimpl->m_key + keySize);
} else if (dhimpl->m_skAlgo == "Blowfish") {
int keySize = dhimpl->m_keySize > 128 ? dhimpl->m_keySize / 8 : 16;
EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, nullptr,
- (unsigned char *)dhimpl->m_key + keySize);
+ dhimpl->m_key + keySize);
EVP_CIPHER_CTX_set_key_length(ctx, keySize);
LOGDH("DHencrypt: BF keysize is %d", keySize);
- EVP_EncryptInit_ex(ctx, nullptr, nullptr, (unsigned char *)dhimpl->m_key,
nullptr);
+ EVP_EncryptInit_ex(ctx, nullptr, nullptr, dhimpl->m_key, nullptr);
} else if (dhimpl->m_skAlgo == "DESede") {
- EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, (unsigned char
*)dhimpl->m_key,
- (unsigned char *)dhimpl->m_key + 24);
+ EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, dhimpl->m_key,
+ dhimpl->m_key + 24);
}
if (!EVP_EncryptUpdate(ctx, ciphertext, &outlen, cleartext, len)) {
@@ -410,28 +411,28 @@ unsigned char *gf_decryptDH(void *dhCtx, const unsigned
char *cleartext,
LOGDH(" DH: gf_encryptDH using sk algo: %s, Keysize: %d",
dhimpl->m_skAlgo.c_str(), dhimpl->m_keySize);
- unsigned char *ciphertext =
+ auto ciphertext =
new unsigned char[len + 50]; // give enough room for padding
int outlen, tmplen;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
- const EVP_CIPHER *cipherFunc = dhimpl->getCipherFunc();
+ auto cipherFunc = dhimpl->getCipherFunc();
// init openssl cipher context
if (dhimpl->m_skAlgo == "AES") {
int keySize = dhimpl->m_keySize > 128 ? dhimpl->m_keySize / 8 : 16;
- EVP_DecryptInit_ex(ctx, cipherFunc, nullptr, (unsigned char
*)dhimpl->m_key,
- (unsigned char *)dhimpl->m_key + keySize);
+ EVP_DecryptInit_ex(ctx, cipherFunc, nullptr, dhimpl->m_key,
+ dhimpl->m_key + keySize);
} else if (dhimpl->m_skAlgo == "Blowfish") {
int keySize = dhimpl->m_keySize > 128 ? dhimpl->m_keySize / 8 : 16;
EVP_DecryptInit_ex(ctx, cipherFunc, nullptr, nullptr,
- (unsigned char *)dhimpl->m_key + keySize);
+ dhimpl->m_key + keySize);
EVP_CIPHER_CTX_set_key_length(ctx, keySize);
LOGDH("DHencrypt: BF keysize is %d", keySize);
- EVP_DecryptInit_ex(ctx, nullptr, nullptr, (unsigned char *)dhimpl->m_key,
nullptr);
+ EVP_DecryptInit_ex(ctx, nullptr, nullptr, dhimpl->m_key, nullptr);
} else if (dhimpl->m_skAlgo == "DESede") {
- EVP_DecryptInit_ex(ctx, cipherFunc, nullptr, (unsigned char
*)dhimpl->m_key,
- (unsigned char *)dhimpl->m_key + 24);
+ EVP_DecryptInit_ex(ctx, cipherFunc, nullptr, dhimpl->m_key,
+ dhimpl->m_key + 24);
}
if (!EVP_DecryptUpdate(ctx, ciphertext, &outlen, cleartext, len)) {
@@ -488,7 +489,7 @@ bool gf_verifyDH(void *dhCtx, const char *subject,
// Ignore first letter for comparision, openssl adds / before subject name
// e.g. /CN=geode1
- if (strcmp((const char *)certsubject + 1, subject) == 0) {
+ if (strcmp(certsubject + 1, subject) == 0) {
evpkey = X509_get_pubkey(dhimpl->m_serverCerts[item]);
cert = dhimpl->m_serverCerts[item];
LOGDH("Found subject [%s] in stored certificates", certsubject);
@@ -608,13 +609,14 @@ int DH_PUBKEY_set(DH_PUBKEY **x, EVP_PKEY *pkey) {
asn1int = BN_to_ASN1_INTEGER(pub_key, nullptr);
if ((i = i2d_ASN1_INTEGER(asn1int, nullptr)) <= 0) goto err;
- if ((s = reinterpret_cast<unsigned char *>(OPENSSL_malloc(i + 1))) ==
nullptr) {
+ if ((s = reinterpret_cast<unsigned char *>(OPENSSL_malloc(i + 1))) ==
+ nullptr) {
X509err(X509_F_X509_PUBKEY_SET, ERR_R_MALLOC_FAILURE);
goto err;
}
p = s;
i2d_ASN1_INTEGER(asn1int, &p);
- if (!ASN1_BIT_STRING_set((ASN1_STRING *)pk->public_key, s, i)) {
+ if (!ASN1_BIT_STRING_set(static_cast<ASN1_STRING *>(pk->public_key), s, i)) {
X509err(X509_F_X509_PUBKEY_SET, ERR_R_MALLOC_FAILURE);
goto err;
}
diff --git a/dhimpl/DHImpl.cpp b/dhimpl/DHImpl.cpp
index 25b7ba9..8e5e4b3 100644
--- a/dhimpl/DHImpl.cpp
+++ b/dhimpl/DHImpl.cpp
@@ -81,9 +81,10 @@ ASN1_SEQUENCE(
m_dh = DH_new();
- BIGNUM* pbn = nullptr;
- BIGNUM* gbn = nullptr;
- DH_get0_pqg(m_dh, const_cast<const BIGNUM**>(&pbn), nullptr,
const_cast<const BIGNUM**>(&gbn));
+ BIGNUM *pbn = nullptr;
+ BIGNUM *gbn = nullptr;
+ DH_get0_pqg(m_dh, const_cast<const BIGNUM **>(&pbn), nullptr,
+ const_cast<const BIGNUM **>(&gbn));
BN_dec2bn(&pbn, dhP);
LOGDH(" DHInit: P ptr is %p", pbn);
@@ -324,25 +325,22 @@ unsigned char *gf_encryptDH(const unsigned char
*cleartext, int len,
unsigned char *ciphertext =
new unsigned char[len + 50]; // give enough room for padding
int outlen, tmplen;
- EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
+ auto ctx = EVP_CIPHER_CTX_new();
- const EVP_CIPHER *cipherFunc = getCipherFunc();
+ auto cipherFunc = getCipherFunc();
// init openssl cipher context
if (m_skAlgo == "AES") {
int keySize = m_keySize > 128 ? m_keySize / 8 : 16;
- EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, (unsigned char *)m_key,
- (unsigned char *)m_key + keySize);
+ EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, m_key, m_key + keySize);
} else if (m_skAlgo == "Blowfish") {
int keySize = m_keySize > 128 ? m_keySize / 8 : 16;
- EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, nullptr,
- (unsigned char *)m_key + keySize);
+ EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, nullptr, m_key + keySize);
EVP_CIPHER_CTX_set_key_length(ctx, keySize);
LOGDH("DHencrypt: BF keysize is %d", keySize);
- EVP_EncryptInit_ex(ctx, nullptr, nullptr, (unsigned char *)m_key, nullptr);
+ EVP_EncryptInit_ex(ctx, nullptr, nullptr, m_key, nullptr);
} else if (m_skAlgo == "DESede") {
- EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, (unsigned char *)m_key,
- (unsigned char *)m_key + 24);
+ EVP_EncryptInit_ex(ctx, cipherFunc, nullptr, m_key, m_key + 24);
}
if (!EVP_EncryptUpdate(ctx, ciphertext, &outlen, cleartext, len)) {
@@ -393,12 +391,12 @@ bool gf_verifyDH(const char *subject, const unsigned char
*challenge,
}
for (int item = 0; item < count; item++) {
- certsubject =
- X509_NAME_oneline(X509_get_subject_name(m_serverCerts[item]), nullptr,
0);
+ certsubject = X509_NAME_oneline(X509_get_subject_name(m_serverCerts[item]),
+ nullptr, 0);
// Ignore first letter for comparision, openssl adds / before subject name
// e.g. /CN=geode1
- if (strcmp((const char *)certsubject + 1, subject) == 0) {
+ if (strcmp(certsubject + 1, subject) == 0) {
evpkey = X509_get_pubkey(m_serverCerts[item]);
cert = m_serverCerts[item];
LOGDH("Found subject [%s] in stored certificates", certsubject);
@@ -510,7 +508,8 @@ int DH_PUBKEY_set(DH_PUBKEY **x, EVP_PKEY *pkey) {
asn1int = BN_to_ASN1_INTEGER(pub_key, nullptr);
if ((i = i2d_ASN1_INTEGER(asn1int, nullptr)) <= 0) goto err;
- if ((s = reinterpret_cast<unsigned char *>(OPENSSL_malloc(i + 1))) ==
nullptr) {
+ if ((s = reinterpret_cast<unsigned char *>(OPENSSL_malloc(i + 1))) ==
+ nullptr) {
X509err(X509_F_X509_PUBKEY_SET, ERR_R_MALLOC_FAILURE);
goto err;
}
diff --git a/tests/cpp/fwklib/CMakeLists.txt b/tests/cpp/fwklib/CMakeLists.txt
index 87ad26d..acb532b 100644
--- a/tests/cpp/fwklib/CMakeLists.txt
+++ b/tests/cpp/fwklib/CMakeLists.txt
@@ -4,9 +4,9 @@
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -57,10 +57,11 @@ target_include_directories(framework
)
target_link_libraries(framework
- PUBLIC
+ PUBLIC
apache-geode
PRIVATE
ACE
+ internal
_WarningsAsError
)
diff --git a/tests/cpp/fwklib/FwkLog.cpp b/tests/cpp/fwklib/FwkLog.cpp
index 33f3105..a76e8c2 100644
--- a/tests/cpp/fwklib/FwkLog.cpp
+++ b/tests/cpp/fwklib/FwkLog.cpp
@@ -17,9 +17,12 @@
#include <cinttypes>
-#include "fwklib/FwkLog.hpp"
#include <geode/Exception.hpp>
+#include "fwklib/FwkLog.hpp"
+#include "fwklib/PerfFwk.hpp"
+#include "hacks/AceThreadId.h"
+
namespace apache {
namespace geode {
namespace client {
@@ -74,9 +77,9 @@ void plog(const char* l, const char* s, const char* filename,
int32_t lineno) {
const char* fil = dirAndFile(filename);
- fprintf(stdout, "[%s %s %s:P%d:T%" PRIXPTR "]::%s::%d %s %s\n", buf,
+ fprintf(stdout, "[%s %s %s:P%d:T%" PRIu64 "]::%s::%d %s %s\n", buf,
u.sysname, u.nodename, ACE_OS::getpid(),
- (uintptr_t)(ACE_Thread::self()), fil, lineno, l, s);
+ hacks::aceThreadId(ACE_OS::thr_self()), fil, lineno, l, s);
fflush(stdout);
}
diff --git a/tests/cpp/fwklib/IpcHandler.cpp b/tests/cpp/fwklib/IpcHandler.cpp
index fbe6d0f..43d19c6 100644
--- a/tests/cpp/fwklib/IpcHandler.cpp
+++ b/tests/cpp/fwklib/IpcHandler.cpp
@@ -93,16 +93,15 @@ int32_t IpcHandler::readInt(int32_t waitSeconds) {
FWKEXCEPTION("Connection failure, error: " << errno);
}
- ACE_Time_Value *wtime = new ACE_Time_Value(waitSeconds, 1000);
+ auto wtime = new ACE_Time_Value(waitSeconds, 1000);
int32_t redInt = -1;
- int32_t red =
- static_cast<int32_t>(m_io->recv_n((void *)&redInt, 4, 0, wtime));
+ auto length = m_io->recv_n(&redInt, 4, 0, wtime);
delete wtime;
- if (red == 4) {
+ if (length == 4) {
result = ntohl(redInt);
// FWKDEBUG( "Received " << result );
} else {
- if (red == -1) {
+ if (length == -1) {
#ifdef WIN32
errno = WSAGetLastError();
#endif
@@ -151,11 +150,10 @@ std::string IpcHandler::readString(int32_t waitSeconds) {
ACE_Time_Value *wtime = new ACE_Time_Value(waitSeconds, 1000);
- int32_t red =
- static_cast<int32_t>(m_io->recv((void *)buffer, length, 0, wtime));
+ auto readLength = m_io->recv(buffer, length, 0, wtime);
delete wtime;
- if (red <= 0) {
- if (red < 0) {
+ if (readLength <= 0) {
+ if (readLength < 0) {
#ifdef WIN32
errno = WSAGetLastError();
#endif
@@ -214,8 +212,7 @@ bool IpcHandler::sendIpcMsg(IpcMsg msg, int32_t
waitSeconds) {
int32_t writeInt = htonl(msg);
// FWKDEBUG( "Sending " << ( int32_t )msg );
ACE_Time_Value tv(waitSeconds, 1000);
- int32_t wrote =
- static_cast<int32_t>(m_io->send((const void *)&writeInt, 4, &tv));
+ auto wrote = m_io->send(&writeInt, 4, &tv);
if (wrote == -1) {
#ifdef WIN32
errno = WSAGetLastError();
@@ -242,7 +239,7 @@ bool IpcHandler::sendIpcMsg(IpcMsg msg, int32_t
waitSeconds) {
}
bool IpcHandler::sendBuffer(IpcMsg msg, const char *str) {
- int32_t length = static_cast<int32_t>(strlen(str));
+ auto length = static_cast<int32_t>(strlen(str));
char *buffer = checkBuffer(length);
*reinterpret_cast<IpcMsg *>(buffer) = static_cast<IpcMsg>(htonl(msg));
*reinterpret_cast<int32_t *>(buffer + 4) = htonl(length);
@@ -250,8 +247,7 @@ bool IpcHandler::sendBuffer(IpcMsg msg, const char *str) {
// FWKDEBUG( "Sending " << ( int32_t )msg << " and string: " << str );
length += 8;
- int32_t wrote =
- static_cast<int32_t>(m_io->send((const void *)buffer, length));
+ auto wrote = m_io->send(buffer, length);
if (wrote == -1) {
#ifdef WIN32
errno = WSAGetLastError();
diff --git a/tests/cpp/fwklib/TcpIpc.cpp b/tests/cpp/fwklib/TcpIpc.cpp
index 26f1861..5b094d6 100644
--- a/tests/cpp/fwklib/TcpIpc.cpp
+++ b/tests/cpp/fwklib/TcpIpc.cpp
@@ -39,7 +39,7 @@ namespace testframework {
void TcpIpc::clearNagle(ACE_HANDLE sock) {
int32_t val = 1;
- char *param = (char *)&val;
+ char *param = reinterpret_cast<char *>(&val);
int32_t plen = sizeof(val);
if (0 != ACE_OS::setsockopt(sock, IPPROTO_TCP, 1, param, plen)) {
diff --git a/tests/cpp/fwklib/UDPIpc.cpp b/tests/cpp/fwklib/UDPIpc.cpp
index acba938..95608fd 100644
--- a/tests/cpp/fwklib/UDPIpc.cpp
+++ b/tests/cpp/fwklib/UDPIpc.cpp
@@ -76,7 +76,7 @@ bool UDPMessage::receiveFrom(ACE_SOCK_Dgram& io,
FWKEXCEPTION("UDPMessage::receiveFrom: Failed, header length: " << len);
}
clear();
- memcpy((void*)&m_hdr, buffs.iov_base, UDP_HEADER_SIZE);
+ memcpy(&m_hdr, buffs.iov_base, UDP_HEADER_SIZE);
if (m_hdr.tag != UDP_MSG_TAG) {
FWKEXCEPTION("UDPMessage::receiveFrom: Failed, invalid tag: " <<
m_hdr.tag);
}
diff --git a/tests/cpp/testobject/PdxClassV2.cpp
b/tests/cpp/testobject/PdxClassV2.cpp
index fbc6b2c..624d571 100644
--- a/tests/cpp/testobject/PdxClassV2.cpp
+++ b/tests/cpp/testobject/PdxClassV2.cpp
@@ -548,8 +548,8 @@ bool PdxTypesIgnoreUnreadFieldsV2::equals(
}
void PdxTypesIgnoreUnreadFieldsV2::updateMembers() {
- m_i5 = (int32_t)m_diffInExtraFields;
- m_i6 = (int32_t)m_diffInExtraFields;
+ m_i5 = static_cast<int32_t>(m_diffInExtraFields);
+ m_i6 = static_cast<int32_t>(m_diffInExtraFields);
}
void PdxTypesIgnoreUnreadFieldsV2::toData(PdxWriter& pw) const {
@@ -563,8 +563,8 @@ void PdxTypesIgnoreUnreadFieldsV2::toData(PdxWriter& pw)
const {
pw.writeInt("i5", m_diffInExtraFields);
pw.writeInt("i6", m_diffInExtraFields);
- m_i5 = (int32_t)m_diffInExtraFields;
- m_i6 = (int32_t)m_diffInExtraFields;
+ m_i5 = static_cast<int32_t>(m_diffInExtraFields);
+ m_i6 = static_cast<int32_t>(m_diffInExtraFields);
m_diffInSameFields++;
m_diffInExtraFields++;