http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PdxInstanceImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxInstanceImpl.cpp b/src/cppcache/src/PdxInstanceImpl.cpp index 7111baa..bf8d1ef 100644 --- a/src/cppcache/src/PdxInstanceImpl.cpp +++ b/src/cppcache/src/PdxInstanceImpl.cpp @@ -26,7 +26,6 @@ #include "CacheImpl.hpp" #include "Utils.hpp" #include <algorithm> -#include <cstring> /* adongre - Coverity II * CID 29255: Calling risky function (SECURE_CODING)[VERY RISKY]. Using "sprintf" @@ -35,12 +34,13 @@ * 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 */ #define VERIFY_PDX_INSTANCE_FIELD_THROW \ if (pft == NULLPTR) { \ char excpStr[256] = {0}; \ - std::snprintf(excpStr, 256, "PdxInstance doesn't has field %s ", \ + ACE_OS::snprintf(excpStr, 256, "PdxInstance doesn't has field %s ", \ fieldname); \ throw IllegalStateException(excpStr); \ } @@ -68,7 +68,7 @@ PdxFieldTypePtr PdxInstanceImpl::m_DefaultPdxFieldType( -1 /*field index*/, false, 1, -1 /*var len field idx*/)); bool sortFunc(PdxFieldTypePtr field1, PdxFieldTypePtr field2) { - int diff = std::strcmp(field1->getFieldName(), field2->getFieldName()); + int diff = ACE_OS::strcmp(field1->getFieldName(), field2->getFieldName()); if (diff < 0) { return true; } else { @@ -570,8 +570,9 @@ bool PdxInstanceImpl::deepArrayEquals(CacheablePtr obj, CacheablePtr otherObj) { * 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, + ACE_OS::snprintf(excpStr, 256, "PdxInstance cannot calculate equals of the field %s " "since equals is only supported for CacheableKey " "derived types ", @@ -726,8 +727,9 @@ int PdxInstanceImpl::deepArrayHashCode(CacheablePtr obj) { * 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, + ACE_OS::snprintf(excpStr, 256, "PdxInstance cannot calculate hashcode of the field %s " "since hashcode is only supported for CacheableKey " "derived types ", @@ -804,8 +806,9 @@ uint32_t PdxInstanceImpl::hashcode() 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(excpStr, 256, "PdxInstance not found typeid %d ", + ACE_OS::snprintf(excpStr, 256, "PdxInstance not found typeid %d ", pField->getTypeId()); throw IllegalStateException(excpStr); } @@ -1208,14 +1211,15 @@ CacheableStringPtr PdxInstanceImpl::toString() const { * 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 */ PdxTypePtr pt = getPdxType(); std::string toString = "PDX["; char buf[2048]; - std::snprintf(buf, 2048, "%d", pt->getTypeId()); + ACE_OS::snprintf(buf, 2048, "%d", pt->getTypeId()); toString += buf; toString += ","; - std::snprintf(buf, 2048, "%s", pt->getPdxClassName()); + ACE_OS::snprintf(buf, 2048, "%s", pt->getPdxClassName()); toString += buf; toString += "]{"; bool firstElement = true; @@ -1226,7 +1230,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { } else { toString += ","; } - std::snprintf(buf, 2048, "%s", identityFields.at(i)->getFieldName()); + ACE_OS::snprintf(buf, 2048, "%s", identityFields.at(i)->getFieldName()); toString += buf; toString += "="; @@ -1234,63 +1238,63 @@ CacheableStringPtr PdxInstanceImpl::toString() const { case PdxFieldTypes::BOOLEAN: { bool value = false; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%s", value ? "true" : "false"); + ACE_OS::snprintf(buf, 2048, "%s", value ? "true" : "false"); toString += buf; break; } case PdxFieldTypes::BYTE: { signed char value = 0; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%d", value); + ACE_OS::snprintf(buf, 2048, "%d", value); toString += buf; break; } case PdxFieldTypes::SHORT: { int16_t value = 0; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%d", value); + ACE_OS::snprintf(buf, 2048, "%d", value); toString += buf; break; } case PdxFieldTypes::INT: { int32_t value = 0; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%d", value); + ACE_OS::snprintf(buf, 2048, "%d", value); toString += buf; break; } case PdxFieldTypes::LONG: { int64_t value = 0; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%lld", value); + ACE_OS::snprintf(buf, 2048, "%lld", value); toString += buf; break; } case PdxFieldTypes::FLOAT: { float value = 0; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%f", value); + ACE_OS::snprintf(buf, 2048, "%f", value); toString += buf; break; } case PdxFieldTypes::DOUBLE: { double value = 0; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%f", value); + ACE_OS::snprintf(buf, 2048, "%f", value); toString += buf; break; } case PdxFieldTypes::CHAR: { wchar_t value = 0; getField(identityFields.at(i)->getFieldName(), value); - std::snprintf(buf, 2048, "%c", value); + ACE_OS::snprintf(buf, 2048, "%c", value); toString += buf; break; } case PdxFieldTypes::STRING: { wchar_t* value = 0; getField(identityFields.at(i)->getFieldName(), &value); - std::snprintf(buf, 2048, "%ls", value); + ACE_OS::snprintf(buf, 2048, "%ls", value); toString += buf; break; } @@ -1300,7 +1304,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%c\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%c\t", value[i]); toString += buf; } GF_SAFE_DELETE_ARRAY(value); @@ -1313,7 +1317,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%ls\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%ls\t", value[i]); toString += buf; } } @@ -1325,7 +1329,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%d\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%d\t", value[i]); toString += buf; } GF_SAFE_DELETE_ARRAY(value); @@ -1338,7 +1342,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%d\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%d\t", value[i]); toString += buf; } GF_SAFE_DELETE_ARRAY(value); @@ -1351,7 +1355,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%d\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%d\t", value[i]); toString += buf; } GF_SAFE_DELETE_ARRAY(value); @@ -1364,7 +1368,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%lld\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%lld\t", value[i]); toString += buf; } } @@ -1376,7 +1380,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%f\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%f\t", value[i]); toString += buf; } GF_SAFE_DELETE_ARRAY(value); @@ -1389,7 +1393,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%f\t", value[i]); + ACE_OS::snprintf(buf, 2048, "%f\t", value[i]); toString += buf; } } @@ -1399,7 +1403,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { CacheableDatePtr value = NULLPTR; getField(identityFields.at(i)->getFieldName(), value); if (value != NULLPTR) { - std::snprintf(buf, 2048, "%s", value->toString()->asChar()); + ACE_OS::snprintf(buf, 2048, "%s", value->toString()->asChar()); toString += buf; } break; @@ -1410,7 +1414,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { getField(identityFields.at(i)->getFieldName(), &value, length); if (length > 0) { for (int i = 0; i < length; i++) { - std::snprintf(buf, 2048, "%s\t", value[i] ? "true" : "false"); + ACE_OS::snprintf(buf, 2048, "%s\t", value[i] ? "true" : "false"); toString += buf; } GF_SAFE_DELETE_ARRAY(value); @@ -1426,7 +1430,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { if (arrayLength > 0) { for (int j = 0; j < arrayLength; j++) { for (int k = 0; k < elementLength[j]; k++) { - std::snprintf(buf, 2048, "%d\t", value[j][k]); + ACE_OS::snprintf(buf, 2048, "%d\t", value[j][k]); toString += buf; } } @@ -1437,7 +1441,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { CacheableObjectArrayPtr value; getField(identityFields.at(i)->getFieldName(), value); if (value != NULLPTR) { - std::snprintf(buf, 2048, "%s\t", value->toString()->asChar()); + ACE_OS::snprintf(buf, 2048, "%s\t", value->toString()->asChar()); toString += buf; } break; @@ -1446,7 +1450,7 @@ CacheableStringPtr PdxInstanceImpl::toString() const { CacheablePtr value; getField(identityFields.at(i)->getFieldName(), value); if (value != NULLPTR) { - std::snprintf(buf, 2048, "%s\t", value->toString()->asChar()); + ACE_OS::snprintf(buf, 2048, "%s\t", value->toString()->asChar()); toString += buf; } } @@ -1530,7 +1534,7 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) const { char* myPdxClassName = myPdxType->getPdxClassName(); char* otherPdxClassName = otherPdxType->getPdxClassName(); - if (std::strcmp(otherPdxClassName, myPdxClassName) != 0) { + if (ACE_OS::strcmp(otherPdxClassName, myPdxClassName) != 0) { return false; } @@ -1641,8 +1645,9 @@ bool PdxInstanceImpl::operator==(const CacheableKey& other) 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(excpStr, 256, "PdxInstance not found typeid %d ", + ACE_OS::snprintf(excpStr, 256, "PdxInstance not found typeid %d ", myPFT->getTypeId()); throw IllegalStateException(excpStr); } @@ -1803,7 +1808,7 @@ const char* PdxInstanceImpl::getClassName() const { PdxTypePtr pdxtype = PdxTypeRegistry::getPdxType(m_typeId); if (pdxtype == NULLPTR) { char excpStr[256] = {0}; - std::snprintf(excpStr, 256, + ACE_OS::snprintf(excpStr, 256, "PdxType is not defined for PdxInstance: %d ", m_typeId); throw IllegalStateException(excpStr); } @@ -2034,8 +2039,9 @@ void PdxInstanceImpl::setField(const char* fieldName, bool value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2059,8 +2065,9 @@ void PdxInstanceImpl::setField(const char* fieldName, signed char value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2084,8 +2091,9 @@ void PdxInstanceImpl::setField(const char* fieldName, unsigned char value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2101,7 +2109,7 @@ void PdxInstanceImpl::setField(const char* fieldName, int16_t value) { if (pft != NULLPTR && pft->getTypeId() != PdxFieldTypes::SHORT) { char excpStr[256] = {0}; - std::snprintf( + ACE_OS::snprintf( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2125,8 +2133,9 @@ void PdxInstanceImpl::setField(const char* fieldName, int32_t value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2150,8 +2159,9 @@ void PdxInstanceImpl::setField(const char* fieldName, int64_t value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2175,8 +2185,9 @@ void PdxInstanceImpl::setField(const char* fieldName, float value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2200,8 +2211,9 @@ void PdxInstanceImpl::setField(const char* fieldName, double value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2225,8 +2237,9 @@ void PdxInstanceImpl::setField(const char* fieldName, wchar_t value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2250,8 +2263,9 @@ void PdxInstanceImpl::setField(const char* fieldName, char value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2268,7 +2282,7 @@ void PdxInstanceImpl::setField(const char* fieldName, CacheableDatePtr value) { if (pft != NULLPTR && pft->getTypeId() != PdxFieldTypes::DATE) { char excpStr[256] = {0}; - std::snprintf( + ACE_OS::snprintf( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2292,8 +2306,9 @@ void PdxInstanceImpl::setField(const char* fieldName, CacheablePtr value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2309,7 +2324,7 @@ void PdxInstanceImpl::setField(const char* fieldName, if (pft != NULLPTR && pft->getTypeId() != PdxFieldTypes::OBJECT_ARRAY) { char excpStr[256] = {0}; - std::snprintf( + ACE_OS::snprintf( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2333,8 +2348,9 @@ void PdxInstanceImpl::setField(const char* fieldName, bool* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2359,8 +2375,9 @@ void PdxInstanceImpl::setField(const char* fieldName, signed char* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2386,8 +2403,9 @@ void PdxInstanceImpl::setField(const char* fieldName, unsigned char* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2413,8 +2431,9 @@ void PdxInstanceImpl::setField(const char* fieldName, int16_t* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2439,8 +2458,9 @@ void PdxInstanceImpl::setField(const char* fieldName, int32_t* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2465,8 +2485,9 @@ void PdxInstanceImpl::setField(const char* fieldName, int64_t* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2491,8 +2512,9 @@ void PdxInstanceImpl::setField(const char* fieldName, float* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2517,8 +2539,9 @@ void PdxInstanceImpl::setField(const char* fieldName, double* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2543,8 +2566,9 @@ void PdxInstanceImpl::setField(const char* fieldName, wchar_t* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2569,8 +2593,9 @@ void PdxInstanceImpl::setField(const char* fieldName, char* value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2598,8 +2623,9 @@ void PdxInstanceImpl::setField(const char* fieldName, const wchar_t* value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2623,8 +2649,9 @@ void PdxInstanceImpl::setField(const char* fieldName, const char* value) { * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2650,8 +2677,9 @@ void PdxInstanceImpl::setField(const char* fieldName, int8_t** value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2681,8 +2709,9 @@ void PdxInstanceImpl::setField(const char* fieldName, wchar_t** value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : "")); @@ -2723,8 +2752,9 @@ void PdxInstanceImpl::setField(const char* fieldName, char** value, * 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( excpStr, 256, "PdxInstance doesn't has field %s or type of field not matched %s ", fieldName, (pft != NULLPTR ? pft->toString()->asChar() : ""));
http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PdxReaderWithTypeCollector.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxReaderWithTypeCollector.cpp b/src/cppcache/src/PdxReaderWithTypeCollector.cpp index aa4c410..52b0198 100644 --- a/src/cppcache/src/PdxReaderWithTypeCollector.cpp +++ b/src/cppcache/src/PdxReaderWithTypeCollector.cpp @@ -24,6 +24,7 @@ #include "PdxReaderWithTypeCollector.hpp" #include "PdxTypes.hpp" #include <gfcpp/PdxFieldTypes.hpp> +#include <ace/OS_NS_stdio.h> namespace apache { namespace geode { @@ -51,7 +52,7 @@ void PdxReaderWithTypeCollector::checkType(const char* fieldName, int8_t typeId, if (pft != NULLPTR) { if (typeId != pft->getTypeId()) { char excpStr[128] = {0}; - std::snprintf( + ACE_OS::snprintf( excpStr, 128, "Expected %s fieldType field but found field of type %s ", fieldType, pft->toString()->asChar()); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PdxType.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PdxType.cpp b/src/cppcache/src/PdxType.cpp index b813855..5b39d36 100644 --- a/src/cppcache/src/PdxType.cpp +++ b/src/cppcache/src/PdxType.cpp @@ -28,8 +28,7 @@ #include "Utils.hpp" #include "PdxTypeRegistry.hpp" #include "PdxHelper.hpp" - -#include <cstring> +#include <ace/OS.h> namespace apache { namespace geode { @@ -183,8 +182,9 @@ void PdxType::addFixedLengthTypeField(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( + ACE_OS::snprintf( excpStr, 256, "Field: %s is either already added into PdxWriter or it is null ", fieldName); @@ -204,7 +204,7 @@ void PdxType::addVariableLengthTypeField(const char* fieldName, m_fieldNameVsPdxType .end()) { // COVERITY ---> 30289 Same on both sides char excpStr[256] = {0}; - std::snprintf( + ACE_OS::snprintf( excpStr, 256, "Field: %s is either already added into PdxWriter or it is null ", fieldName); @@ -625,7 +625,7 @@ bool PdxType::Equals(PdxTypePtr otherObj) { } bool PdxType::operator<(const PdxType& other) const { - return std::strcmp(this->m_className, other.m_className) < 0; + return ACE_OS::strcmp(this->m_className, other.m_className) < 0; } } // namespace client } // namespace geode http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PoolAttributes.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PoolAttributes.cpp b/src/cppcache/src/PoolAttributes.cpp index 8bbe749..31be9dd 100644 --- a/src/cppcache/src/PoolAttributes.cpp +++ b/src/cppcache/src/PoolAttributes.cpp @@ -134,7 +134,7 @@ void PoolAttributes::addLocator(const char* host, int port) { "Cannot add both locators and servers to a pool"); } char buff[128] = {'\0'}; - std::snprintf(buff, 128, "%s:%d", host, port); + ACE_OS::snprintf(buff, 128, "%s:%d", host, port); m_initLocList.push_back(buff); } @@ -144,6 +144,6 @@ void PoolAttributes::addServer(const char* host, int port) { "Cannot add both locators and servers to a pool"); } char buff[128] = {'\0'}; - std::snprintf(buff, 128, "%s:%d", host, port); + ACE_OS::snprintf(buff, 128, "%s:%d", host, port); m_initServList.push_back(buff); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PoolFactory.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PoolFactory.cpp b/src/cppcache/src/PoolFactory.cpp index 43f54cd..74568f1 100644 --- a/src/cppcache/src/PoolFactory.cpp +++ b/src/cppcache/src/PoolFactory.cpp @@ -186,13 +186,13 @@ PoolPtr PoolFactory::create(const char* name) { void PoolFactory::addCheck(const char* host, int port) { if (port <= 0) { char buff[100]; - std::snprintf(buff, 100, "port must be greater than 0 but was %d", port); + ACE_OS::snprintf(buff, 100, "port must be greater than 0 but was %d", port); throw IllegalArgumentException(buff); } ACE_INET_Addr addr(port, host); if (!(addr.get_ip_address())) { char buff[100]; - std::snprintf(buff, 100, "Unknown host %s", host); + ACE_OS::snprintf(buff, 100, "Unknown host %s", host); throw IllegalArgumentException(buff); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/Properties.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/Properties.cpp b/src/cppcache/src/Properties.cpp index cfa1a9c..2513bec 100644 --- a/src/cppcache/src/Properties.cpp +++ b/src/cppcache/src/Properties.cpp @@ -131,7 +131,7 @@ void Properties::insert(const char* key, const int value) { throw NullPointerException("Properties::insert: Null key given."); } char temp[64]; - std::snprintf(temp, 64, "%d", value); + ACE_OS::snprintf(temp, 64, "%d", value); CacheableStringPtr keyptr = CacheableString::create(key); CacheableStringPtr valptr = CacheableString::create(temp); MAP->rebind(keyptr, valptr); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ProxyRegion.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ProxyRegion.cpp b/src/cppcache/src/ProxyRegion.cpp index 43c9e39..24a6cc9 100644 --- a/src/cppcache/src/ProxyRegion.cpp +++ b/src/cppcache/src/ProxyRegion.cpp @@ -21,7 +21,7 @@ void ProxyRegion::unSupportedOperation(const char* operationName) const { char msg[256] = {'\0'}; - std::snprintf( + ACE_OS::snprintf( msg, 256, "%s operation is not supported when Region instance is logical.", operationName); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ProxyRemoteQueryService.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ProxyRemoteQueryService.cpp b/src/cppcache/src/ProxyRemoteQueryService.cpp index c96d6b9..397f30c 100644 --- a/src/cppcache/src/ProxyRemoteQueryService.cpp +++ b/src/cppcache/src/ProxyRemoteQueryService.cpp @@ -43,10 +43,10 @@ QueryPtr ProxyRemoteQueryService::newQuery(const char* querystring) { void ProxyRemoteQueryService::unSupportedException(const char* operationName) { char msg[256] = {'\0'}; - std::snprintf(msg, 256, - "%s operation is not supported when pool is in multiuser " - "authentication mode.", - operationName); + ACE_OS::snprintf(msg, 256, + "%s operation is not supported when pool is in multiuser " + "authentication mode.", + operationName); throw UnsupportedOperationException(msg); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/PutAllPartialResult.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/PutAllPartialResult.hpp b/src/cppcache/src/PutAllPartialResult.hpp index a471cec..1234c08 100644 --- a/src/cppcache/src/PutAllPartialResult.hpp +++ b/src/cppcache/src/PutAllPartialResult.hpp @@ -81,8 +81,8 @@ class PutAllPartialResult : public Serializable { virtual CacheableStringPtr toString() const { char msgStr1[1024]; if (m_firstFailedKey != NULLPTR) { - std::snprintf(msgStr1, 1024, "[ Key =%s ]", - m_firstFailedKey->toString()->asChar()); + ACE_OS::snprintf(msgStr1, 1024, "[ Key =%s ]", + m_firstFailedKey->toString()->asChar()); } char msgStr2[1024]; @@ -90,12 +90,12 @@ class PutAllPartialResult : public Serializable { // TODO:: impl. CacheableObjectPartList.size(); int failedKeyNum = m_totalMapSize - m_succeededKeys->size(); if (failedKeyNum > 0) { - std::snprintf( + ACE_OS::snprintf( msgStr2, 1024, "The putAll operation failed to put %d out of %d entries ", failedKeyNum, m_totalMapSize); } else { - std::snprintf( + ACE_OS::snprintf( msgStr2, 1024, "The putAll operation successfully put %d out of %d entries ", m_succeededKeys->size(), m_totalMapSize); @@ -103,8 +103,8 @@ class PutAllPartialResult : public Serializable { } char stringBuf[7000]; - std::snprintf(stringBuf, 7000, "PutAllPartialResult: %s%s", msgStr1, - msgStr2); + ACE_OS::snprintf(stringBuf, 7000, "PutAllPartialResult: %s%s", msgStr1, + msgStr2); return CacheableString::create(stringBuf); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/RegionAttributes.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionAttributes.cpp b/src/cppcache/src/RegionAttributes.cpp index 12d9f1f..a636c7e 100644 --- a/src/cppcache/src/RegionAttributes.cpp +++ b/src/cppcache/src/RegionAttributes.cpp @@ -18,12 +18,12 @@ #include <gfcpp/Cache.hpp> #include <Utils.hpp> #include <gfcpp/DataOutput.hpp> -#include <cstring> #include <string.h> #include <stdlib.h> #include <gfcpp/GeodeTypeIds.hpp> #include <CacheXmlParser.hpp> #include <ace/DLL.h> +#include <ace/OS.h> #include <gfcpp/DataInput.hpp> #include <gfcpp/Properties.hpp> @@ -100,28 +100,28 @@ RegionAttributes::RegionAttributes(const RegionAttributes& rhs) if (rhs.m_cacheLoaderLibrary != NULL) { size_t len = strlen(rhs.m_cacheLoaderLibrary) + 1; m_cacheLoaderLibrary = new char[len]; - std::strncpy(m_cacheLoaderLibrary, rhs.m_cacheLoaderLibrary, len); + ACE_OS::strncpy(m_cacheLoaderLibrary, rhs.m_cacheLoaderLibrary, len); } else { m_cacheLoaderLibrary = NULL; } if (rhs.m_cacheWriterLibrary != NULL) { size_t len = strlen(rhs.m_cacheWriterLibrary) + 1; m_cacheWriterLibrary = new char[len]; - std::strncpy(m_cacheWriterLibrary, rhs.m_cacheWriterLibrary, len); + ACE_OS::strncpy(m_cacheWriterLibrary, rhs.m_cacheWriterLibrary, len); } else { m_cacheWriterLibrary = NULL; } if (rhs.m_cacheListenerLibrary != NULL) { size_t len = strlen(rhs.m_cacheListenerLibrary) + 1; m_cacheListenerLibrary = new char[len]; - std::strncpy(m_cacheListenerLibrary, rhs.m_cacheListenerLibrary, len); + ACE_OS::strncpy(m_cacheListenerLibrary, rhs.m_cacheListenerLibrary, len); } else { m_cacheListenerLibrary = NULL; } if (rhs.m_partitionResolverLibrary != NULL) { size_t len = strlen(rhs.m_partitionResolverLibrary) + 1; m_partitionResolverLibrary = new char[len]; - std::strncpy(m_partitionResolverLibrary, rhs.m_partitionResolverLibrary, + ACE_OS::strncpy(m_partitionResolverLibrary, rhs.m_partitionResolverLibrary, len); } else { m_partitionResolverLibrary = NULL; @@ -129,28 +129,28 @@ RegionAttributes::RegionAttributes(const RegionAttributes& rhs) if (rhs.m_cacheLoaderFactory != NULL) { size_t len = strlen(rhs.m_cacheLoaderFactory) + 1; m_cacheLoaderFactory = new char[len]; - std::strncpy(m_cacheLoaderFactory, rhs.m_cacheLoaderFactory, len); + ACE_OS::strncpy(m_cacheLoaderFactory, rhs.m_cacheLoaderFactory, len); } else { m_cacheLoaderFactory = NULL; } if (rhs.m_cacheWriterFactory != NULL) { size_t len = strlen(rhs.m_cacheWriterFactory) + 1; m_cacheWriterFactory = new char[len]; - std::strncpy(m_cacheWriterFactory, rhs.m_cacheWriterFactory, len); + ACE_OS::strncpy(m_cacheWriterFactory, rhs.m_cacheWriterFactory, len); } else { m_cacheWriterFactory = NULL; } if (rhs.m_cacheListenerFactory != NULL) { size_t len = strlen(rhs.m_cacheListenerFactory) + 1; m_cacheListenerFactory = new char[len]; - std::strncpy(m_cacheListenerFactory, rhs.m_cacheListenerFactory, len); + ACE_OS::strncpy(m_cacheListenerFactory, rhs.m_cacheListenerFactory, len); } else { m_cacheListenerFactory = NULL; } if (rhs.m_partitionResolverFactory != NULL) { size_t len = strlen(rhs.m_partitionResolverFactory) + 1; m_partitionResolverFactory = new char[len]; - std::strncpy(m_partitionResolverFactory, rhs.m_partitionResolverFactory, + ACE_OS::strncpy(m_partitionResolverFactory, rhs.m_partitionResolverFactory, len); } else { m_partitionResolverFactory = NULL; @@ -158,28 +158,28 @@ RegionAttributes::RegionAttributes(const RegionAttributes& rhs) if (rhs.m_endpoints != NULL) { size_t len = strlen(rhs.m_endpoints) + 1; m_endpoints = new char[len]; - std::strncpy(m_endpoints, rhs.m_endpoints, len); + ACE_OS::strncpy(m_endpoints, rhs.m_endpoints, len); } else { m_endpoints = NULL; } if (rhs.m_poolName != NULL) { size_t len = strlen(rhs.m_poolName) + 1; m_poolName = new char[len]; - std::strncpy(m_poolName, rhs.m_poolName, len); + ACE_OS::strncpy(m_poolName, rhs.m_poolName, len); } else { m_poolName = NULL; } if (rhs.m_persistenceLibrary != NULL) { size_t len = strlen(rhs.m_persistenceLibrary) + 1; m_persistenceLibrary = new char[len]; - std::strncpy(m_persistenceLibrary, rhs.m_persistenceLibrary, len); + ACE_OS::strncpy(m_persistenceLibrary, rhs.m_persistenceLibrary, len); } else { m_persistenceLibrary = NULL; } if (rhs.m_persistenceFactory != NULL) { size_t len = strlen(rhs.m_persistenceFactory) + 1; m_persistenceFactory = new char[len]; - std::strncpy(m_persistenceFactory, rhs.m_persistenceFactory, len); + ACE_OS::strncpy(m_persistenceFactory, rhs.m_persistenceFactory, len); } else { m_persistenceFactory = NULL; } @@ -222,13 +222,13 @@ void* getFactoryFunc(const char* lib, const char* funcName) { if (dll.open(lib, ACE_DEFAULT_SHLIB_MODE, 0) == -1) { // error... char msg[1000]; - std::snprintf(msg, 1000, "cannot open library: %s", lib); + ACE_OS::snprintf(msg, 1000, "cannot open library: %s", lib); throw IllegalArgumentException(msg); } void* func = dll.symbol(funcName); if (func == NULL) { char msg[1000]; - std::snprintf(msg, 1000, "cannot find factory function %s in library %s", + ACE_OS::snprintf(msg, 1000, "cannot find factory function %s in library %s", funcName, lib); throw IllegalArgumentException(msg); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/RegionFactory.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RegionFactory.cpp b/src/cppcache/src/RegionFactory.cpp index 3051226..4ab8d1f 100644 --- a/src/cppcache/src/RegionFactory.cpp +++ b/src/cppcache/src/RegionFactory.cpp @@ -163,7 +163,7 @@ RegionFactoryPtr RegionFactory::setRegionTimeToLive( RegionFactoryPtr RegionFactory::setInitialCapacity(int initialCapacity) { char excpStr[256] = {0}; if (initialCapacity < 0) { - std::snprintf(excpStr, 256, "initialCapacity must be >= 0 "); + ACE_OS::snprintf(excpStr, 256, "initialCapacity must be >= 0 "); throw IllegalArgumentException(excpStr); } m_attributeFactory->setInitialCapacity(initialCapacity); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/RemoteQuery.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/RemoteQuery.cpp b/src/cppcache/src/RemoteQuery.cpp index 08117ae..346b37a 100644 --- a/src/cppcache/src/RemoteQuery.cpp +++ b/src/cppcache/src/RemoteQuery.cpp @@ -59,10 +59,10 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func, CacheableVectorPtr paramList) { if ((timeout * 1000) >= 0x7fffffff) { char exMsg[1024]; - std::snprintf(exMsg, 1023, - "%s: timeout parameter " - "greater than maximum allowed (2^31/1000 i.e 2147483)", - func); + ACE_OS::snprintf(exMsg, 1023, + "%s: timeout parameter " + "greater than maximum allowed (2^31/1000 i.e 2147483)", + func); throw IllegalArgumentException(exMsg); } ThinClientPoolDM* pool = dynamic_cast<ThinClientPoolDM*>(tcdm); @@ -92,10 +92,10 @@ SelectResultsPtr RemoteQuery::execute(uint32_t timeout, const char* func, } else { if (values->size() % fieldNameVec.size() != 0) { char exMsg[1024]; - std::snprintf(exMsg, 1023, - "%s: Number of values coming from " - "server has to be exactly divisible by field count", - func); + ACE_OS::snprintf(exMsg, 1023, + "%s: Number of values coming from " + "server has to be exactly divisible by field count", + func); throw MessageException(exMsg); } else { LOGFINEST("%s: creating StructSet for query: %s", func, http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ServerLocation.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ServerLocation.cpp b/src/cppcache/src/ServerLocation.cpp index e39c568..e35c9c6 100644 --- a/src/cppcache/src/ServerLocation.cpp +++ b/src/cppcache/src/ServerLocation.cpp @@ -16,6 +16,7 @@ */ #include "ServerLocation.hpp" +#include <ace/OS_NS_stdio.h> namespace apache { namespace geode { @@ -23,7 +24,7 @@ namespace client { void ServerLocation::makeEpString() { if (m_serverName != NULLPTR) { char epstring[1024] = {0}; - std::snprintf(epstring, 1024, "%s:%d", m_serverName->asChar(), m_port); + ACE_OS::snprintf(epstring, 1024, "%s:%d", m_serverName->asChar(), m_port); m_epString = epstring; } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/SslSockStream.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/SslSockStream.cpp b/src/cppcache/src/SslSockStream.cpp index 2f08d53..991c32f 100644 --- a/src/cppcache/src/SslSockStream.cpp +++ b/src/cppcache/src/SslSockStream.cpp @@ -14,7 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <cstdio> #include "SslSockStream.hpp" #include <gfcpp/ExceptionTypes.hpp> #include <ace/OS_NS_stdio.h> @@ -29,8 +28,8 @@ void *SslSockStream::getACESSLFuncPtr(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); } @@ -44,7 +43,7 @@ void SslSockStream::initACESSLFuncPtrs() { LOGERROR("Failed to open cryptoImpl . Errno: %d : %s", lastError, ACE_OS::strerror(lastError)); char msg[1000] = {0}; - std::snprintf(msg, 1000, "cannot open library: %s", libName); + ACE_OS::snprintf(msg, 1000, "cannot open library: %s", libName); LOGERROR(msg); throw FileNotFoundException(msg); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/StackFrame.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/StackFrame.cpp b/src/cppcache/src/StackFrame.cpp index 29e4fda..5e33be9 100644 --- a/src/cppcache/src/StackFrame.cpp +++ b/src/cppcache/src/StackFrame.cpp @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include <cstdio> +#include <ace/OS.h> #include <gfcpp/gfcpp_globals.hpp> #include "StackFrame.hpp" #include <gfcpp/gf_base.hpp> @@ -33,8 +33,8 @@ char* StackFrame::asString() { } modlen--; } - std::snprintf(m_string, 1024, "%s at %s in %s", m_symbol, m_offset, - tmp_module + modlen); + ACE_OS::snprintf(m_string, 1024, "%s at %s in %s", m_symbol, m_offset, + tmp_module + modlen); } return m_string; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/SystemProperties.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/SystemProperties.cpp b/src/cppcache/src/SystemProperties.cpp index 8b60d8a..709f9dd 100644 --- a/src/cppcache/src/SystemProperties.cpp +++ b/src/cppcache/src/SystemProperties.cpp @@ -17,7 +17,6 @@ #include <gfcpp/gfcpp_globals.hpp> -#include <cstring> #include <string> #include <stdlib.h> #include <string.h> @@ -520,7 +519,7 @@ void SystemProperties::processProperty(const char* property, } size_t len = strlen(value) + 1; m_statisticsArchiveFile = new char[len]; - std::strncpy(m_statisticsArchiveFile, value, len); + ACE_OS::strncpy(m_statisticsArchiveFile, value, len); } else if (prop == LogFilename) { if (m_logFilename != NULL) { @@ -529,7 +528,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_logFilename = new char[len]; - std::strncpy(m_logFilename, value, len); + ACE_OS::strncpy(m_logFilename, value, len); } } else if (prop == LogLevel) { try { @@ -558,7 +557,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_name = new char[len]; - std::strncpy(m_name, value, len); + ACE_OS::strncpy(m_name, value, len); } } else if (prop == DurableClientId) { if (m_durableClientId != NULL) { @@ -568,7 +567,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_durableClientId = new char[len]; - std::strncpy(m_durableClientId, value, len); + ACE_OS::strncpy(m_durableClientId, value, len); } } else if (prop == SslKeyStore) { if (m_sslKeyStore != NULL) { @@ -578,7 +577,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_sslKeyStore = new char[len]; - std::strncpy(m_sslKeyStore, value, len); + ACE_OS::strncpy(m_sslKeyStore, value, len); } } else if (prop == SslTrustStore) { if (m_sslTrustStore != NULL) { @@ -588,7 +587,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_sslTrustStore = new char[len]; - std::strncpy(m_sslTrustStore, value, len); + ACE_OS::strncpy(m_sslTrustStore, value, len); } // adongre: Added for Ticket #758 } else if (prop == SslKeystorePassword) { @@ -599,7 +598,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_sslKeystorePassword = new char[len]; - std::strncpy(m_sslKeystorePassword, value, len); + ACE_OS::strncpy(m_sslKeystorePassword, value, len); } } else if (prop == ConflateEvents) { if (m_conflateEvents != NULL) { @@ -609,7 +608,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_conflateEvents = new char[len]; - std::strncpy(m_conflateEvents, value, len); + ACE_OS::strncpy(m_conflateEvents, value, len); } } else if (prop == LicenseFilename) { // ignore license-file @@ -622,7 +621,7 @@ void SystemProperties::processProperty(const char* property, if (value != NULL) { size_t len = strlen(value) + 1; m_cacheXMLFile = new char[len]; - std::strncpy(m_cacheXMLFile, value, len); + ACE_OS::strncpy(m_cacheXMLFile, value, len); } } else if (prop == LogFileSizeLimit) { @@ -739,8 +738,8 @@ void SystemProperties::processProperty(const char* property, } } else { char msg[1000]; - std::snprintf(msg, 1000, "SystemProperties: unknown property: %s = %s", - property, value); + ACE_OS::snprintf(msg, 1000, "SystemProperties: unknown property: %s = %s", + property, value); throwError(msg); } } @@ -755,18 +754,18 @@ void SystemProperties::logSettings() { settings += "\n appdomain-enabled = "; settings += isAppDomainEnabled() ? "true" : "false"; - std::snprintf(buf, 2048, "%" PRIu32, statsDiskSpaceLimit()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, statsDiskSpaceLimit()); settings += "\n archive-disk-space-limit = "; settings += buf; - std::snprintf(buf, 2048, "%" PRIu32, statsFileSizeLimit()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, statsFileSizeLimit()); settings += "\n archive-file-size-limit = "; settings += buf; settings += "\n auto-ready-for-events = "; settings += autoReadyForEvents() ? "true" : "false"; - std::snprintf(buf, 2048, "%" PRIu32, bucketWaitTimeout()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, bucketWaitTimeout()); settings += "\n bucket-wait-timeout = "; settings += buf; @@ -776,15 +775,15 @@ void SystemProperties::logSettings() { settings += "\n conflate-events = "; settings += conflateEvents(); - std::snprintf(buf, 2048, "%" PRIu32, connectTimeout()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, connectTimeout()); settings += "\n connect-timeout = "; settings += buf; - std::snprintf(buf, 2048, "%" PRIu32, javaConnectionPoolSize()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, javaConnectionPoolSize()); settings += "\n connection-pool-size = "; settings += buf; - std::snprintf(buf, 2048, "%" PRIu32, connectWaitTimeout()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, connectWaitTimeout()); settings += "\n connect-wait-timeout = "; settings += buf; @@ -800,7 +799,7 @@ void SystemProperties::logSettings() { settings += "\n durable-client-id = "; settings += durableClientId(); - std::snprintf(buf, 2048, "%" PRIu32, durableTimeout()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, durableTimeout()); settings += "\n durable-timeout = "; settings += buf; @@ -812,13 +811,13 @@ void SystemProperties::logSettings() { settings += "\n grid-client = "; settings += isGridClient() ? "true" : "false"; - std::snprintf(buf, 2048, "%" PRIu32, heapLRUDelta()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, heapLRUDelta()); settings += "\n heap-lru-delta = "; settings += buf; /* adongre - Coverity II * CID 29195: Printf arg type mismatch (PW.PRINTF_ARG_MISMATCH) */ - std::snprintf(buf, 2048, "%" PRIu32, static_cast<int>(heapLRULimit())); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, static_cast<int>(heapLRULimit())); settings += "\n heap-lru-limit = "; settings += buf; @@ -828,33 +827,33 @@ void SystemProperties::logSettings() { // settings += "\n license-type = "; // settings += licenseType(); - std::snprintf(buf, 2048, "%" PRIu32, logDiskSpaceLimit()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, logDiskSpaceLimit()); settings += "\n log-disk-space-limit = "; settings += buf; settings += "\n log-file = "; settings += logFilename(); - std::snprintf(buf, 2048, "%" PRIu32, logFileSizeLimit()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, logFileSizeLimit()); settings += "\n log-file-size-limit = "; settings += buf; settings += "\n log-level = "; settings += Log::levelToChars(logLevel()); - std::snprintf(buf, 2048, "%" PRIu32, threadPoolSize()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, threadPoolSize()); settings += "\n max-fe-threads = "; settings += buf; - std::snprintf(buf, 2048, "%" PRIu32, maxSocketBufferSize()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, maxSocketBufferSize()); settings += "\n max-socket-buffer-size = "; settings += buf; - std::snprintf(buf, 2048, "%" PRIi32, notifyAckInterval()); + ACE_OS::snprintf(buf, 2048, "%" PRIi32, notifyAckInterval()); settings += "\n notify-ack-interval = "; settings += buf; - std::snprintf(buf, 2048, "%" PRIi32, notifyDupCheckLife()); + ACE_OS::snprintf(buf, 2048, "%" PRIi32, notifyDupCheckLife()); settings += "\n notify-dupcheck-life = "; settings += buf; @@ -863,14 +862,14 @@ void SystemProperties::logSettings() { // *** PLEASE ADD IN ALPHABETICAL ORDER - USER VISIBLE *** - std::snprintf(buf, 2048, "%" PRIi32, pingInterval()); + ACE_OS::snprintf(buf, 2048, "%" PRIi32, pingInterval()); settings += "\n ping-interval = "; settings += buf; settings += "\n read-timeout-unit-in-millis = "; settings += readTimeoutUnitInMillis() ? "true" : "false"; - std::snprintf(buf, 2048, "%" PRIi32, redundancyMonitorInterval()); + ACE_OS::snprintf(buf, 2048, "%" PRIi32, redundancyMonitorInterval()); settings += "\n redundancy-monitor-interval = "; settings += buf; @@ -907,16 +906,16 @@ void SystemProperties::logSettings() { settings += "\n statistic-sampling-enabled = "; settings += statisticsEnabled() ? "true" : "false"; - std::snprintf(buf, 2048, "%" PRIu32, statisticsSampleInterval()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, statisticsSampleInterval()); settings += "\n statistic-sample-rate = "; settings += buf; - std::snprintf(buf, 2048, "%" PRIu32, suspendedTxTimeout()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, suspendedTxTimeout()); settings += "\n suspended-tx-timeout = "; settings += buf; // tombstone-timeout - std::snprintf(buf, 2048, "%" PRIu32, tombstoneTimeoutInMSec()); + ACE_OS::snprintf(buf, 2048, "%" PRIu32, tombstoneTimeoutInMSec()); settings += "\n tombstone-timeout = "; settings += buf; http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/TcpConn.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TcpConn.cpp b/src/cppcache/src/TcpConn.cpp index 087cd8f..d6b469a 100644 --- a/src/cppcache/src/TcpConn.cpp +++ b/src/cppcache/src/TcpConn.cpp @@ -20,7 +20,6 @@ #include <gfcpp/SystemProperties.hpp> #include <gfcpp/Log.hpp> -#include <cstdio> #include <memory.h> #include <ace/INET_Addr.h> @@ -122,8 +121,8 @@ void TcpConn::init() { LOGERROR("Failed to create socket. Errno: %d: %s", lastError, ACE_OS::strerror(lastError)); char msg[256]; - std::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s", - lastError, ACE_OS::strerror(lastError)); + ACE_OS::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s", + lastError, ACE_OS::strerror(lastError)); throw GeodeIOException(msg); } @@ -198,15 +197,17 @@ void TcpConn::listen(ACE_INET_Addr addr, uint32_t waitSeconds) { * 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 */ - std::snprintf( + ACE_OS::snprintf( msg, 256, "TcpConn::listen Attempt to listen timed out after %d seconds.", waitSeconds); throw TimeoutException(msg); } - std::snprintf(msg, 256, "TcpConn::listen failed with errno: %d: %s", - lastError, ACE_OS::strerror(lastError)); + ACE_OS::snprintf(msg, 256, "TcpConn::listen failed with errno: %d: %s", + lastError, ACE_OS::strerror(lastError)); throw GeodeIOException(msg); } } @@ -257,7 +258,7 @@ void TcpConn::connect() { char msg[256]; int32_t lastError = ACE_OS::last_error(); if (lastError == ETIME || lastError == ETIMEDOUT) { - std::snprintf( + ACE_OS::snprintf( msg, 256, "TcpConn::connect Attempt to connect timed out after %d seconds.", waitSeconds); @@ -265,8 +266,8 @@ void TcpConn::connect() { GF_SAFE_DELETE(m_io); throw TimeoutException(msg); } - std::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s", - lastError, ACE_OS::strerror(lastError)); + ACE_OS::snprintf(msg, 256, "TcpConn::connect failed with errno: %d: %s", + lastError, ACE_OS::strerror(lastError)); // this is only called by constructor, so we must delete m_io GF_SAFE_DELETE(m_io); throw GeodeIOException(msg); @@ -275,8 +276,8 @@ void TcpConn::connect() { if (-1 == rc) { char msg[250]; int32_t lastError = ACE_OS::last_error(); - std::snprintf(msg, 256, "TcpConn::NONBLOCK: %d: %s", lastError, - ACE_OS::strerror(lastError)); + ACE_OS::snprintf(msg, 256, "TcpConn::NONBLOCK: %d: %s", lastError, + ACE_OS::strerror(lastError)); LOGINFO(msg); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/TcpSslConn.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TcpSslConn.cpp b/src/cppcache/src/TcpSslConn.cpp index 0a46424..bbd055d 100644 --- a/src/cppcache/src/TcpSslConn.cpp +++ b/src/cppcache/src/TcpSslConn.cpp @@ -16,8 +16,6 @@ */ #include "TcpSslConn.hpp" -#include <cstdio> - #include <gfcpp/SystemProperties.hpp> #include <gfcpp/DistributedSystem.hpp> #include "../../cryptoimpl/GFSsl.hpp" @@ -29,7 +27,7 @@ GFSsl* TcpSslConn::getSSLImpl(ACE_SOCKET sock, const char* pubkeyfile, const char* libName = "cryptoImpl"; if (m_dll.open(libName, RTLD_NOW | RTLD_GLOBAL, 0) == -1) { char msg[1000] = {0}; - std::snprintf(msg, 1000, "cannot open library: %s", libName); + ACE_OS::snprintf(msg, 1000, "cannot open library: %s", libName); LOGERROR(msg); throw FileNotFoundException(msg); } @@ -38,9 +36,9 @@ GFSsl* TcpSslConn::getSSLImpl(ACE_SOCKET sock, const char* pubkeyfile, reinterpret_cast<gf_create_SslImpl>(m_dll.symbol("gf_create_SslImpl")); if (func == NULL) { char msg[1000]; - std::snprintf(msg, 1000, - "cannot find function %s in library gf_create_SslImpl", - "cryptoImpl"); + ACE_OS::snprintf(msg, 1000, + "cannot find function %s in library gf_create_SslImpl", + "cryptoImpl"); LOGERROR(msg); throw IllegalStateException(msg); } @@ -77,10 +75,12 @@ void TcpSslConn::listen(ACE_INET_Addr addr, uint32_t waitSeconds) { * 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( msg, "TcpSslConn::listen Attempt to listen timed out after %d // seconds.", waitSeconds ); - std::snprintf( + ACE_OS::snprintf( msg, 256, "TcpSslConn::listen Attempt to listen timed out after %d seconds.", waitSeconds); @@ -88,8 +88,8 @@ void TcpSslConn::listen(ACE_INET_Addr addr, uint32_t waitSeconds) { } // sprintf( msg, "TcpSslConn::listen failed with errno: %d: %s", lastError, // ACE_OS::strerror(lastError) ); - std::snprintf(msg, 255, "TcpSslConn::listen failed with errno: %d: %s", - lastError, ACE_OS::strerror(lastError)); + ACE_OS::snprintf(msg, 255, "TcpSslConn::listen failed with errno: %d: %s", + lastError, ACE_OS::strerror(lastError)); throw GeodeIOException(msg); } } @@ -119,7 +119,7 @@ void TcpSslConn::connect() { char msg[256]; int32_t lastError = ACE_OS::last_error(); if (lastError == ETIME || lastError == ETIMEDOUT) { - std::snprintf( + ACE_OS::snprintf( msg, 256, "TcpSslConn::connect Attempt to connect timed out after %d seconds.", m_waitSeconds); @@ -127,8 +127,8 @@ void TcpSslConn::connect() { GF_SAFE_DELETE(m_ssl); throw TimeoutException(msg); } - std::snprintf(msg, 256, "TcpSslConn::connect failed with errno: %d: %s", - lastError, ACE_OS::strerror(lastError)); + ACE_OS::snprintf(msg, 256, "TcpSslConn::connect failed with errno: %d: %s", + lastError, ACE_OS::strerror(lastError)); // this is only called by constructor, so we must delete m_ssl GF_SAFE_DELETE(m_ssl); throw GeodeIOException(msg); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/TcrMessage.hpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/TcrMessage.hpp b/src/cppcache/src/TcrMessage.hpp index 4eb0f3e..5097d40 100644 --- a/src/cppcache/src/TcrMessage.hpp +++ b/src/cppcache/src/TcrMessage.hpp @@ -1114,10 +1114,10 @@ class TcrMessageHelper { } else if (!isObj) { // otherwise we're currently always expecting an object char exMsg[256]; - std::snprintf(exMsg, 255, - "TcrMessageHelper::readChunkPartHeader: " - "%s: part is not object", - methodName); + ACE_OS::snprintf(exMsg, 255, + "TcrMessageHelper::readChunkPartHeader: " + "%s: part is not object", + methodName); LOGDEBUG("%s ", exMsg); // throw MessageException(exMsg); return EXCEPTION; @@ -1135,7 +1135,7 @@ class TcrMessageHelper { return EXCEPTION; } else { char exMsg[256]; - std::snprintf( + ACE_OS::snprintf( exMsg, 255, "TcrMessageHelper::readChunkPartHeader: %s: cannot handle " "java serializable object from server", @@ -1150,10 +1150,10 @@ class TcrMessageHelper { if (expectedFirstType > 0) { if (partType != expectedFirstType) { char exMsg[256]; - std::snprintf(exMsg, 255, - "TcrMessageHelper::readChunkPartHeader: " - "%s: got unhandled object class = %d", - methodName, partType); + ACE_OS::snprintf(exMsg, 255, + "TcrMessageHelper::readChunkPartHeader: " + "%s: got unhandled object class = %d", + methodName, partType); throw MessageException(exMsg); } // This is for GETALL @@ -1170,10 +1170,10 @@ class TcrMessageHelper { } if (compId != expectedPartType) { char exMsg[256]; - std::snprintf(exMsg, 255, - "TcrMessageHelper::readChunkPartHeader: " - "%s: got unhandled object type = %d", - methodName, compId); + ACE_OS::snprintf(exMsg, 255, + "TcrMessageHelper::readChunkPartHeader: " + "%s: got unhandled object type = %d", + methodName, compId); throw MessageException(exMsg); } return OBJECT; @@ -1192,10 +1192,10 @@ class TcrMessageHelper { } else if (!isObj) { // otherwise we're currently always expecting an object char exMsg[256]; - std::snprintf(exMsg, 255, - "TcrMessageHelper::readChunkPartHeader: " - "%s: part is not object", - methodName); + ACE_OS::snprintf(exMsg, 255, + "TcrMessageHelper::readChunkPartHeader: " + "%s: part is not object", + methodName); throw MessageException(exMsg); } @@ -1209,7 +1209,7 @@ class TcrMessageHelper { return static_cast<int8_t>(EXCEPTION); } else { char exMsg[256]; - std::snprintf( + ACE_OS::snprintf( exMsg, 255, "TcrMessageHelper::readChunkPartHeader: %s: cannot handle " "java serializable object from server", http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ThinClientPoolDM.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ThinClientPoolDM.cpp b/src/cppcache/src/ThinClientPoolDM.cpp index e9dbf1a..88f0ea7 100644 --- a/src/cppcache/src/ThinClientPoolDM.cpp +++ b/src/cppcache/src/ThinClientPoolDM.cpp @@ -562,9 +562,9 @@ std::string ThinClientPoolDM::selectEndpoint( getStats().incLoctorResposes(); char epNameStr[128] = {0}; - std::snprintf(epNameStr, 128, "%s:%d", - outEndpoint.getServerName().c_str(), - outEndpoint.getPort()); + ACE_OS::snprintf(epNameStr, 128, "%s:%d", + outEndpoint.getServerName().c_str(), + outEndpoint.getPort()); LOGFINE("ThinClientPoolDM: Locator returned endpoint [%s]", epNameStr); return epNameStr; } else if (m_attrs->m_initServList @@ -731,8 +731,8 @@ const CacheableStringArrayPtr ThinClientPoolDM::getServers() { int i = 0; for (it = vec.begin(); it < vec.end(); it++) { ServerLocation serLoc = *it; - std::snprintf(buffer, 256, "%s:%d", serLoc.getServerName().c_str(), - serLoc.getPort()); + ACE_OS::snprintf(buffer, 256, "%s:%d", serLoc.getServerName().c_str(), + serLoc.getPort()); ptrArr[i++] = CacheableString::create(buffer); } } @@ -2038,7 +2038,7 @@ TcrEndpoint* ThinClientPoolDM::addEP(ServerLocation& serverLoc) { std::string serverName = serverLoc.getServerName(); int port = serverLoc.getPort(); char endpointName[100]; - std::snprintf(endpointName, 100, "%s:%d", serverName.c_str(), port); + ACE_OS::snprintf(endpointName, 100, "%s:%d", serverName.c_str(), port); return addEP(endpointName); } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/ThinClientRegion.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/ThinClientRegion.cpp b/src/cppcache/src/ThinClientRegion.cpp index cacd03a..aa26bb6 100644 --- a/src/cppcache/src/ThinClientRegion.cpp +++ b/src/cppcache/src/ThinClientRegion.cpp @@ -37,8 +37,6 @@ #include "VersionedCacheableObjectPartList.hpp" //#include "PutAllPartialResult.hpp" -#include <cstring> - using namespace apache::geode::client; namespace apache { @@ -623,7 +621,7 @@ SelectResultsPtr ThinClientRegion::query(const char* predicate, bool isFullQuery = false; - size_t predlen = std::strlen(predicate); + size_t predlen = ACE_OS::strlen(predicate); if (predlen > 6) // perhaps it has 'select' or 'import' if its > 6 { @@ -643,8 +641,8 @@ SelectResultsPtr ThinClientRegion::query(const char* predicate, ACE_OS::ace_tolower(predicate[charpos + skipspace]); } - if (!std::strcmp(firstWord, "select") || - !std::strcmp(firstWord, "import")) { + if (!ACE_OS::strcmp(firstWord, "select") || + !ACE_OS::strcmp(firstWord, "import")) { isFullQuery = true; } } @@ -4136,7 +4134,7 @@ void ChunkedDurableCQListResponse::handleChunk( if (!isObj) { // we're currently always expecting an object char exMsg[256]; - std::snprintf( + ACE_OS::snprintf( exMsg, 255, "ChunkedDurableCQListResponse::handleChunk: part is not object"); throw MessageException(exMsg); http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/Utils.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/Utils.cpp b/src/cppcache/src/Utils.cpp index c8c9685..1f3046c 100644 --- a/src/cppcache/src/Utils.cpp +++ b/src/cppcache/src/Utils.cpp @@ -20,7 +20,6 @@ #include "NanoTimer.hpp" #include <ace/Recursive_Thread_Mutex.h> #include <ace/INET_Addr.h> -#include <cstring> extern "C" { #include <stdio.h> @@ -190,7 +189,7 @@ std::string Utils::convertHostToCanonicalForm(const char* endpoints) { struct hostent* host; host = ACE_OS::gethostbyname(hostName); if (host) { - std::snprintf(fullName, 256, "%s:%d", host->h_name, port); + ACE_OS::snprintf(fullName, 256, "%s:%d", host->h_name, port); return fullName; } } else { @@ -198,7 +197,7 @@ std::string Utils::convertHostToCanonicalForm(const char* endpoints) { if (pos != std::string::npos) { ACE_INET_Addr addr(endpoints); addr.get_host_name(hostName, 256); - std::snprintf(fullName, 256, "%s:%d", hostName, port); + ACE_OS::snprintf(fullName, 256, "%s:%d", hostName, port); return fullName; } } @@ -251,7 +250,7 @@ CacheableStringPtr Utils::convertBytesToString(const uint8_t* bytes, size_t totalBytes = 0; char byteStr[20]; for (int32_t index = 0; index < length; ++index) { - int len = std::snprintf(byteStr, 20, "%d ", bytes[index]); + int len = ACE_OS::snprintf(byteStr, 20, "%d ", bytes[index]); totalBytes += len; // no use going beyond maxLength since LOG* methods will truncate // in any case @@ -269,7 +268,7 @@ CacheableStringPtr Utils::convertBytesToString(const uint8_t* bytes, int32_t Utils::logWideString(char* buf, size_t maxLen, const wchar_t* wStr) { if (wStr != NULL) { mbstate_t state; - std::memset(&state, 0, sizeof(mbstate_t)); + ACE_OS::memset(&state, 0, sizeof(mbstate_t)); const char* bufStart = buf; do { if (maxLen < static_cast<size_t>(MB_CUR_MAX)) { @@ -278,7 +277,7 @@ int32_t Utils::logWideString(char* buf, size_t maxLen, const wchar_t* wStr) { size_t numChars = wcrtomb(buf, *wStr, &state); if (numChars == static_cast<size_t>(-1)) { // write short when conversion cannot be done - numChars = std::snprintf(buf, maxLen, "<%u>", *wStr); + numChars = ACE_OS::snprintf(buf, maxLen, "<%u>", *wStr); } buf += numChars; if (numChars >= maxLen) { @@ -288,6 +287,6 @@ int32_t Utils::logWideString(char* buf, size_t maxLen, const wchar_t* wStr) { } while (*wStr++ != L'\0'); return static_cast<int32_t>(buf - bufStart); } else { - return std::snprintf(buf, maxLen, "null"); + return ACE_OS::snprintf(buf, maxLen, "null"); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/AtomicStatisticsImpl.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/AtomicStatisticsImpl.cpp b/src/cppcache/src/statistics/AtomicStatisticsImpl.cpp index 4a62e8e..c237891 100644 --- a/src/cppcache/src/statistics/AtomicStatisticsImpl.cpp +++ b/src/cppcache/src/statistics/AtomicStatisticsImpl.cpp @@ -165,7 +165,7 @@ void AtomicStatisticsImpl::close() { void AtomicStatisticsImpl::_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); @@ -183,10 +183,12 @@ void AtomicStatisticsImpl::_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); @@ -198,7 +200,7 @@ void AtomicStatisticsImpl::_setLong(int32 offset, int64 value) { void AtomicStatisticsImpl::_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); @@ -213,7 +215,7 @@ void AtomicStatisticsImpl::_setDouble(int32 offset, double value) { int32 AtomicStatisticsImpl::_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); @@ -225,7 +227,7 @@ int32 AtomicStatisticsImpl::_getInt(int32 offset) { int64 AtomicStatisticsImpl::_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); @@ -236,7 +238,7 @@ int64 AtomicStatisticsImpl::_getLong(int32 offset) { double AtomicStatisticsImpl::_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); @@ -284,7 +286,7 @@ int64 AtomicStatisticsImpl::getRawBits(StatisticDescriptor* descriptor) { int32 AtomicStatisticsImpl::_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); @@ -303,11 +305,13 @@ int64 AtomicStatisticsImpl::_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); @@ -319,7 +323,7 @@ int64 AtomicStatisticsImpl::_incLong(int32 offset, int64 delta) { double AtomicStatisticsImpl::_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/HostStatHelper.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/HostStatHelper.cpp b/src/cppcache/src/statistics/HostStatHelper.cpp index 757111e..19802d3 100644 --- a/src/cppcache/src/statistics/HostStatHelper.cpp +++ b/src/cppcache/src/statistics/HostStatHelper.cpp @@ -53,9 +53,9 @@ void HostStatHelper::initOSCode() { osCode = GFS_OSTYPE_MACOSX; } else { char buf[1024] = {0}; - std::snprintf(buf, 1024, - "HostStatHelper::initOSTypes:unhandled os type: %s", - osName.c_str()); + ACE_OS::snprintf(buf, 1024, + "HostStatHelper::initOSTypes:unhandled os type: %s", + osName.c_str()); throw IllegalArgumentException(buf); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/HostStatHelperLinux.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/HostStatHelperLinux.cpp b/src/cppcache/src/statistics/HostStatHelperLinux.cpp index 24ae159..e08f7f7 100644 --- a/src/cppcache/src/statistics/HostStatHelperLinux.cpp +++ b/src/cppcache/src/statistics/HostStatHelperLinux.cpp @@ -23,6 +23,7 @@ #include <glob.h> #include "HostStatHelperLinux.hpp" #include "LinuxProcessStats.hpp" +#include <ace/OS.h> using namespace apache::geode::statistics; @@ -65,7 +66,7 @@ void HostStatHelperLinux::refreshProcess(ProcessStats* processStats) { char procFileName[64]; FILE* fPtr; - std::snprintf(procFileName, 64, "/proc/%" PRIu32 "/stat", (uint32)thePid); + ACE_OS::snprintf(procFileName, 64, "/proc/%" PRIu32 "/stat", (uint32)thePid); fPtr = fopen(procFileName, "r"); /* read only */ if (fPtr != NULL) { int32 status = fscanf( http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/HostStatHelperSolaris.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/HostStatHelperSolaris.cpp b/src/cppcache/src/statistics/HostStatHelperSolaris.cpp index 2d44a02..f4f3f3f 100644 --- a/src/cppcache/src/statistics/HostStatHelperSolaris.cpp +++ b/src/cppcache/src/statistics/HostStatHelperSolaris.cpp @@ -18,6 +18,8 @@ #include <gfcpp/gfcpp_globals.hpp> #if defined(_SOLARIS) +#include <ace/OS_NS_sys_utsname.h> +#include <ace/OS_NS_errno.h> #include "HostStatHelperSolaris.hpp" #include <procfs.h> #include <sys/types.h> @@ -30,6 +32,7 @@ #include <glob.h> #include <gfcpp/ExceptionTypes.hpp> #include "SolarisProcessStats.hpp" +#include <ace/OS.h> using namespace apache::geode::statistics; @@ -65,7 +68,7 @@ void HostStatHelperSolaris::refreshProcess(ProcessStats* processStats) { prusage_t currentUsage; psinfo_t currentInfo; - std::snprintf(procFileName, 64, "/proc/%lu/psinfo", (uint32)thePid); + ACE_OS::snprintf(procFileName, 64, "/proc/%lu/psinfo", (uint32)thePid); // fread was returning errno 2 FILENOTFOUND so it was switched to read // This matches what was done in the Geode Project also fPtr = open(procFileName, O_RDONLY, 0); /* read only */ @@ -83,7 +86,7 @@ void HostStatHelperSolaris::refreshProcess(ProcessStats* processStats) { } close(fPtr); } - std::snprintf(procFileName, 64, "/proc/%u/usage", (uint32)thePid); + ACE_OS::snprintf(procFileName, 64, "/proc/%u/usage", (uint32)thePid); fPtr = open(procFileName, O_RDONLY, 0); if (fPtr != -1) { if (read(fPtr, ¤tUsage, sizeof(currentUsage)) != @@ -168,8 +171,8 @@ void HostStatHelperSolaris::getKernelStats(uint32_t* cpuUtil) { m_kstat = kstat_open(); if (m_kstat == NULL) { char buf[128]; - std::snprintf(buf, 128, "Unable to obtain kstat data, errno %d", - errno); + ACE_OS::snprintf(buf, 128, "Unable to obtain kstat data, errno %d", + errno); throw NullPointerException(buf); } } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/HostStatHelperWin.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/HostStatHelperWin.cpp b/src/cppcache/src/statistics/HostStatHelperWin.cpp index ba6e8b0..f5c4926 100644 --- a/src/cppcache/src/statistics/HostStatHelperWin.cpp +++ b/src/cppcache/src/statistics/HostStatHelperWin.cpp @@ -16,6 +16,7 @@ */ #include <gfcpp/gfcpp_globals.hpp> +#include <ace/OS.h> #include "HostStatHelperWin.hpp" @@ -82,11 +83,11 @@ char* HostStatHelperWin::getInstIdStr(PPERF_INSTANCE_DEFINITION PerfInst, static char resbuff[132]; if (PerfInst->UniqueID == PERF_NO_UNIQUE_ID) { short* unicodePtr = (short*)((PBYTE)PerfInst + PerfInst->NameOffset); - std::snprintf(resbuff, 132, "%S length=%d unicode[0]=%d", - (char*)((PBYTE)PerfInst + PerfInst->NameOffset), - PerfInst->NameLength, unicodePtr[0]); + ACE_OS::snprintf(resbuff, 132, "%S length=%d unicode[0]=%d", + (char*)((PBYTE)PerfInst + PerfInst->NameOffset), + PerfInst->NameLength, unicodePtr[0]); } else { - std::snprintf(resbuff, 132, "%s%d", prefix, PerfInst->UniqueID); + ACE_OS::snprintf(resbuff, 132, "%s%d", prefix, PerfInst->UniqueID); } return resbuff; } http://git-wip-us.apache.org/repos/asf/geode-native/blob/d7f6ac3d/src/cppcache/src/statistics/HostStatSampler.cpp ---------------------------------------------------------------------- diff --git a/src/cppcache/src/statistics/HostStatSampler.cpp b/src/cppcache/src/statistics/HostStatSampler.cpp index e4e648a..765f8df 100644 --- a/src/cppcache/src/statistics/HostStatSampler.cpp +++ b/src/cppcache/src/statistics/HostStatSampler.cpp @@ -25,8 +25,6 @@ #include <ace/Dirent.h> #include <ace/Dirent_Selector.h> #include <ace/OS_NS_sys_stat.h> -#include <cstdlib> -#include <cstring> #include <utility> #include <vector> @@ -70,16 +68,16 @@ int selector(const dirent* d) { std::string filebasename = ACE::basename( apache::geode::statistics::globals::g_statFileWithExt.c_str()); size_t actualHyphenPos = filebasename.find_last_of('.'); - if (std::strcmp(filebasename.c_str(), d->d_name) == 0) return 1; + if (strcmp(filebasename.c_str(), d->d_name) == 0) return 1; size_t fileExtPos = inputname.find_last_of('.'); std::string extName = inputname.substr(fileExtPos + 1, inputname.length()); - if (std::strcmp(extName.c_str(), "gfs") != 0) return 0; + if (strcmp(extName.c_str(), "gfs") != 0) return 0; if (fileExtPos != std::string::npos) { std::string tempname = inputname.substr(0, fileExtPos); 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; @@ -106,7 +104,7 @@ int comparator(const dirent** d1, const dirent** d2) { } else if (strlen((*d1)->d_name) > strlen((*d2)->d_name)) { 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) { @@ -179,7 +177,7 @@ HostStatSampler::HostStatSampler(const char* filePath, int64 sampleIntervalMs, // replace all '\' with '/' to make everything easier.. size_t len = g_statFile.length() + 1; char* slashtmp = new char[len]; - std::strncpy(slashtmp, g_statFile.c_str(), len); + ACE_OS::strncpy(slashtmp, g_statFile.c_str(), len); for (size_t i = 0; i < g_statFile.length(); i++) { if (slashtmp[i] == '/') { slashtmp[i] = '\\'; @@ -207,7 +205,7 @@ HostStatSampler::HostStatSampler(const char* filePath, int64 sampleIntervalMs, if (fileHyphenPos != std::string::npos) { std::string buff = tempname.substr(fileHyphenPos + 1, tempname.length()); - rollIndex = std::atoi(buff.c_str()) + 1; + rollIndex = ACE_OS::atoi(buff.c_str()) + 1; } } } @@ -266,11 +264,11 @@ std::string HostStatSampler::createArchiveFileName() { int32 len = static_cast<int32>(m_archiveFileName.length()); size_t fileExtPos = m_archiveFileName.find_last_of('.', len); if (fileExtPos == std::string::npos) { - std::snprintf(buff, 1024, "%s-%d.gfs", m_archiveFileName.c_str(), pid); + ACE_OS::snprintf(buff, 1024, "%s-%d.gfs", m_archiveFileName.c_str(), pid); } else { std::string tmp; tmp = m_archiveFileName.substr(0, fileExtPos); - std::snprintf(buff, 1024, "%s-%d.gfs", tmp.c_str(), pid); + ACE_OS::snprintf(buff, 1024, "%s-%d.gfs", tmp.c_str(), pid); } m_archiveFileName = buff; return m_archiveFileName; @@ -462,13 +460,13 @@ int32 HostStatSampler::rollArchive(std::string filename) { while (!gotNewFileName) { char newfilename[1000] = {0}; if (i < 10) { - std::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i, - extName.c_str()); + ACE_OS::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i, + extName.c_str()); } else { - std::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i, - extName.c_str()); + ACE_OS::snprintf(newfilename, 1000, "%s%c%s-%d.%s", statsdirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, fnameBeforeExt.c_str(), i, + extName.c_str()); } FILE* fp = fopen(newfilename, "r"); @@ -656,8 +654,8 @@ void HostStatSampler::checkDiskLimit() { int status = sds.open(dirname.c_str(), selector, comparator); if (status != -1) { for (int i = 1; i < sds.length(); i++) { - std::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(), - ACE_DIRECTORY_SEPARATOR_CHAR, sds[i]->d_name); + ACE_OS::snprintf(fullpath, 512, "%s%c%s", dirname.c_str(), + ACE_DIRECTORY_SEPARATOR_CHAR, sds[i]->d_name); ACE_OS::stat(fullpath, &statBuf); g_fileInfoPair = std::make_pair(fullpath, statBuf.st_size); fileInfo.push_back(g_fileInfoPair);