Repository: geode-native Updated Branches: refs/heads/develop 3daae6ed5 -> d7f6ac3d4
http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/OsStatisticsImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/OsStatisticsImpl.cpp b/src/cppcache/src/statistics/OsStatisticsImpl.cpp index 567052b..668ddf3 100644 --- a/src/cppcache/src/statistics/OsStatisticsImpl.cpp +++ b/src/cppcache/src/statistics/OsStatisticsImpl.cpp @@ -19,7 +19,7 @@ #include "StatisticsTypeImpl.hpp" #include "StatisticDescriptorImpl.hpp" -#include <cstring> +#include "ace/OS.h" using namespace apache::geode::statistics; @@ -44,7 +44,7 @@ int64 OsStatisticsImpl::calcNumericId(StatisticsFactory* system, const char* OsStatisticsImpl::calcTextId(StatisticsFactory* system, const char* userValue) { - if (userValue != NULL && std::strcmp(userValue, "") != 0) { + if (userValue != NULL && strcmp(userValue, "") != 0) { return userValue; } else { if (system != NULL) { @@ -159,7 +159,7 @@ void OsStatisticsImpl::close() { void OsStatisticsImpl::_setInt(int32 offset, int32 value) { if (offset >= statsType->getIntStatCount()) { char s[128] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( s, 128, "setInt:The id (%d) of the Statistic Descriptor is not valid ", offset); throw IllegalArgumentException(s); @@ -177,10 +177,12 @@ void OsStatisticsImpl::_setLong(int32 offset, int64 value) { * arbitrarily long string, * 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 */ // sprintf(s, "setLong:The id (%d) of the Statistic Descriptor is not valid // ", offset); - std::snprintf( + ACE_OS::snprintf( s, 128, "setLong:The id (%d) of the Statistic Descriptor is not valid ", offset); throw IllegalArgumentException(s); @@ -191,7 +193,7 @@ void OsStatisticsImpl::_setLong(int32 offset, int64 value) { void OsStatisticsImpl::_setDouble(int32 offset, double value) { if (offset >= statsType->getDoubleStatCount()) { char s[128] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( s, 128, "setDouble:The id (%d) of the Statistic Descriptor is not valid ", offset); @@ -205,7 +207,7 @@ void OsStatisticsImpl::_setDouble(int32 offset, double value) { int32 OsStatisticsImpl::_getInt(int32 offset) { if (offset >= statsType->getIntStatCount()) { char s[128] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( s, 128, "getInt:The id (%d) of the Statistic Descriptor is not valid ", offset); throw IllegalArgumentException(s); @@ -217,7 +219,7 @@ int32 OsStatisticsImpl::_getInt(int32 offset) { int64 OsStatisticsImpl::_getLong(int32 offset) { if (offset >= statsType->getLongStatCount()) { char s[128] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( s, 128, "getLong:The id (%d) of the Statistic Descriptor is not valid ", offset); throw IllegalArgumentException(s); @@ -229,7 +231,7 @@ int64 OsStatisticsImpl::_getLong(int32 offset) { double OsStatisticsImpl::_getDouble(int32 offset) { if (offset >= statsType->getDoubleStatCount()) { char s[128] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( s, 128, "getDouble:The id (%d) of the Statistic Descriptor is not valid ", offset); @@ -267,7 +269,7 @@ int64 OsStatisticsImpl::_getRawBits(StatisticDescriptor* statDscp) { int32 OsStatisticsImpl::_incInt(int32 offset, int32 delta) { if (offset >= statsType->getIntStatCount()) { char s[128] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( s, 128, "incInt:The id (%d) of the Statistic Descriptor is not valid ", offset); throw IllegalArgumentException(s); @@ -287,11 +289,13 @@ int64 OsStatisticsImpl::_incLong(int32 offset, int64 delta) { * arbitrarily long string, * 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 */ // sprintf(s, "incLong:The id (%d) of the Statistic Descriptor is not valid // ", offset); - std::snprintf( + ACE_OS::snprintf( s, 128, "incLong:The id (%d) of the Statistic Descriptor is not valid ", offset); throw IllegalArgumentException(s); @@ -303,7 +307,7 @@ int64 OsStatisticsImpl::_incLong(int32 offset, int64 delta) { double OsStatisticsImpl::_incDouble(int32 offset, double delta) { if (offset >= statsType->getDoubleStatCount()) { char s[128] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( s, 128, "incDouble:The id (%d) of the Statistic Descriptor is not valid ", offset); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/StatisticDescriptorImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/StatisticDescriptorImpl.cpp b/src/cppcache/src/statistics/StatisticDescriptorImpl.cpp index e08736e..bf01763 100644 --- a/src/cppcache/src/statistics/StatisticDescriptorImpl.cpp +++ b/src/cppcache/src/statistics/StatisticDescriptorImpl.cpp @@ -17,7 +17,7 @@ #include "StatisticDescriptorImpl.hpp" -#include <cstring> +#include <ace/OS.h> using namespace apache::geode::statistics; @@ -45,12 +45,12 @@ StatisticDescriptorImpl::StatisticDescriptorImpl(const char* statName, int8 statIsStatLargerBetter) { name = statName; descriptorType = statDescriptorType; - if (std::strcmp(statDescription, "") == 0) { + if (strcmp(statDescription, "") == 0) { description = ""; } else { description = statDescription; } - if (std::strcmp(statUnit, "") == 0) { + if (strcmp(statUnit, "") == 0) { unit = ""; } else { unit = statUnit; @@ -167,7 +167,7 @@ const char* StatisticDescriptorImpl::getTypeCodeName(FieldType code) throw( return DoubleTypeName; default: { char buf[20]; - std::snprintf(buf, 20, "%d", code); + ACE_OS::snprintf(buf, 20, "%d", code); std::string temp(buf); std::string s = "Unknown type code:" + temp; throw IllegalArgumentException(s.c_str()); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/StatisticsTypeImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/StatisticsTypeImpl.cpp b/src/cppcache/src/statistics/StatisticsTypeImpl.cpp index 50df5ca..e1bea61 100644 --- a/src/cppcache/src/statistics/StatisticsTypeImpl.cpp +++ b/src/cppcache/src/statistics/StatisticsTypeImpl.cpp @@ -18,7 +18,7 @@ #include "StatisticsTypeImpl.hpp" #include "StatisticDescriptorImpl.hpp" #include <string> -#include <cstring> +#include <ace/OS.h> using namespace apache::geode::statistics; /** @@ -61,11 +61,11 @@ StatisticsTypeImpl::StatisticsTypeImpl(const char* nameArg, } if (statsLengthArg > MAX_DESCRIPTORS_PER_TYPE) { char buffer[100]; - std::snprintf(buffer, 100, "%d", statsLengthArg); + ACE_OS::snprintf(buffer, 100, "%d", statsLengthArg); std::string temp(buffer); std::string s = "The requested descriptor count " + temp + " exceeds the maximum which is "; - std::snprintf(buffer, 100, "%d", MAX_DESCRIPTORS_PER_TYPE); + ACE_OS::snprintf(buffer, 100, "%d", MAX_DESCRIPTORS_PER_TYPE); std::string buf(buffer); s += buf + "."; throw IllegalArgumentException(s.c_str());