Revert "GEODE-2484 Replace ace calls to standard functions" Broken CL compiling on VS 2013 which does not have complete C++11 features, e.g. std::snprintf.
This reverts commit d4e0a8447b1e54d5c34a35069bc24a30d8258e2e. This closes #18. Project: http://git-wip-us.apache.org/repos/asf/geode-native/repo Commit: http://git-wip-us.apache.org/repos/asf/geode-native/commit/d7f6ac3d Tree: http://git-wip-us.apache.org/repos/asf/geode-native/tree/d7f6ac3d Diff: http://git-wip-us.apache.org/repos/asf/geode-native/diff/d7f6ac3d Branch: refs/heads/develop Commit: d7f6ac3d4978ae42266191c18e44eb3875c99156 Parents: 3daae6e Author: Jacob Barrett <jbarr...@pivotal.io> Authored: Fri Feb 17 13:54:09 2017 -0800 Committer: Jacob Barrett <jbarr...@pivotal.io> Committed: Fri Feb 17 13:54:41 2017 -0800 ---------------------------------------------------------------------- src/cppcache/src/CacheImpl.cpp | 9 +- src/cppcache/src/CacheXmlParser.cpp | 330 ++++++++----------- src/cppcache/src/CacheableDate.cpp | 13 +- src/cppcache/src/CacheableKey.cpp | 6 +- src/cppcache/src/CacheableString.cpp | 8 +- src/cppcache/src/ClientProxyMembershipID.cpp | 17 +- src/cppcache/src/ClientProxyMembershipID.hpp | 5 +- src/cppcache/src/CqEventImpl.cpp | 2 +- src/cppcache/src/DiffieHellman.cpp | 14 +- src/cppcache/src/DiskStoreId.cpp | 6 +- src/cppcache/src/EventId.cpp | 14 +- src/cppcache/src/Exception.cpp | 8 +- src/cppcache/src/ExceptionTypes.cpp | 2 +- src/cppcache/src/Log.cpp | 72 ++-- src/cppcache/src/PdxFieldType.cpp | 5 +- src/cppcache/src/PdxInstanceFactoryImpl.cpp | 10 +- src/cppcache/src/PdxInstanceImpl.cpp | 154 +++++---- src/cppcache/src/PdxReaderWithTypeCollector.cpp | 3 +- src/cppcache/src/PdxType.cpp | 10 +- src/cppcache/src/PoolAttributes.cpp | 4 +- src/cppcache/src/PoolFactory.cpp | 4 +- src/cppcache/src/Properties.cpp | 2 +- src/cppcache/src/ProxyRegion.cpp | 2 +- src/cppcache/src/ProxyRemoteQueryService.cpp | 8 +- src/cppcache/src/PutAllPartialResult.hpp | 12 +- src/cppcache/src/RegionAttributes.cpp | 30 +- src/cppcache/src/RegionFactory.cpp | 2 +- src/cppcache/src/RemoteQuery.cpp | 16 +- src/cppcache/src/ServerLocation.cpp | 3 +- src/cppcache/src/SslSockStream.cpp | 7 +- src/cppcache/src/StackFrame.cpp | 6 +- src/cppcache/src/SystemProperties.cpp | 63 ++-- src/cppcache/src/TcpConn.cpp | 23 +- src/cppcache/src/TcpSslConn.cpp | 24 +- src/cppcache/src/TcrMessage.hpp | 36 +- src/cppcache/src/ThinClientPoolDM.cpp | 12 +- src/cppcache/src/ThinClientRegion.cpp | 10 +- src/cppcache/src/Utils.cpp | 13 +- .../src/statistics/AtomicStatisticsImpl.cpp | 22 +- src/cppcache/src/statistics/HostStatHelper.cpp | 6 +- .../src/statistics/HostStatHelperLinux.cpp | 3 +- .../src/statistics/HostStatHelperSolaris.cpp | 11 +- .../src/statistics/HostStatHelperWin.cpp | 9 +- src/cppcache/src/statistics/HostStatSampler.cpp | 34 +- .../src/statistics/OsStatisticsImpl.cpp | 26 +- .../src/statistics/StatisticDescriptorImpl.cpp | 8 +- .../src/statistics/StatisticsTypeImpl.cpp | 6 +- 47 files changed, 539 insertions(+), 551 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/CacheImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CacheImpl.cpp b/src/cppcache/src/CacheImpl.cpp index 71fbb4f..308e13d 100644 --- a/src/cppcache/src/CacheImpl.cpp +++ b/src/cppcache/src/CacheImpl.cpp @@ -34,6 +34,7 @@ #include "ClientProxyMembershipID.hpp" #include "AutoDelete.hpp" #include <string> +#include "ace/OS.h" #include <gfcpp/PoolManager.hpp> #include <gfcpp/RegionAttributes.hpp> #include "ThinClientPoolHADM.hpp" @@ -483,7 +484,7 @@ void CacheImpl::createRegion(const char* name, RegionPtr tmp; if (0 == m_regions->find(namestr, tmp)) { char buffer[256]; - std::snprintf( + ACE_OS::snprintf( buffer, 256, "Cache::createRegion: \"%s\" region exists in local cache", namestr.c_str()); @@ -505,14 +506,14 @@ void CacheImpl::createRegion(const char* name, throw; } catch (std::exception& ex) { char buffer[512]; - std::snprintf(buffer, 512, + ACE_OS::snprintf(buffer, 512, "Cache::createRegion: Failed to create Region \"%s\" " "due to unknown exception: %s", namestr.c_str(), ex.what()); throw UnknownException(buffer); } catch (...) { char buffer[256]; - std::snprintf(buffer, 256, + ACE_OS::snprintf(buffer, 256, "Cache::createRegion: Failed to create Region \"%s\" " "due to unknown exception.", namestr.c_str()); @@ -520,7 +521,7 @@ void CacheImpl::createRegion(const char* name, } if (rpImpl == NULL) { char buffer[256]; - std::snprintf(buffer, 256, + ACE_OS::snprintf(buffer, 256, "Cache::createRegion: Failed to create Region \"%s\"", namestr.c_str()); throw RegionCreationFailedException(buffer); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/CacheXmlParser.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CacheXmlParser.cpp b/src/cppcache/src/CacheXmlParser.cpp index e73e974..e4f43ce 100644 --- a/src/cppcache/src/CacheXmlParser.cpp +++ b/src/cppcache/src/CacheXmlParser.cpp @@ -20,7 +20,6 @@ #include <gfcpp/PoolFactory.hpp> #include "AutoDelete.hpp" #include "CacheImpl.hpp" -#include <cstring> #if defined(_WIN32) #include <windows.h> @@ -83,67 +82,47 @@ extern "C" void startElementSAX2Function(void* ctx, const xmlChar* name, (!parser->isIllegalStateException()) && (!parser->isAnyOtherException())) { try { - if (strcmp(reinterpret_cast<const char*>(name), parser->CACHE) == 0) { + if (strcmp((char*)name, parser->CACHE) == 0) { parser->startCache(ctx, atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CLIENT_CACHE) == 0) { + } else if (strcmp((char*)name, parser->CLIENT_CACHE) == 0) { parser->startCache(ctx, atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PDX) == 0) { + } else if (strcmp((char*)name, parser->PDX) == 0) { parser->startPdx(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION) == 0) { + } else if (strcmp((char*)name, parser->REGION) == 0) { parser->incNesting(); parser->startRegion(atts, parser->isRootLevel()); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->ROOT_REGION) == 0) { + } else if (strcmp((char*)name, parser->ROOT_REGION) == 0) { parser->incNesting(); parser->startRegion(atts, parser->isRootLevel()); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION_ATTRIBUTES) == 0) { + } else if (strcmp((char*)name, parser->REGION_ATTRIBUTES) == 0) { parser->startRegionAttributes(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION_TIME_TO_LIVE) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION_IDLE_TIME) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->ENTRY_TIME_TO_LIVE) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->ENTRY_IDLE_TIME) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->EXPIRATION_ATTRIBUTES) == 0) { + } else if (strcmp((char*)name, parser->REGION_TIME_TO_LIVE) == 0) { + } else if (strcmp((char*)name, parser->REGION_IDLE_TIME) == 0) { + } else if (strcmp((char*)name, parser->ENTRY_TIME_TO_LIVE) == 0) { + } else if (strcmp((char*)name, parser->ENTRY_IDLE_TIME) == 0) { + } else if (strcmp((char*)name, parser->EXPIRATION_ATTRIBUTES) == 0) { parser->startExpirationAttributes(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CACHE_LOADER) == 0) { + } else if (strcmp((char*)name, parser->CACHE_LOADER) == 0) { parser->startCacheLoader(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CACHE_WRITER) == 0) { + } else if (strcmp((char*)name, parser->CACHE_WRITER) == 0) { parser->startCacheWriter(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CACHE_LISTENER) == 0) { + } else if (strcmp((char*)name, parser->CACHE_LISTENER) == 0) { parser->startCacheListener(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PARTITION_RESOLVER) == 0) { + } else if (strcmp((char*)name, parser->PARTITION_RESOLVER) == 0) { parser->startPartitionResolver(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PERSISTENCE_MANAGER) == 0) { + } else if (strcmp((char*)name, parser->PERSISTENCE_MANAGER) == 0) { parser->startPersistenceManager(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PROPERTIES) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PROPERTY) == 0) { + } else if (strcmp((char*)name, parser->PROPERTIES) == 0) { + } else if (strcmp((char*)name, parser->PROPERTY) == 0) { parser->startPersistenceProperties(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->POOL) == 0) { + } else if (strcmp((char*)name, parser->POOL) == 0) { parser->startPool(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->LOCATOR) == 0) { + } else if (strcmp((char*)name, parser->LOCATOR) == 0) { parser->startLocator(atts); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->SERVER) == 0) { + } else if (strcmp((char*)name, parser->SERVER) == 0) { parser->startServer(atts); } else { - std::string temp(reinterpret_cast<const char*>(name)); + std::string temp((char*)name); std::string s = "XML:Unknown XML element \"" + temp + "\""; throw CacheXmlException(s.c_str()); } @@ -176,65 +155,45 @@ extern "C" void endElementSAX2Function(void* ctx, const xmlChar* name) { (!parser->isIllegalStateException()) && (!parser->isAnyOtherException())) { try { - if (strcmp(reinterpret_cast<const char*>(name), parser->CACHE) == 0) { + if (strcmp((char*)name, parser->CACHE) == 0) { parser->endCache(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CLIENT_CACHE) == 0) { + } else if (strcmp((char*)name, parser->CLIENT_CACHE) == 0) { parser->endCache(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PDX) == 0) { + } else if (strcmp((char*)name, parser->PDX) == 0) { parser->endPdx(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION) == 0) { + } else if (strcmp((char*)name, parser->REGION) == 0) { parser->endRegion(parser->isRootLevel()); parser->decNesting(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->ROOT_REGION) == 0) { + } else if (strcmp((char*)name, parser->ROOT_REGION) == 0) { parser->endRegion(parser->isRootLevel()); parser->decNesting(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION_ATTRIBUTES) == 0) { + } else if (strcmp((char*)name, parser->REGION_ATTRIBUTES) == 0) { parser->endRegionAttributes(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION_TIME_TO_LIVE) == 0) { + } else if (strcmp((char*)name, parser->REGION_TIME_TO_LIVE) == 0) { parser->endRegionTimeToLive(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->REGION_IDLE_TIME) == 0) { + } else if (strcmp((char*)name, parser->REGION_IDLE_TIME) == 0) { parser->endRegionIdleTime(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->ENTRY_TIME_TO_LIVE) == 0) { + } else if (strcmp((char*)name, parser->ENTRY_TIME_TO_LIVE) == 0) { parser->endEntryTimeToLive(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->ENTRY_IDLE_TIME) == 0) { + } else if (strcmp((char*)name, parser->ENTRY_IDLE_TIME) == 0) { parser->endEntryIdleTime(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->EXPIRATION_ATTRIBUTES) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CACHE_LOADER) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CACHE_WRITER) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->CACHE_LISTENER) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PARTITION_RESOLVER) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PERSISTENCE_MANAGER) == 0) { + } else if (strcmp((char*)name, parser->EXPIRATION_ATTRIBUTES) == 0) { + } else if (strcmp((char*)name, parser->CACHE_LOADER) == 0) { + } else if (strcmp((char*)name, parser->CACHE_WRITER) == 0) { + } else if (strcmp((char*)name, parser->CACHE_LISTENER) == 0) { + } else if (strcmp((char*)name, parser->PARTITION_RESOLVER) == 0) { + } else if (strcmp((char*)name, parser->PERSISTENCE_MANAGER) == 0) { parser->endPersistenceManager(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PROPERTIES) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->PROPERTY) == 0) { - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->POOL) == 0) { + } else if (strcmp((char*)name, parser->PROPERTIES) == 0) { + } else if (strcmp((char*)name, parser->PROPERTY) == 0) { + } else if (strcmp((char*)name, parser->POOL) == 0) { parser->endPool(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->LOCATOR) == 0) { + } else if (strcmp((char*)name, parser->LOCATOR) == 0) { // parser->endLocator(); - } else if (strcmp(reinterpret_cast<const char*>(name), - parser->SERVER) == 0) { + } else if (strcmp((char*)name, parser->SERVER) == 0) { // parser->endServer(); } else { - std::string temp(reinterpret_cast<const char*>(name)); + std::string temp((char*)name); std::string s = "XML:Unknown XML element \"" + temp + "\""; throw CacheXmlException(s.c_str()); } @@ -383,7 +342,7 @@ void CacheXmlParser::handleParserErrors(int res) { if (res != 0) // xml file is not well-formed { char buf[256]; - std::snprintf(buf, 256, "Error code returned by xml parser is : %d ", + ACE_OS::snprintf(buf, 256, "Error code returned by xml parser is : %d ", res); Log::error(buf); @@ -479,10 +438,10 @@ void CacheXmlParser::create(Cache* cache) { void CacheXmlParser::startCache(void* ctx, const xmlChar** attrs) { int attrsCount = 0; if (attrs != NULL) { - const char* attrName; - const char* attrValue; - while ((attrName = reinterpret_cast<const char*>(attrs[attrsCount++])) != NULL) { - attrValue = reinterpret_cast<const char*>(attrs[attrsCount++]); + char* attrName; + char* attrValue; + while ((attrName = (char*)attrs[attrsCount++]) != NULL) { + attrValue = (char*)attrs[attrsCount++]; if (attrValue == NULL) { std::string exStr = "XML: No value provided for attribute: "; exStr += attrName; @@ -760,11 +719,11 @@ void CacheXmlParser::startRegion(const xmlChar** atts, bool isRoot) { } char* regionName = NULL; - const char* refid = NULL; + char* refid = NULL; for (int i = 0; (atts[i] != NULL); i++) { if (atts[i] != NULL) { - const char* name = (char*)atts[i]; + char* name = (char*)atts[i]; i++; if (atts[i] != NULL) { char* value = (char*)atts[i]; @@ -840,7 +799,7 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { throw CacheXmlException(s.c_str()); } - const char* refid = NULL; + char* refid = NULL; for (int i = 0; (atts[i] != NULL); i++) { i++; @@ -856,14 +815,12 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { throw CacheXmlException(s.c_str()); } - if (strcmp(reinterpret_cast<const char*>(atts[i - 1]), ID) == 0) { + if (strcmp((char*)atts[i - 1], ID) == 0) { RegionXmlCreation* region = reinterpret_cast<RegionXmlCreation*>(_stack.top()); - region->setAttrId( - std::string(reinterpret_cast<const char*>(atts[i]))); - } else if (strcmp(reinterpret_cast<const char*>(atts[i - 1]), - REFID) == 0) { - refid = reinterpret_cast<const char*>(atts[i]); + region->setAttrId(std::string((char*)atts[i])); + } else if (strcmp((char*)atts[i - 1], REFID) == 0) { + refid = (char*)atts[i]; } } } @@ -892,15 +849,13 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { _stack.push(attrsFactory); for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp(ID, reinterpret_cast<const char*>(atts[i])) == 0 || - strcmp(REFID, reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp(ID, (char*)atts[i]) == 0 || + strcmp(REFID, (char*)atts[i]) == 0) { i++; continue; - } else if (strcmp(CLIENT_NOTIFICATION_ENABLED, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(CLIENT_NOTIFICATION_ENABLED, (char*)atts[i]) == 0) { i++; - const char* client_notification_enabled = - reinterpret_cast<const char*>(atts[i]); + char* client_notification_enabled = (char*)atts[i]; if (strcmp("false", client_notification_enabled) == 0 || strcmp("FALSE", client_notification_enabled) == 0) { if (m_poolFactory) { @@ -912,34 +867,30 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { m_poolFactory->setSubscriptionEnabled(true); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML: " + temp + " is not a valid value for the attribute <client-notification>\n"; throw CacheXmlException(s.c_str()); } - } else if (strcmp(INITIAL_CAPACITY, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(INITIAL_CAPACITY, (char*)atts[i]) == 0) { i++; - const char* initialCapacity = reinterpret_cast<const char*>(atts[i]); + char* initialCapacity = (char*)atts[i]; attrsFactory->setInitialCapacity(atoi(initialCapacity)); - } else if (strcmp(CONCURRENCY_LEVEL, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(CONCURRENCY_LEVEL, (char*)atts[i]) == 0) { i++; - const char* concurrencyLevel = reinterpret_cast<const char*>(atts[i]); + char* concurrencyLevel = (char*)atts[i]; attrsFactory->setConcurrencyLevel(atoi(concurrencyLevel)); - } else if (strcmp(LOAD_FACTOR, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(LOAD_FACTOR, (char*)atts[i]) == 0) { i++; - const char* loadFactor = reinterpret_cast<const char*>(atts[i]); + char* loadFactor = (char*)atts[i]; attrsFactory->setLoadFactor( static_cast<float>(atof(loadFactor))); // check whether this works - } else if (strcmp(CACHING_ENABLED, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(CACHING_ENABLED, (char*)atts[i]) == 0) { bool flag = false; i++; - const char* cachingEnabled = reinterpret_cast<const char*>(atts[i]); + char* cachingEnabled = (char*)atts[i]; if (strcmp("true", cachingEnabled) == 0 || strcmp("TRUE", cachingEnabled) == 0) { flag = true; @@ -947,7 +898,7 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { strcmp("FALSE", cachingEnabled) == 0) { flag = false; } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML: " + temp + @@ -955,17 +906,15 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { throw CacheXmlException(s.c_str()); } attrsFactory->setCachingEnabled(flag); // check whether this works - } else if (strcmp(LRU_ENTRIES_LIMIT, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(LRU_ENTRIES_LIMIT, (char*)atts[i]) == 0) { i++; - const char* lruentriesLimit = reinterpret_cast<const char*>(atts[i]); + char* lruentriesLimit = (char*)atts[i]; int lruentriesLimitInt = atoi(lruentriesLimit); uint32_t temp = static_cast<uint32_t>(lruentriesLimitInt); attrsFactory->setLruEntriesLimit(temp); - } else if (strcmp(DISK_POLICY, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(DISK_POLICY, (char*)atts[i]) == 0) { i++; - const char* diskPolicy = reinterpret_cast<const char*>(atts[i]); + char* diskPolicy = (char*)atts[i]; if (strcmp(OVERFLOWS, diskPolicy) == 0) { attrsFactory->setDiskPolicy( apache::geode::client::DiskPolicyType::OVERFLOWS); @@ -975,19 +924,18 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { attrsFactory->setDiskPolicy( apache::geode::client::DiskPolicyType::NONE); } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML: " + temp + " is not a valid value for the attribute <disk-policy>"; throw CacheXmlException(s.c_str()); } - } else if (strcmp(ENDPOINTS, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(ENDPOINTS, (char*)atts[i]) == 0) { i++; if (m_poolFactory) { std::vector<std::pair<std::string, int>> endPoints( - parseEndPoints(reinterpret_cast<const char*>(atts[i]))); + parseEndPoints((char*)atts[i])); std::vector<std::pair<std::string, int>>::iterator endPoint; for (endPoint = endPoints.begin(); endPoint != endPoints.end(); endPoint++) { @@ -995,17 +943,15 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { } } isTCR = true; - } else if (strcmp(POOL_NAME, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(POOL_NAME, (char*)atts[i]) == 0) { i++; - const char* poolName = reinterpret_cast<const char*>(atts[i]); + char* poolName = (char*)atts[i]; attrsFactory->setPoolName(poolName); isTCR = true; - } else if (strcmp(CLONING_ENABLED, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(CLONING_ENABLED, (char*)atts[i]) == 0) { i++; bool flag = false; - const char* isClonable = reinterpret_cast<const char*>(atts[i]); + char* isClonable = (char*)atts[i]; if (strcmp("true", isClonable) == 0 || strcmp("TRUE", isClonable) == 0) { @@ -1014,7 +960,7 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { strcmp("FALSE", isClonable) == 0) { flag = false; } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML: " + temp + @@ -1024,12 +970,10 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { attrsFactory->setCloningEnabled(flag); isTCR = true; - } else if (strcmp(CONCURRENCY_CHECKS_ENABLED, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(CONCURRENCY_CHECKS_ENABLED, (char*)atts[i]) == 0) { bool flag = false; i++; - const char* concurrencyChecksEnabled = - reinterpret_cast<const char*>(atts[i]); + char* concurrencyChecksEnabled = (char*)atts[i]; if (strcmp("true", concurrencyChecksEnabled) == 0 || strcmp("TRUE", concurrencyChecksEnabled) == 0) { flag = true; @@ -1037,7 +981,7 @@ void CacheXmlParser::startRegionAttributes(const xmlChar** atts) { strcmp("FALSE", concurrencyChecksEnabled) == 0) { flag = false; } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML: " + temp + " is not a valid value for the attribute " @@ -1107,22 +1051,22 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) { "<expirartion-attributes>"; throw CacheXmlException(s.c_str()); } - const char* timeOut = NULL; + char* timeOut = NULL; int timeOutInt = 0; ExpirationAction::Action expire = ExpirationAction::INVALID_ACTION; for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp(TIMEOUT, reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp(TIMEOUT, (char*)atts[i]) == 0) { i++; - timeOut = reinterpret_cast<const char*>(atts[i]); + timeOut = (char*)atts[i]; if (strcmp(timeOut, "") == 0) { std::string s = "XML:Value for attribute <timeout> needs to be specified"; throw CacheXmlException(s.c_str()); } timeOutInt = atoi(timeOut); - } else if (strcmp(ACTION, reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(ACTION, (char*)atts[i]) == 0) { i++; - const char* action = reinterpret_cast<const char*>(atts[i]); + char* action = (char*)atts[i]; if (strcmp(action, "") == 0) { @@ -1141,14 +1085,14 @@ void CacheXmlParser::startExpirationAttributes(const xmlChar** atts) { } else if (strcmp(LOCAL_DESTROY, action) == 0) { expire = ExpirationAction::LOCAL_DESTROY; } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML: " + temp + " is not a valid value for the attribute <action>"; throw CacheXmlException(s.c_str()); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML:Incorrect attribute name specified in " @@ -1188,9 +1132,9 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) { char* libraryName = NULL; char* libraryFunctionName = NULL; for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp(LIBRARY_NAME, reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp(LIBRARY_NAME, (char*)atts[i]) == 0) { i++; - size_t len = strlen(reinterpret_cast<const char*>(atts[i])) + 1; + size_t len = strlen((char*)atts[i]) + 1; libraryName = new char[len]; /* adongre * CID 28824: Dereference before null check (REVERSE_INULL) @@ -1199,7 +1143,7 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) { std::string s = "Memory allocation fails"; throw CacheXmlException(s.c_str()); } - std::strncpy(libraryName, reinterpret_cast<const char*>(atts[i]), len); + ACE_OS::strncpy(libraryName, (char*)atts[i], len); if (libraryName == NULL) { std::string s = @@ -1209,10 +1153,9 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) { "will be set"; throw CacheXmlException(s.c_str()); } - } else if (strcmp(LIBRARY_FUNCTION_NAME, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(LIBRARY_FUNCTION_NAME, (char*)atts[i]) == 0) { i++; - size_t len = strlen(reinterpret_cast<const char*>(atts[i])) + 1; + size_t len = strlen((char*)atts[i]) + 1; libraryFunctionName = new char[len]; /* adongre * CID 28823: Dereference before null check (REVERSE_INULL) @@ -1222,8 +1165,7 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) { throw CacheXmlException(s.c_str()); } - std::strncpy(libraryFunctionName, - reinterpret_cast<const char*>(atts[i]), len); + ACE_OS::strncpy(libraryFunctionName, (char*)atts[i], len); if (libraryFunctionName == NULL) { std::string s = "XML:Value for the <library-function-name> needs to be provided"; @@ -1231,7 +1173,7 @@ void CacheXmlParser::startPersistenceManager(const xmlChar** atts) { throw CacheXmlException(s.c_str()); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML:Incorrect attribute name specified in <persistence-manager>: " + @@ -1277,21 +1219,21 @@ void CacheXmlParser::startPersistenceProperties(const xmlChar** atts) { m_config = Properties::create(); } } - const char* propName = NULL; - const char* propValue = NULL; + char* propName = NULL; + char* propValue = NULL; for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp("name", reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp("name", (char*)atts[i]) == 0) { i++; - propName = reinterpret_cast<const char*>(atts[i]); + propName = (char*)atts[i]; if (propName == NULL || strcmp(propName, "") == 0) { std::string s = "XML:Value for attribute <name> needs to be specified in the " "<property>"; throw CacheXmlException(s.c_str()); } - } else if (strcmp("value", reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp("value", (char*)atts[i]) == 0) { i++; - propValue = reinterpret_cast<const char*>(atts[i]); + propValue = (char*)atts[i]; if (propValue == NULL || strcmp(propValue, "") == 0) { std::string s = "XML:Value for attribute <value> needs to be " @@ -1299,7 +1241,7 @@ void CacheXmlParser::startPersistenceProperties(const xmlChar** atts) { throw CacheXmlException(s.c_str()); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML:Incorrect attribute name specified in <property>: " + temp; @@ -1320,8 +1262,8 @@ void CacheXmlParser::startPersistenceProperties(const xmlChar** atts) { } void CacheXmlParser::startCacheLoader(const xmlChar** atts) { - const char* libraryName = NULL; - const char* libraryFunctionName = NULL; + char* libraryName = NULL; + char* libraryFunctionName = NULL; int attrsCount = 0; if (!atts) { std::string s = "XML:No attributes provided for <cache-loader>"; @@ -1335,9 +1277,9 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) { } for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp(LIBRARY_NAME, reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp(LIBRARY_NAME, (char*)atts[i]) == 0) { i++; - libraryName = reinterpret_cast<const char*>(atts[i]); + libraryName = (char*)atts[i]; if (libraryName == NULL || strcmp(libraryName, "") == 0) { std::string s = "XML:The attribute <library-name> of <cache-loader> cannot be set " @@ -1346,17 +1288,16 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) { "will be set"; throw CacheXmlException(s.c_str()); } - } else if (strcmp(LIBRARY_FUNCTION_NAME, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(LIBRARY_FUNCTION_NAME, (char*)atts[i]) == 0) { i++; - libraryFunctionName = reinterpret_cast<const char*>(atts[i]); + libraryFunctionName = (char*)atts[i]; if (libraryFunctionName == NULL || strcmp(libraryFunctionName, "") == 0) { std::string s = "XML:Value for the <library-function-name> needs to be provided"; throw CacheXmlException(s.c_str()); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML:Incorrect attribute name specified in <cache-loader> : " + temp; @@ -1387,8 +1328,8 @@ void CacheXmlParser::startCacheLoader(const xmlChar** atts) { } void CacheXmlParser::startCacheListener(const xmlChar** atts) { - const char* libraryName = NULL; - const char* libraryFunctionName = NULL; + char* libraryName = NULL; + char* libraryFunctionName = NULL; int attrsCount = 0; if (!atts) { std::string s = "XML:No attributes provided for <cache-listener> "; @@ -1402,9 +1343,9 @@ void CacheXmlParser::startCacheListener(const xmlChar** atts) { } for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp(LIBRARY_NAME, reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp(LIBRARY_NAME, (char*)atts[i]) == 0) { i++; - libraryName = reinterpret_cast<const char*>(atts[i]); + libraryName = (char*)atts[i]; if (libraryName == NULL || strcmp(libraryName, "") == 0) { std::string s = "XML:The attribute <library-name> of the <cache-listener> tag " @@ -1413,17 +1354,16 @@ void CacheXmlParser::startCacheListener(const xmlChar** atts) { "default value will be set"; throw CacheXmlException(s.c_str()); } - } else if (strcmp(LIBRARY_FUNCTION_NAME, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(LIBRARY_FUNCTION_NAME, (char*)atts[i]) == 0) { i++; - libraryFunctionName = reinterpret_cast<const char*>(atts[i]); + libraryFunctionName = (char*)atts[i]; if (libraryFunctionName == NULL || strcmp(libraryFunctionName, "") == 0) { std::string s = "XML:Value for <library-function-name> needs to be provided"; throw CacheXmlException(s.c_str()); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML:Incorrect attribute name specified in <cache-listener> : " + @@ -1455,8 +1395,8 @@ void CacheXmlParser::startCacheListener(const xmlChar** atts) { } void CacheXmlParser::startPartitionResolver(const xmlChar** atts) { - const char* libraryName = NULL; - const char* libraryFunctionName = NULL; + char* libraryName = NULL; + char* libraryFunctionName = NULL; int attrsCount = 0; if (!atts) { std::string s = "XML:No attributes provided for <partition-resolver> "; @@ -1470,9 +1410,9 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) { } for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp(LIBRARY_NAME, reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp(LIBRARY_NAME, (char*)atts[i]) == 0) { i++; - libraryName = reinterpret_cast<const char*>(atts[i]); + libraryName = (char*)atts[i]; if (libraryName == NULL || strcmp(libraryName, "") == 0) { std::string s = "XML:The attribute <library-name> of the <partition-resolver> tag " @@ -1481,17 +1421,16 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) { "default value will be set"; throw CacheXmlException(s.c_str()); } - } else if (strcmp(LIBRARY_FUNCTION_NAME, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(LIBRARY_FUNCTION_NAME, (char*)atts[i]) == 0) { i++; - libraryFunctionName = reinterpret_cast<const char*>(atts[i]); + libraryFunctionName = (char*)atts[i]; if (libraryFunctionName == NULL || strcmp(libraryFunctionName, "") == 0) { std::string s = "XML:Value for <library-function-name> needs to be provided"; throw CacheXmlException(s.c_str()); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML:Incorrect attribute name specified in <partition-resolver> : " + @@ -1523,8 +1462,8 @@ void CacheXmlParser::startPartitionResolver(const xmlChar** atts) { } void CacheXmlParser::startCacheWriter(const xmlChar** atts) { - const char* libraryName = NULL; - const char* libraryFunctionName = NULL; + char* libraryName = NULL; + char* libraryFunctionName = NULL; int attrsCount = 0; if (!atts) { std::string s = "XML:No attributes provided for <cache-writer>"; @@ -1538,9 +1477,9 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) { } for (int i = 0; (atts[i] != NULL); i++) { - if (strcmp(LIBRARY_NAME, reinterpret_cast<const char*>(atts[i])) == 0) { + if (strcmp(LIBRARY_NAME, (char*)atts[i]) == 0) { i++; - libraryName = reinterpret_cast<const char*>(atts[i]); + libraryName = (char*)atts[i]; if (libraryName == NULL || strcmp(libraryName, "") == 0) { std::string s = "XML:The attribute <library-name> of <cache-writer> cannot be set " @@ -1549,17 +1488,16 @@ void CacheXmlParser::startCacheWriter(const xmlChar** atts) { "will be set"; throw CacheXmlException(s.c_str()); } - } else if (strcmp(LIBRARY_FUNCTION_NAME, - reinterpret_cast<const char*>(atts[i])) == 0) { + } else if (strcmp(LIBRARY_FUNCTION_NAME, (char*)atts[i]) == 0) { i++; - libraryFunctionName = reinterpret_cast<const char*>(atts[i]); + libraryFunctionName = (char*)atts[i]; if (libraryFunctionName == NULL || strcmp(libraryFunctionName, "") == 0) { std::string s = "XML:Value for the <library-function-name> needs to be provided"; throw CacheXmlException(s.c_str()); } } else { - const char* name = reinterpret_cast<const char*>(atts[i]); + char* name = (char*)atts[i]; std::string temp(name); std::string s = "XML:Incorrect attribute name specified in <cache-writer>: " + temp; http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/CacheableDate.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CacheableDate.cpp b/src/cppcache/src/CacheableDate.cpp index ca2369d..cbddfbc 100644 --- a/src/cppcache/src/CacheableDate.cpp +++ b/src/cppcache/src/CacheableDate.cpp @@ -23,7 +23,6 @@ #include <gfcpp/ExceptionTypes.hpp> #include <gfcpp/GeodeTypeIds.hpp> -#include <cstdio> #include <cwchar> #include <ace/OS.h> @@ -114,9 +113,9 @@ CacheableStringPtr CacheableDate::toString() const { struct tm date = {0}; time_t sec = m_timevalue / 1000; ACE_OS::localtime_r(&sec, &date); - std::snprintf(buffer, 24, "%d/%d/%d %d:%d:%d", date.tm_mon + 1, - date.tm_mday, date.tm_year + 1900, date.tm_hour, date.tm_min, - date.tm_sec); + ACE_OS::snprintf(buffer, 24, "%d/%d/%d %d:%d:%d", date.tm_mon + 1, + date.tm_mday, date.tm_year + 1900, date.tm_hour, date.tm_min, + date.tm_sec); return CacheableString::create(buffer); } @@ -124,9 +123,9 @@ int32_t CacheableDate::logString(char* buffer, int32_t maxLength) const { struct tm date = {0}; time_t sec = m_timevalue / 1000; ACE_OS::localtime_r(&sec, &date); - return std::snprintf(buffer, maxLength, - "CacheableDate (mm/dd/yyyy) ( %d/%d/%d )", - date.tm_mon + 1, date.tm_mday, date.tm_year + 1900); + return ACE_OS::snprintf(buffer, maxLength, + "CacheableDate (mm/dd/yyyy) ( %d/%d/%d )", + date.tm_mon + 1, date.tm_mday, date.tm_year + 1900); } } // namespace client http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/CacheableKey.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CacheableKey.cpp b/src/cppcache/src/CacheableKey.cpp index 660127d..065aea2 100644 --- a/src/cppcache/src/CacheableKey.cpp +++ b/src/cppcache/src/CacheableKey.cpp @@ -19,7 +19,7 @@ #include <gfcpp/CacheableKey.hpp> -#include <cstdio> +#include <ace/OS.h> #include <typeinfo> namespace apache { @@ -27,8 +27,8 @@ namespace geode { namespace client { int32_t CacheableKey::logString(char* buffer, int32_t maxLength) const { - return std::snprintf(buffer, maxLength, "%s( @0x%08lX )", - typeid(*this).name(), (unsigned long)this); + return ACE_OS::snprintf(buffer, maxLength, "%s( @0x%08lX )", + typeid(*this).name(), (unsigned long)this); } } // namespace client } // namespace geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/CacheableString.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CacheableString.cpp b/src/cppcache/src/CacheableString.cpp index 875af4a..50d638d 100644 --- a/src/cppcache/src/CacheableString.cpp +++ b/src/cppcache/src/CacheableString.cpp @@ -23,6 +23,8 @@ #include <cwchar> #include <cstdlib> +#include <ace/ACE.h> +#include <ace/OS.h> using namespace apache::geode::client; @@ -297,12 +299,12 @@ CacheableString::~CacheableString() { int32_t CacheableString::logString(char* buffer, int32_t maxLength) const { if (isCString()) { - return std::snprintf( + return ACE_OS::snprintf( buffer, maxLength, "%s( %s )", className(), (m_str != NULL ? reinterpret_cast<const char*>(m_str) : "null")); } else { GF_DEV_ASSERT(isWideString()); - int32_t numChars = std::snprintf(buffer, maxLength, "%s( ", className()); + int32_t numChars = ACE_OS::snprintf(buffer, maxLength, "%s( ", className()); if (numChars >= (int)maxLength || numChars <= 0) { return numChars; } @@ -316,7 +318,7 @@ int32_t CacheableString::logString(char* buffer, int32_t maxLength) const { } buffer += numChars; maxLength -= numChars; - numChars = std::snprintf(buffer, maxLength, " )"); + numChars = ACE_OS::snprintf(buffer, maxLength, " )"); return numChars + static_cast<int32_t>(buffer - bufStart); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ClientProxyMembershipID.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ClientProxyMembershipID.cpp b/src/cppcache/src/ClientProxyMembershipID.cpp index 407c1f6..2e546d3 100644 --- a/src/cppcache/src/ClientProxyMembershipID.cpp +++ b/src/cppcache/src/ClientProxyMembershipID.cpp @@ -89,7 +89,7 @@ void ClientProxyMembershipID::init(const std::string& dsName) { randString[RAND_STRING_LEN] = '\0'; } char ps[15] = {0}; - std::snprintf(ps, 15, "%d", pid); + ACE_OS::snprintf(ps, 15, "%d", pid); g_randString = "GFNative_"; g_randString.append(randString).append(ps); LOGINFO("Using %s as random data for ClientProxyMembershipID", @@ -217,12 +217,13 @@ void ClientProxyMembershipID::initObjectVars( * callers must be careful not to overflow the actual space of the * destination. * Use snprintf() instead, or correct precision specifiers. + * Fix : using ACE_OS::snprintf */ char PID[15] = {0}; char Synch_Counter[15] = {0}; - // std::snprintf(PID, 15, "%d",vPID); + // ACE_OS::snprintf(PID, 15, "%d",vPID); ACE_OS::itoa(vPID, PID, 10); - // std::snprintf(Synch_Counter, 15, "%d",synch_counter); + // ACE_OS::snprintf(Synch_Counter, 15, "%d",synch_counter); ACE_OS::itoa(synch_counter, Synch_Counter, 10); clientID.append(hostname); clientID.append("("); @@ -238,7 +239,7 @@ void ClientProxyMembershipID::initObjectVars( // int offset = 0; for (uint32_t i = 0; i < getHostAddrLen(); i++) { char hostInfo[16] = {0}; - // offset += std::snprintf(hostInfo + offset , 255 - offset, ":%x", + // offset += ACE_OS::snprintf(hostInfo + offset , 255 - offset, ":%x", // m_hostAddr[i]); ACE_OS::itoa(m_hostAddr[i], hostInfo, 16); m_hashKey.append(":"); @@ -247,7 +248,7 @@ void ClientProxyMembershipID::initObjectVars( m_hashKey.append(":"); char hostInfoPort[16] = {0}; ACE_OS::itoa(getHostPort(), hostInfoPort, 10); - // offset += std::snprintf(hostInfo + offset, 255 - offset , ":%d", + // offset += ACE_OS::snprintf(hostInfo + offset, 255 - offset , ":%d", // getHostPort()); m_hashKey.append(hostInfoPort); m_hashKey.append(":"); @@ -259,7 +260,7 @@ void ClientProxyMembershipID::initObjectVars( m_hashKey.append(":"); char viewid[16] = {0}; ACE_OS::itoa(m_vmViewId, viewid, 10); - // offset += std::snprintf(hostInfo + offset , 255 - offset , ":%d", + // offset += ACE_OS::snprintf(hostInfo + offset , 255 - offset , ":%d", // m_vmViewId); m_hashKey.append(viewid); } @@ -317,7 +318,7 @@ void ClientProxyMembershipID::getClientProxyMembershipID() { // DSMemberId = DSMemberId.append(host); // DSMemberId= DSMemberId.append("("); m_dsmemID.write(static_cast<int8_t>('(')); - int lenPid = std::snprintf(buf, 50, "%d", pid); + int lenPid = ACE_OS::snprintf(buf, 50, "%d", pid); // DSMemberId.append(buf); // m_dsmemID.writeInt((int32_t)pid); m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(buf), lenPid); @@ -335,7 +336,7 @@ void ClientProxyMembershipID::getClientProxyMembershipID() { m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(hexBuf), 8); m_dsmemID.write(static_cast<int8_t>(':')); // DSMemberId = DSMemberId.append(":"); - std::snprintf(dsName, 50, "%s", dsPtr->getName()); + ACE_OS::snprintf(dsName, 50, "%s", dsPtr->getName()); // DSMemberId.append(dsName); uint32_t dsLen = static_cast<uint32_t>(strlen(dsName)); m_dsmemID.writeBytesOnly(reinterpret_cast<int8_t*>(dsName), dsLen); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ClientProxyMembershipID.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ClientProxyMembershipID.hpp b/src/cppcache/src/ClientProxyMembershipID.hpp index ab3214d..8856b2c 100644 --- a/src/cppcache/src/ClientProxyMembershipID.hpp +++ b/src/cppcache/src/ClientProxyMembershipID.hpp @@ -25,6 +25,7 @@ #include <gfcpp/DataOutput.hpp> #include "GeodeTypeIdsImpl.hpp" #include "DSMemberForVersionStamp.hpp" +#include <ace/OS.h> #include <string> namespace apache { @@ -91,8 +92,8 @@ class ClientProxyMembershipID : public DSMemberForVersionStamp { char hostInfo[255] = {0}; uint32_t offset = 0; for (uint32_t i = 0; i < getHostAddrLen(); i++) { - offset += std::snprintf(hostInfo + offset, 255 - offset, ":%x", - m_hostAddr[i]); + offset += ACE_OS::snprintf(hostInfo + offset, 255 - offset, ":%x", + m_hostAddr[i]); } CacheableStringPtr tempHashCode = CacheableString::create(hostInfo, offset); result = result + tempHashCode->hashcode(); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/CqEventImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/CqEventImpl.cpp b/src/cppcache/src/CqEventImpl.cpp index d583fdf..6f796db 100644 --- a/src/cppcache/src/CqEventImpl.cpp +++ b/src/cppcache/src/CqEventImpl.cpp @@ -90,7 +90,7 @@ bool CqEventImpl::getError() { return m_error; } std::string CqEventImpl::toString() { char buffer[1024]; - std::snprintf( + ACE_OS::snprintf( buffer, 1024, "CqEvent CqName=%s; base operation=%d; cq operation= %d;key=%s;value=%s", m_cQuery->getName(), m_baseOp, m_queryOp, m_key->toString()->asChar(), http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/DiffieHellman.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/DiffieHellman.cpp b/src/cppcache/src/DiffieHellman.cpp index 9f30df8..e58d286 100644 --- a/src/cppcache/src/DiffieHellman.cpp +++ b/src/cppcache/src/DiffieHellman.cpp @@ -44,8 +44,8 @@ void* DiffieHellman::getOpenSSLFuncPtr(const char* function_name) { void* func = m_dll.symbol(function_name); if (func == NULL) { char msg[1000]; - std::snprintf(msg, 1000, "cannot find function %s in library %s", - function_name, "cryptoImpl"); + ACE_OS::snprintf(msg, 1000, "cannot find function %s in library %s", + function_name, "cryptoImpl"); LOGERROR(msg); throw IllegalStateException(msg); } @@ -61,7 +61,7 @@ void DiffieHellman::initOpenSSLFuncPtrs() { if (m_dll.open(libName, ACE_DEFAULT_SHLIB_MODE, 0) == -1) { char msg[1000]; - std::snprintf(msg, 1000, "cannot open library: %s", libName); + ACE_OS::snprintf(msg, 1000, "cannot open library: %s", libName); LOGERROR(msg); throw FileNotFoundException(msg); } @@ -99,13 +99,13 @@ void DiffieHellman::initDhKeys(const PropertiesPtr& props) { if (error == DH_ERR_UNSUPPORTED_ALGO) { // Unsupported Algorithm char msg[64] = {'\0'}; - std::snprintf(msg, 64, "Algorithm %s is not supported.", - dhAlgo->asChar()); + ACE_OS::snprintf(msg, 64, "Algorithm %s is not supported.", + dhAlgo->asChar()); throw IllegalArgumentException(msg); } else if (error == DH_ERR_ILLEGAL_KEYSIZE) { // Illegal Key size char msg[64] = {'\0'}; - std::snprintf(msg, 64, "Illegal key size for algorithm %s.", - dhAlgo->asChar()); + ACE_OS::snprintf(msg, 64, "Illegal key size for algorithm %s.", + dhAlgo->asChar()); throw IllegalArgumentException(msg); } else if (m_dhCtx == NULL) { throw IllegalStateException( http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/DiskStoreId.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/DiskStoreId.cpp b/src/cppcache/src/DiskStoreId.cpp index 5adfa81..cf5b2e7 100644 --- a/src/cppcache/src/DiskStoreId.cpp +++ b/src/cppcache/src/DiskStoreId.cpp @@ -16,6 +16,7 @@ */ #include "DiskStoreId.hpp" +#include <ace/OS.h> namespace apache { namespace geode { @@ -31,9 +32,10 @@ std::string DiskStoreId::getHashKey() { * callers must be careful not to overflow the actual space of the * destination. * Use snprintf() instead, or correct precision specifiers. + * Fix : using ACE_OS::snprintf */ - std::snprintf(hashCode, 128, "%" PRIx64 "_%" PRIx64, m_mostSig, - m_leastSig); + ACE_OS::snprintf(hashCode, 128, "%" PRIx64 "_%" PRIx64, m_mostSig, + m_leastSig); m_hashCode.append(hashCode); } return m_hashCode; http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/EventId.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/EventId.cpp b/src/cppcache/src/EventId.cpp index 197d2cb..d4c9f49 100644 --- a/src/cppcache/src/EventId.cpp +++ b/src/cppcache/src/EventId.cpp @@ -19,7 +19,9 @@ #include "GeodeTypeIdsImpl.hpp" #include "ClientProxyMembershipID.hpp" #include <ace/TSS_T.h> -#include <cstring> + +#include <ace/OS.h> +#include <ace/INET_Addr.h> namespace apache { namespace geode { @@ -132,7 +134,7 @@ int8_t EventId::typeId() const { return GeodeTypeIdsImpl::EventId; } EventId::EventId(char* memId, uint32_t memIdLen, int64_t thr, int64_t seq) { // TODO: statics being assigned; not thread-safe?? - std::memcpy(m_eidMem, memId, memIdLen); + ACE_OS::memcpy(m_eidMem, memId, memIdLen); m_eidMemLen = memIdLen; m_eidThr = thr; m_eidSeq = seq; @@ -178,10 +180,10 @@ EventId::~EventId() {} /** used to render as a string for logging. */ size_t EventId::logString(char* buffer, size_t maxLength) const { - return std::snprintf(buffer, maxLength, - "EventId( memID=[binary], thr=%" PRIi64 - ", seq=%" PRIi64 " )", - m_eidThr, m_eidSeq); + return ACE_OS::snprintf(buffer, maxLength, + "EventId( memID=[binary], thr=%" PRIi64 + ", seq=%" PRIi64 " )", + m_eidThr, m_eidSeq); } } // namespace client } // namespace geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/Exception.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/Exception.cpp b/src/cppcache/src/Exception.cpp index 71a9058..bffdc47 100644 --- a/src/cppcache/src/Exception.cpp +++ b/src/cppcache/src/Exception.cpp @@ -19,13 +19,13 @@ extern "C" { #include <string.h> #include <stdlib.h> } +#include <ace/OS.h> #include <gfcpp/Exception.hpp> #include <gfcpp/CacheableString.hpp> #include <StackTrace.hpp> #include <ace/TSS_T.h> -#include <cstring> #include <string> namespace apache { @@ -54,10 +54,10 @@ Exception::Exception(const char* msg1, const char* msg2, bool forceTrace, char* msg; GF_NEW(msg, char[len + 1]); if (msg1) { - std::memcpy(msg, msg1, len1); + ACE_OS::memcpy(msg, msg1, len1); } if (msg2) { - std::memcpy(msg + len1, msg2, len2); + ACE_OS::memcpy(msg + len1, msg2, len2); } msg[len] = '\0'; @@ -107,7 +107,7 @@ size_t Exception::getStackTrace(char* buffer, size_t maxLength) const { traceString += "Cause by exception: "; m_cause->m_stack->getString(traceString); } - len = std::snprintf(buffer, maxLength, "%s", traceString.c_str()); + len = ACE_OS::snprintf(buffer, maxLength, "%s", traceString.c_str()); } return len; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ExceptionTypes.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ExceptionTypes.cpp b/src/cppcache/src/ExceptionTypes.cpp index 1d76e58..ea03c72 100644 --- a/src/cppcache/src/ExceptionTypes.cpp +++ b/src/cppcache/src/ExceptionTypes.cpp @@ -329,7 +329,7 @@ void GfErrTypeThrowException(const char* str, GfErrType err) { char buf[64]; LOGINFO("error code: %d", err); if (exMsg == NULL) { - std::snprintf(buf, 64, "Unknown error code[0x%X]", err); + ACE_OS::snprintf(buf, 64, "Unknown error code[0x%X]", err); exMsg = buf; } UnknownException ex(str, exMsg); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/Log.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/Log.cpp b/src/cppcache/src/Log.cpp index 205c742..972452a 100644 --- a/src/cppcache/src/Log.cpp +++ b/src/cppcache/src/Log.cpp @@ -18,9 +18,6 @@ #include <gfcpp/gfcpp_globals.hpp> #include <cctype> -#include <cstdlib> -#include <ctime> -#include <cstring> #include <string> #include <utility> #include <vector> @@ -113,7 +110,7 @@ static int selector(const dirent* d) { size_t fileHyphenPos = tempname.find_last_of('-'); if (fileHyphenPos != std::string::npos) { std::string buff1 = tempname.substr(0, fileHyphenPos); - if (std::strstr(filebasename.c_str(), buff1.c_str()) == 0) { + if (ACE_OS::strstr(filebasename.c_str(), buff1.c_str()) == 0) { return 0; } if (fileHyphenPos != actualHyphenPos) return 0; @@ -141,7 +138,7 @@ static int comparator(const dirent** d1, const dirent** d2) { return 1; } - int diff = std::strcmp((*d1)->d_name, (*d2)->d_name); + int diff = ACE_OS::strcmp((*d1)->d_name, (*d2)->d_name); if (diff < 0) { return -1; } else if (diff > 0) { @@ -189,7 +186,7 @@ const char* Log::logFileName() { throw IllegalStateException( ("Log file name is too long: " + *g_logFile).c_str()); } - std::strncpy(g_logFileNameBuffer, g_logFile->c_str(), + ACE_OS::strncpy(g_logFileNameBuffer, g_logFile->c_str(), sizeof(g_logFileNameBuffer)); } @@ -233,7 +230,7 @@ void Log::init(LogLevel level, const char* logFileName, int32 logFileLimit, // replace all '\' with '/' to make everything easier.. size_t length = g_logFile->length() + 1; char* slashtmp = new char[length]; - std::strncpy(slashtmp, g_logFile->c_str(), length); + ACE_OS::strncpy(slashtmp, g_logFile->c_str(), length); for (size_t i = 0; i < g_logFile->length(); i++) { if (slashtmp[i] == '/') { slashtmp[i] = '\\'; @@ -322,7 +319,7 @@ void Log::init(LogLevel level, const char* logFileName, int32 logFileLimit, if (fileHyphenPos != std::string::npos) { std::string buff = tempname.substr(fileHyphenPos + 1, tempname.length()); - g_rollIndex = std::atoi(buff.c_str()) + 1; + g_rollIndex = ACE_OS::atoi(buff.c_str()) + 1; } } // if loop } // for loop @@ -357,6 +354,7 @@ void Log::init(LogLevel level, const char* logFileName, int32 logFileLimit, * callers must be careful not to overflow the actual space of the * destination. * Use snprintf() instead, or correct precision specifiers. + * Fix : using ACE_OS::snprintf */ char rollFile[1024] = {0}; std::string logsdirname; @@ -384,18 +382,18 @@ void Log::init(LogLevel level, const char* logFileName, int32 logFileLimit, fnameBeforeExt = logsbasename.substr(0, posOfExt); extName = logsbasename.substr(posOfExt + 1, baselen); } - std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), - g_rollIndex++, extName.c_str()); + ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), + g_rollIndex++, extName.c_str()); bool rollFileNameGot = false; while (!rollFileNameGot) { FILE* checkFile = fopen(rollFile, "r"); if (checkFile != NULL) { fclose(checkFile); checkFile = NULL; - std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), - g_rollIndex++, extName.c_str()); + ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), + g_rollIndex++, extName.c_str()); } else { rollFileNameGot = true; } @@ -564,7 +562,7 @@ const char* Log::levelToChars(Log::LogLevel level) { default: { char buf[64] = {0}; - std::snprintf(buf, 64, "Unexpected log level: %d", level); + ACE_OS::snprintf(buf, 64, "Unexpected log level: %d", level); throw IllegalArgumentException(buf); } } @@ -616,14 +614,14 @@ char* Log::formatLogLine(char* buf, Log::LogLevel level) { time_t secs = clock.sec(); struct tm* tm_val = ACE_OS::localtime(&secs); char* pbuf = buf; - pbuf += std::snprintf(pbuf, 15, "[%s ", Log::levelToChars(level)); - pbuf += std::strftime(pbuf, MINBUFSIZE, "%Y/%m/%d %H:%M:%S", tm_val); + 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 += - std::snprintf(pbuf, 15, ".%06ld ", static_cast<long>(clock.usec())); - pbuf += std::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val); + ACE_OS::snprintf(pbuf, 15, ".%06ld ", static_cast<long>(clock.usec())); + pbuf += ACE_OS::strftime(pbuf, MINBUFSIZE, "%Z ", tm_val); - std::snprintf(pbuf, 300, "%s:%d %lu] ", g_uname.nodename, g_pid, - (unsigned long)ACE_OS::thr_self()); + ACE_OS::snprintf(pbuf, 300, "%s:%d %lu] ", g_uname.nodename, g_pid, + (unsigned long)ACE_OS::thr_self()); return buf; } @@ -662,7 +660,7 @@ void Log::put(LogLevel level, const char* msg) { formatLogLine(buf, level); size_t numChars = - static_cast<int>(std::strlen(buf) + std::strlen(msg)); + static_cast<int>(ACE_OS::strlen(buf) + ACE_OS::strlen(msg)); g_bytesWritten += numChars + 2; // bcoz we have to count trailing new line (\n) @@ -693,17 +691,17 @@ void Log::put(LogLevel level, const char* msg) { fnameBeforeExt = logsbasename.substr(0, posOfExt); extName = logsbasename.substr(posOfExt + 1, baselen); } - std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), - g_rollIndex++, extName.c_str()); + ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), + g_rollIndex++, extName.c_str()); bool rollFileNameGot = false; while (!rollFileNameGot) { FILE* fp1 = fopen(rollFile, "r"); if (fp1 != NULL) { fclose(fp1); - std::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), - g_rollIndex++, extName.c_str()); + ACE_OS::snprintf(rollFile, 1024, "%s%c%s-%d.%s", logsdirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), + g_rollIndex++, extName.c_str()); } else { rollFileNameGot = true; } @@ -738,7 +736,7 @@ void Log::put(LogLevel level, const char* msg) { g_spaceUsed = 0; ACE_stat statBuf = {0}; /*for(int i = 1; i < entries_count; i++) { - std::snprintf(fullpath , 512 , + ACE_OS::snprintf(fullpath , 512 , "%s%c%s",dirname.c_str(),ACE_DIRECTORY_SEPARATOR_CHAR,resultArray[i]->d_name); ACE_OS::stat(fullpath,&statBuf); g_fileInfoPair = std::make_pair(fullpath,statBuf.st_size); @@ -758,8 +756,8 @@ void Log::put(LogLevel level, const char* msg) { int status = sds.open(dirname.c_str(), selector, comparator); if (status != -1) { for (int index = 1; index < sds.length(); ++index) { - std::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, sds[index]->d_name); + ACE_OS::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, sds[index]->d_name); ACE_OS::stat(fullpath, &statBuf); g_fileInfoPair = std::make_pair(fullpath, statBuf.st_size); fileInfo.push_back(g_fileInfoPair); @@ -776,8 +774,8 @@ void Log::put(LogLevel level, const char* msg) { g_spaceUsed -= fileSize; } else { char printmsg[256]; - std::snprintf(printmsg, 256, "%s\t%s\n", "Could not delete", - fileInfo[fileIndex].first.c_str()); + ACE_OS::snprintf(printmsg, 256, "%s\t%s\n", "Could not delete", + fileInfo[fileIndex].first.c_str()); int numChars = fprintf(g_log, "%s%s\n", formatLogLine(buf, level), printmsg); g_bytesWritten += @@ -810,13 +808,13 @@ void Log::put(LogLevel level, const char* msg) { void Log::putThrow(LogLevel level, const char* msg, const Exception& ex) { char buf[128] = {0}; - std::snprintf(buf, 128, "Geode exception %s thrown: ", ex.getName()); + ACE_OS::snprintf(buf, 128, "Geode exception %s thrown: ", ex.getName()); put(level, (std::string(buf) + ex.getMessage() + "\n" + msg).c_str()); } void Log::putCatch(LogLevel level, const char* msg, const Exception& ex) { char buf[128] = {0}; - std::snprintf(buf, 128, "Geode exception %s caught: ", ex.getName()); + ACE_OS::snprintf(buf, 128, "Geode exception %s caught: ", ex.getName()); put(level, (std::string(buf) + ex.getMessage() + "\n" + msg).c_str()); } @@ -827,7 +825,7 @@ void Log::enterFn(LogLevel level, const char* functionName) { fn = fn.substr(fn.size() - MAX_NAME_LENGTH, MAX_NAME_LENGTH); } char buf[MAX_NAME_LENGTH + 512] = {0}; - std::snprintf(buf, 1536, "{{{===>>> Entering function %s", fn.c_str()); + ACE_OS::snprintf(buf, 1536, "{{{===>>> Entering function %s", fn.c_str()); put(level, buf); } @@ -838,7 +836,7 @@ void Log::exitFn(LogLevel level, const char* functionName) { fn = fn.substr(fn.size() - MAX_NAME_LENGTH, MAX_NAME_LENGTH); } char buf[MAX_NAME_LENGTH + 512] = {0}; - std::snprintf(buf, 1536, "<<<===}}} Exiting function %s", fn.c_str()); + ACE_OS::snprintf(buf, 1536, "<<<===}}} Exiting function %s", fn.c_str()); put(level, buf); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PdxFieldType.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxFieldType.cpp b/src/cppcache/src/PdxFieldType.cpp index fb1f815..04b5ae1 100644 --- a/src/cppcache/src/PdxFieldType.cpp +++ b/src/cppcache/src/PdxFieldType.cpp @@ -27,6 +27,8 @@ #include <gfcpp/PdxFieldTypes.hpp> //#include <malloc.h> +#include "ace/OS.h" + namespace apache { namespace geode { namespace client { @@ -153,8 +155,9 @@ CacheableStringPtr PdxFieldType::toString() const { * callers must be careful not to overflow the actual space of the * destination. * Use snprintf() instead, or correct precision specifiers. + * Fix : using ACE_OS::snprintf */ - std::snprintf( + ACE_OS::snprintf( stringBuf, 1024, " PdxFieldName=%s TypeId=%d VarLenFieldIdx=%d sequenceid=%d\n", this->m_fieldName.c_str(), this->m_typeId, this->m_varLenFieldIdx, http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PdxInstanceFactoryImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxInstanceFactoryImpl.cpp b/src/cppcache/src/PdxInstanceFactoryImpl.cpp index fa0a11f..6342ec0 100644 --- a/src/cppcache/src/PdxInstanceFactoryImpl.cpp +++ b/src/cppcache/src/PdxInstanceFactoryImpl.cpp @@ -18,6 +18,7 @@ #include "PdxType.hpp" #include "PdxTypes.hpp" #include "PdxInstanceImpl.hpp" +#include <ace/OS_NS_stdio.h> namespace apache { namespace geode { @@ -393,11 +394,12 @@ void PdxInstanceFactoryImpl::isFieldAdded(const char* fieldName) { * callers must be careful not to overflow the actual space of the * destination. * Use snprintf() instead, or correct precision specifiers. + * Fix : using ACE_OS::snprintf */ - std::snprintf(excpStr, 256, - "Field: %s is either already added into " - "PdxInstanceFactory or it is null ", - fieldName); + ACE_OS::snprintf(excpStr, 256, + "Field: %s is either already added into " + "PdxInstanceFactory or it is null ", + fieldName); throw IllegalStateException(excpStr); } }