GEODE-6567: Fix GCC 8 warnings. (#466)
* Exception variables need to be refs in catch blocks
* Fix size of a couple of stack-declared char buffers
diff --git a/cppcache/integration-test/ThinClientPutAll.hpp b/cppcache/integration-test/ThinClientPutAll.hpp
index 3ef4f28..505fd11 100644
--- a/cppcache/integration-test/ThinClientPutAll.hpp
+++ b/cppcache/integration-test/ThinClientPutAll.hpp
@@ -401,7 +401,7 @@
PdxTests::Address::createDeserializable);
serializationRegistry->addPdxSerializableType(
PdxTests::PdxTypes3::createDeserializable);
- } catch (Exception e) {
+ } catch (Exception&) {
LOG("Got expected Exception for Serialization, already registered");
}
// the client1 will register k0 and k1
@@ -446,7 +446,7 @@
PdxTests::Address::createDeserializable);
serializationRegistry->addPdxSerializableType(
PdxTests::PdxTypes3::createDeserializable);
- } catch (Exception e) {
+ } catch (Exception&) {
LOG("Got expected Exception for Serialization, already registered");
}
HashMapOfCacheable map0;
@@ -626,7 +626,7 @@
std::shared_ptr<CacheableKey> key;
regPtr0->invalidate(key);
FAIL("Invalidate on nullptr should throw exception");
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException&) {
LOG(" Got an expected exception invalidate on nullptr should be throwing "
"exception ");
}
diff --git a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
index 47927fc..e9fd8ae 100644
--- a/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
+++ b/cppcache/integration-test/ThinClientPutAllWithCallBack.hpp
@@ -402,7 +402,7 @@
PdxTests::Address::createDeserializable);
serializationRegistry->addPdxSerializableType(
PdxTests::PdxTypes3::createDeserializable);
- } catch (Exception e) {
+ } catch (Exception&) {
LOG("Got expected Exception for Serialization, already registered");
}
// the client1 will register k0 and k1
@@ -447,7 +447,7 @@
PdxTests::Address::createDeserializable);
serializationRegistry->addPdxSerializableType(
PdxTests::PdxTypes3::createDeserializable);
- } catch (Exception e) {
+ } catch (Exception&) {
LOG("Got expected Exception for Serialization, already registered");
}
HashMapOfCacheable map0;
@@ -634,7 +634,7 @@
std::shared_ptr<CacheableKey> key;
regPtr0->invalidate(key);
FAIL("Invalidate on nullptr should throw exception");
- } catch (IllegalArgumentException e) {
+ } catch (IllegalArgumentException&) {
LOG(" Got an expected exception invalidate on nullptr should be throwing "
"exception ");
}
diff --git a/cppcache/integration-test/ThinClientTransactions.hpp b/cppcache/integration-test/ThinClientTransactions.hpp
index 2c59300..0f9e22c 100644
--- a/cppcache/integration-test/ThinClientTransactions.hpp
+++ b/cppcache/integration-test/ThinClientTransactions.hpp
@@ -632,7 +632,7 @@
bool resumeExc = false;
try {
txManager->resume(m_suspendedTransaction);
- } catch (const IllegalStateException) {
+ } catch (const IllegalStateException&) {
resumeExc = true;
}
@@ -642,7 +642,7 @@
bool threwTransactionException = false;
try {
txManager->suspend();
- } catch (const TransactionException) {
+ } catch (const TransactionException&) {
threwTransactionException = true;
}
ASSERT(threwTransactionException,
@@ -769,7 +769,7 @@
bool resumeExc = false;
try {
txManager->resume(m_suspendedTransaction);
- } catch (const IllegalStateException) {
+ } catch (const IllegalStateException&) {
resumeExc = true;
}
diff --git a/cppcache/integration-test/ThinClientTransactionsXA.hpp b/cppcache/integration-test/ThinClientTransactionsXA.hpp
index 3d50393..e52a26f 100644
--- a/cppcache/integration-test/ThinClientTransactionsXA.hpp
+++ b/cppcache/integration-test/ThinClientTransactionsXA.hpp
@@ -645,7 +645,7 @@
bool resumeExc = false;
try {
txManager->resume(m_suspendedTransaction);
- } catch (const IllegalStateException) {
+ } catch (const IllegalStateException&) {
resumeExc = true;
}
@@ -655,7 +655,7 @@
bool threwTransactionException = false;
try {
txManager->suspend();
- } catch (const TransactionException) {
+ } catch (const TransactionException&) {
threwTransactionException = true;
}
ASSERT(threwTransactionException,
@@ -789,7 +789,7 @@
bool resumeExc = false;
try {
txManager->resume(m_suspendedTransaction);
- } catch (const IllegalStateException) {
+ } catch (const IllegalStateException&) {
resumeExc = true;
}
diff --git a/cppcache/integration-test/fw_helper.hpp b/cppcache/integration-test/fw_helper.hpp
index 2c4c10e..11d0ace 100644
--- a/cppcache/integration-test/fw_helper.hpp
+++ b/cppcache/integration-test/fw_helper.hpp
@@ -158,10 +158,10 @@
try {
this->setup();
this->doTest();
- } catch (TestException e) {
+ } catch (TestException& e) {
e.print();
failed.push_back(m_name);
- } catch (apache::geode::client::Exception ge) {
+ } catch (apache::geode::client::Exception& ge) {
fprintf(stdout, "%s\n", ge.getStackTrace().c_str());
failed.push_back(m_name);
}
diff --git a/cppcache/integration-test/testOverflowPutGetSqLite.cpp b/cppcache/integration-test/testOverflowPutGetSqLite.cpp
index 0d753d2..48a79a7 100644
--- a/cppcache/integration-test/testOverflowPutGetSqLite.cpp
+++ b/cppcache/integration-test/testOverflowPutGetSqLite.cpp
@@ -509,9 +509,9 @@
doNput(regionPtr, 100);
FAIL("Didn't get the expected exception");
} catch (apache::geode::client::Exception
- ex) { // expected sqlite full exception
- // catching generic message as we dont
- // have any specific sqlitefull exception
+ &ex) { // expected sqlite full exception
+ // catching generic message as we dont
+ // have any specific sqlitefull exception
char buffer[1024];
sprintf(buffer, "Got expected exception %s: msg = %s",
ex.getName().c_str(), ex.what());
diff --git a/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp b/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
index edd13d5..891e436 100644
--- a/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
+++ b/cppcache/integration-test/testThinClientRemoteQueryTimeout.cpp
@@ -219,7 +219,7 @@
char logmsg[50] = {0};
ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
- } catch (Exception excp) {
+ } catch (Exception &excp) {
std::string failmsg = "";
failmsg += "Second execute unwanted exception ";
failmsg += excp.getName();
@@ -301,7 +301,7 @@
char logmsg[50] = {0};
ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
- } catch (Exception excp) {
+ } catch (Exception &excp) {
std::string failmsg = "";
failmsg += "Fourth execute unwanted exception ";
failmsg += excp.getName();
@@ -402,7 +402,7 @@
char logmsg[50] = {0};
ACE_OS::sprintf(logmsg, "Result size is %zd", results->size());
LOG(logmsg);
- } catch (Exception excp) {
+ } catch (Exception &excp) {
std::string failmsg = "";
failmsg += "Sixth execute unwanted exception ";
failmsg += excp.getName();
diff --git a/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp b/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
index b8a3e47..9b730dc 100644
--- a/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
+++ b/cppcache/integration-test/testThinClientRemoteRegionQuery.cpp
@@ -48,11 +48,11 @@
bool isLocalServer = false;
bool isLocator = false;
-const char *poolNames[] = {"Pool1", "Pool2", "Pool3"};
-const char *locHostPort =
+const char* poolNames[] = {"Pool1", "Pool2", "Pool3"};
+const char* locHostPort =
CacheHelper::getLocatorHostPort(isLocator, isLocalServer, 1);
static bool m_isPdx = false;
-const char *qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
+const char* qRegionNames[] = {"Portfolios", "Positions", "Portfolios2",
"Portfolios3"};
DUNIT_TASK_DEFINITION(LOCATOR, StartLocator)
@@ -103,7 +103,7 @@
PositionPdx::createDeserializable);
serializationRegistry->addPdxSerializableType(
PortfolioPdx::createDeserializable);
- } catch (const IllegalStateException &) {
+ } catch (const IllegalStateException&) {
// ignore exception
}
createPool(poolNames[0], locHostPort, nullptr, 0, true);
@@ -132,7 +132,7 @@
auto regPtr2 = getHelper()->getRegion(qRegionNames[2]);
auto regPtr3 = getHelper()->getRegion(qRegionNames[3]);
- QueryHelper *qh = &QueryHelper::getHelper();
+ QueryHelper* qh = &QueryHelper::getHelper();
char buf[100];
sprintf(buf, "SetSize %zd, NumSets %zd", qh->getPortfolioSetSize(),
@@ -205,7 +205,7 @@
try {
auto results = region->query("");
FAIL("Expected IllegalArgumentException exception for empty predicate");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for empty "
"predicate:");
LOG(ex.what());
@@ -215,7 +215,7 @@
auto results = region->query((regionQueries[0].query()),
std::chrono::seconds(2200000));
FAIL("Expected IllegalArgumentException exception for invalid timeout");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for invalid "
"timeout:");
LOG(ex.what());
@@ -225,7 +225,7 @@
auto results =
region->query((regionQueries[0].query()), std::chrono::seconds(-1));
FAIL("Expected IllegalArgumentException exception for invalid timeout");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for invalid "
"timeout:");
LOG(ex.what());
@@ -233,7 +233,7 @@
try {
auto results = region->query("bad predicate");
FAIL("Expected QueryException exception for wrong predicate");
- } catch (QueryException ex) {
+ } catch (QueryException& ex) {
LOG("got expected QueryException exception for wrong predicate:");
LOG(ex.what());
}
@@ -275,7 +275,7 @@
try {
region->existsValue("");
FAIL("Expected IllegalArgumentException exception for empty predicate");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for empty "
"predicate:");
LOG(ex.what());
@@ -285,7 +285,7 @@
region->existsValue((regionQueries[0].query()),
std::chrono::seconds(2200000));
FAIL("Expected IllegalArgumentException exception for invalid timeout");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for invalid "
"timeout:");
LOG(ex.what());
@@ -294,7 +294,7 @@
try {
region->existsValue((regionQueries[0].query()), std::chrono::seconds(-1));
FAIL("Expected IllegalArgumentException exception for invalid timeout");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for invalid "
"timeout:");
LOG(ex.what());
@@ -302,7 +302,7 @@
try {
region->existsValue("bad predicate");
FAIL("Expected QueryException exception for wrong predicate");
- } catch (QueryException ex) {
+ } catch (QueryException& ex) {
LOG("got expected QueryException exception for wrong predicate:");
LOG(ex.what());
}
@@ -350,7 +350,7 @@
LOG(logmsg);
doAnyErrorOccured = true;
}
- } catch (const QueryException &) {
+ } catch (const QueryException&) {
if (regionQueryRowCounts[i] == 0 || regionQueryRowCounts[i] == 1) {
char logmsg[100] = {0};
ACE_OS::sprintf(
@@ -371,7 +371,7 @@
auto results =
std::dynamic_pointer_cast<SelectResults>(region->selectValue(""));
FAIL("Expected IllegalArgumentException exception for empty predicate");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for empty "
"predicate:");
LOG(ex.what());
@@ -382,7 +382,7 @@
std::dynamic_pointer_cast<SelectResults>(region->selectValue(
(regionQueries[0].query()), std::chrono::seconds(2200000)));
FAIL("Expected IllegalArgumentException exception for invalid timeout");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for invalid "
"timeout:");
LOG(ex.what());
@@ -393,7 +393,7 @@
std::dynamic_pointer_cast<SelectResults>(region->selectValue(
(regionQueries[0].query()), std::chrono::seconds(-1)));
FAIL("Expected IllegalArgumentException exception for invalid timeout");
- } catch (apache::geode::client::IllegalArgumentException ex) {
+ } catch (apache::geode::client::IllegalArgumentException& ex) {
LOG("got expected IllegalArgumentException exception for invalid "
"timeout:");
LOG(ex.what());
@@ -402,7 +402,7 @@
auto results = std::dynamic_pointer_cast<SelectResults>(
region->selectValue("bad predicate"));
FAIL("Expected IllegalArgumentException exception for wrong predicate");
- } catch (QueryException ex) {
+ } catch (QueryException& ex) {
LOG("got expected QueryException for wrong predicate:");
LOG(ex.what());
}
@@ -435,7 +435,7 @@
ACE_OS::sprintf(failmsg, "Query exception didnt occur for index %d", i);
LOG(failmsg);
FAIL(failmsg);
- } catch (apache::geode::client::QueryException ex) {
+ } catch (apache::geode::client::QueryException&) {
// ok, expecting an exception, do nothing
} catch (...) {
LOG("Got unexpected exception");
diff --git a/cppcache/integration-test/testThinClientRemoveOps.cpp b/cppcache/integration-test/testThinClientRemoveOps.cpp
index c08f8da..455d28e 100644
--- a/cppcache/integration-test/testThinClientRemoveOps.cpp
+++ b/cppcache/integration-test/testThinClientRemoveOps.cpp
@@ -506,7 +506,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
@@ -516,7 +516,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
@@ -749,7 +749,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -758,7 +758,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -779,7 +779,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
@@ -788,7 +788,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
@@ -931,7 +931,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -940,7 +940,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -994,7 +994,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -1003,7 +1003,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -1068,7 +1068,7 @@
FAIL(
"destroy on non=existent key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException & /*ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for key300");
}
@@ -1152,7 +1152,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
@@ -1162,7 +1162,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
@@ -1197,7 +1197,7 @@
CacheableInt32::create(val1));
auto vall = std::dynamic_pointer_cast<CacheableInt32>(regPtr0->get(key1));
FAIL("Expected EntryExistException here");
- } catch (EntryExistsException e) {
+ } catch (EntryExistsException &) {
LOG(" Expected EntryExistsException exception thrown by localCreate");
}
@@ -1261,7 +1261,7 @@
FAIL(
"Should have thrown EntryExistsException if entry already exist in "
"region.");
- } catch (EntryExistsException e) {
+ } catch (EntryExistsException &) {
LOG("Expected : check EntryExistsException if entry already exist in "
"region.");
}
@@ -1277,7 +1277,7 @@
regPtr0->localCreate(x, 1);
LOG("Entry with null key and value locally created successfully");
FAIL("Expected IllegalArgumentException here");
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException &ex) {
LOGINFO("Expected IllegalArgumentException : %s", ex.what());
}
@@ -1285,7 +1285,7 @@
regPtr0->localPut(x, 1);
LOG("Entry with null key and value locally put successfully");
FAIL("Expected IllegalArgumentException here");
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException &ex) {
LOGINFO("Expected IllegalArgumentException : %s", ex.what());
}
@@ -1293,28 +1293,28 @@
regPtr0->localDestroy(x);
LOG("Entry with null key locally deleted successfully");
FAIL("Expected IllegalArgumentException here");
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException &ex) {
LOGINFO("Expected IllegalArgumentException : %s", ex.what());
}
try {
regPtr0->localInvalidate(x);
LOG("Entry with null key locally invalidated successfully");
FAIL("Expected IllegalArgumentException here");
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException &ex) {
LOGINFO("Expected IllegalArgumentException : %s", ex.what());
}
try {
regPtr0->localRemove(x, 1);
LOG("Entry with null key and value locally removed successfully");
FAIL("Expected IllegalArgumentException here");
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException &ex) {
LOGINFO("Expected IllegalArgumentException : %s", ex.what());
}
try {
regPtr0->localRemoveEx(x);
LOG("Entry with null key locally removed if value exist successfully");
FAIL("Expected IllegalArgumentException here");
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException &ex) {
LOGINFO("Expected IllegalArgumentException : %s", ex.what());
}
@@ -1345,13 +1345,13 @@
retVal = regPtr0->get(x);
ASSERT(retVal == nullptr, "value should not be found");
FAIL("Expected IllegalArgumentException here for get");
- } catch (Exception) {
+ } catch (Exception &) {
LOG(" Expected exception thrown by get");
}
try {
regPtr0->localPut(keyObject1, x);
- } catch (IllegalArgumentException ex) {
+ } catch (IllegalArgumentException &ex) {
LOGINFO("Expected IllegalArgumentException : %s", ex.what());
}
retVal = regPtr0->get(keyObject1);
@@ -1392,7 +1392,7 @@
regPtr0->localCreate(keyObject3, 1);
FAIL("Expected EntryExistException here");
}
- } catch (EntryExistsException e) {
+ } catch (EntryExistsException &) {
LOG(" Expected EntryExistsException exception thrown by localCreate");
}
@@ -1440,7 +1440,7 @@
regPtr2->localCreate(CacheableString::create("XY"),
CacheableString::create("Y"));
FAIL("localDestroyRegion should have thrown exception");
- } catch (RegionDestroyedException e) {
+ } catch (RegionDestroyedException &) {
LOG(" Expected exception thrown by localCreate, since Region does not "
"exist");
}
@@ -1483,7 +1483,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -1493,7 +1493,7 @@
FAIL(
"destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"destroy operation on already removed entry.");
}
@@ -1568,7 +1568,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
@@ -1577,7 +1577,7 @@
FAIL(
"local destroy on already removed key should have thrown "
"EntryNotFoundException");
- } catch (EntryNotFoundException /*& ex*/) {
+ } catch (EntryNotFoundException &) {
LOG("Got expected EntryNotFoundException for "
"localDestroy operation on already removed entry.");
}
diff --git a/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp b/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
index 2b5a973..d2b59b5 100644
--- a/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
+++ b/cppcache/integration-test/testThinClientSSLAuthCorrupt.cpp
@@ -146,7 +146,7 @@
try {
regPtr->registerAllKeys(false, false, false);
FAIL("Should have got NotConnectedException during registerAllKeys");
- } catch (NotConnectedException exp) {
+ } catch (NotConnectedException &) {
LOG("Connection Failed as expected via NotConnectedException");
}
LOG("CreateRegions1_PoolLocators complete.");
diff --git a/cppcache/integration-test/testThinClientSSLAuthFail.cpp b/cppcache/integration-test/testThinClientSSLAuthFail.cpp
index 61ab7ff..307a9d2 100644
--- a/cppcache/integration-test/testThinClientSSLAuthFail.cpp
+++ b/cppcache/integration-test/testThinClientSSLAuthFail.cpp
@@ -146,7 +146,7 @@
try {
regPtr->registerAllKeys(false, false, false);
FAIL("Should have got NotConnectedException during registerAllKeys");
- } catch (NotConnectedException exp) {
+ } catch (NotConnectedException &) {
LOG("Connection Failed as expected via NotConnectedException");
}
LOG("CreateRegions1_PoolLocators complete.");
diff --git a/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp b/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
index 8bfd7d6..5fa241f 100644
--- a/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
+++ b/cppcache/integration-test/testThinClientSSLAuthUntrusted.cpp
@@ -147,7 +147,7 @@
try {
regPtr->registerAllKeys(false, false, false);
FAIL("Should have got NotConnectedException during registerAllKeys");
- } catch (NotConnectedException exp) {
+ } catch (NotConnectedException &) {
LOG("Connection Failed as expected via NotConnectedException");
}
LOG("CreateRegions1_PoolLocators complete.");
diff --git a/cppcache/src/Utils.cpp b/cppcache/src/Utils.cpp
index f8fa0ec..a832446 100644
--- a/cppcache/src/Utils.cpp
+++ b/cppcache/src/Utils.cpp
@@ -80,7 +80,7 @@
std::string endpoint;
std::string::size_type length = endpointsStr.size();
std::string::size_type pos = 0;
- ACE_TCHAR hostName[256], fullName[256];
+ ACE_TCHAR hostName[256], fullName[512];
pos = endpointsStr.find(':', 0);
if (pos != std::string::npos) {
endpoint = endpointsStr.substr(0, pos);
@@ -98,7 +98,7 @@
struct hostent* host;
host = ACE_OS::gethostbyname(hostName);
if (host) {
- std::snprintf(fullName, 256, "%s:%d", host->h_name, port);
+ std::snprintf(fullName, sizeof(fullName), "%s:%d", host->h_name, port);
return fullName;
}
} else {
@@ -106,7 +106,7 @@
if (pos != std::string::npos) {
ACE_INET_Addr addr(endpoints);
addr.get_host_name(hostName, 256);
- std::snprintf(fullName, 256, "%s:%d", hostName, port);
+ std::snprintf(fullName, sizeof(fullName), "%s:%d", hostName, port);
return fullName;
}
}
diff --git a/tests/cpp/testobject/Portfolio.cpp b/tests/cpp/testobject/Portfolio.cpp
index 36d914f..b711ef5 100644
--- a/tests/cpp/testobject/Portfolio.cpp
+++ b/tests/cpp/testobject/Portfolio.cpp
@@ -109,9 +109,10 @@
}
char position2buf[2048];
if (position2 != nullptr) {
- sprintf(position2buf, " P2: %s", position2->toString().c_str());
+ snprintf(position2buf, sizeof(position2buf), " P2: %s",
+ position2->toString().c_str());
} else {
- sprintf(position2buf, " P2: %s ]", "NULL");
+ snprintf(position2buf, sizeof(position2buf), " P2: %s ]", "NULL");
}
char creationdatebuf[2048];
if (creationDate != nullptr) {
@@ -121,9 +122,9 @@
sprintf(creationdatebuf, "creation Date %s", "NULL");
}
- char stringBuf[7000];
- sprintf(stringBuf, "%s%s%s%s%s", idbuf, pkidbuf, creationdatebuf,
- position1buf, position2buf);
+ char stringBuf[9000];
+ snprintf(stringBuf, sizeof(stringBuf), "%.1024s%.1024s%.1024s%.2048s%.2048s",
+ idbuf, pkidbuf, creationdatebuf, position1buf, position2buf);
return stringBuf;
}
diff --git a/tests/cpp/testobject/PortfolioPdx.cpp b/tests/cpp/testobject/PortfolioPdx.cpp
index 70abb9d..ba2c79a 100644
--- a/tests/cpp/testobject/PortfolioPdx.cpp
+++ b/tests/cpp/testobject/PortfolioPdx.cpp
@@ -146,9 +146,9 @@
sprintf(creationdatebuf, "creation Date %s", "NULL");
}
- char stringBuf[7000];
- sprintf(stringBuf, "%s%s%s%s%s", idbuf, pkidbuf, creationdatebuf,
- position1buf, position2buf);
+ char stringBuf[9000];
+ snprintf(stringBuf, sizeof(stringBuf), "%s%s%s%s%s", idbuf, pkidbuf,
+ creationdatebuf, position1buf, position2buf);
return stringBuf;
}