Used sizeof for buffer sizes instead of hardcoding values
parent
e2e45f7a14
commit
38ccb7e6c9
|
@ -67,7 +67,7 @@ static void ReportWarning(const char *msg, ...) {
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
|
|
||||||
char szBuffer[3000];
|
char szBuffer[3000];
|
||||||
const int iLen = vsnprintf(szBuffer, 3000, msg, args);
|
const int iLen = vsnprintf(szBuffer, sizeof(szBuffer), msg, args);
|
||||||
ai_assert(iLen > 0);
|
ai_assert(iLen > 0);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
|
@ -1228,7 +1228,7 @@ void FBXExporter::WriteObjects ()
|
||||||
"Version", int32_t(101), outstream, binary, indent
|
"Version", int32_t(101), outstream, binary, indent
|
||||||
);
|
);
|
||||||
char layerName[8];
|
char layerName[8];
|
||||||
snprintf(layerName, 8, "COLOR_%d", colorChannelIndex);
|
snprintf(layerName, sizeof(layerName), "COLOR_%d", colorChannelIndex);
|
||||||
FBX::Node::WritePropertyNode(
|
FBX::Node::WritePropertyNode(
|
||||||
"Name", (const char*)layerName, outstream, binary, indent
|
"Name", (const char*)layerName, outstream, binary, indent
|
||||||
);
|
);
|
||||||
|
|
|
@ -99,7 +99,7 @@ MD5Parser::MD5Parser(char *_buffer, unsigned int _fileSize) : buffer(_buffer), b
|
||||||
// Report warning to the log stream
|
// Report warning to the log stream
|
||||||
/*static*/ void MD5Parser::ReportWarning(const char *warn, unsigned int line) {
|
/*static*/ void MD5Parser::ReportWarning(const char *warn, unsigned int line) {
|
||||||
char szBuffer[1024];
|
char szBuffer[1024];
|
||||||
::snprintf(szBuffer, 1024, "[MD5] Line %u: %s", line, warn);
|
::snprintf(szBuffer, sizeof(szBuffer), "[MD5] Line %u: %s", line, warn);
|
||||||
ASSIMP_LOG_WARN(szBuffer);
|
ASSIMP_LOG_WARN(szBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ void MDLImporter::SizeCheck(const void *szPos, const char *szFile, unsigned int
|
||||||
}
|
}
|
||||||
|
|
||||||
char szBuffer[1024];
|
char szBuffer[1024];
|
||||||
::snprintf(szBuffer, 1024, "Invalid MDL file. The file is too small "
|
::snprintf(szBuffer, sizeof(szBuffer), "Invalid MDL file. The file is too small "
|
||||||
"or contains invalid data (File: %s Line: %u)",
|
"or contains invalid data (File: %s Line: %u)",
|
||||||
szFilePtr, iLine);
|
szFilePtr, iLine);
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ AI_WONT_RETURN void ValidateDSProcess::ReportError(const char *msg, ...) {
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
|
|
||||||
char szBuffer[3000];
|
char szBuffer[3000];
|
||||||
const int iLen = vsnprintf(szBuffer, 3000, msg, args);
|
const int iLen = vsnprintf(szBuffer, sizeof(szBuffer), msg, args);
|
||||||
ai_assert(iLen > 0);
|
ai_assert(iLen > 0);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
@ -95,7 +95,7 @@ void ValidateDSProcess::ReportWarning(const char *msg, ...) {
|
||||||
va_start(args, msg);
|
va_start(args, msg);
|
||||||
|
|
||||||
char szBuffer[3000];
|
char szBuffer[3000];
|
||||||
const int iLen = vsnprintf(szBuffer, 3000, msg, args);
|
const int iLen = vsnprintf(szBuffer, sizeof(szBuffer), msg, args);
|
||||||
ai_assert(iLen > 0);
|
ai_assert(iLen > 0);
|
||||||
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
|
@ -224,7 +224,7 @@ bool OpenDDLExport::writeValueType(Value::ValueType type, size_t numItems, std::
|
||||||
statement += "[";
|
statement += "[";
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
::memset(buffer, '\0', 256 * sizeof(char));
|
::memset(buffer, '\0', 256 * sizeof(char));
|
||||||
snprintf(buffer, 256, "%d", static_cast<int>(numItems));
|
snprintf(buffer, sizeof(buffer), "%d", static_cast<int>(numItems));
|
||||||
statement += buffer;
|
statement += buffer;
|
||||||
statement += "]";
|
statement += "]";
|
||||||
}
|
}
|
||||||
|
@ -255,7 +255,7 @@ bool OpenDDLExport::writeValue(Value *val, std::string &statement) {
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
::memset(buffer, '\0', 256 * sizeof(char));
|
::memset(buffer, '\0', 256 * sizeof(char));
|
||||||
snprintf(buffer, 256, "%d", val->getInt16());
|
snprintf(buffer, sizeof(buffer), "%d", val->getInt16());
|
||||||
statement += buffer;
|
statement += buffer;
|
||||||
} break;
|
} break;
|
||||||
case Value::ValueType::ddl_int32: {
|
case Value::ValueType::ddl_int32: {
|
||||||
|
@ -263,7 +263,7 @@ bool OpenDDLExport::writeValue(Value *val, std::string &statement) {
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
::memset(buffer, '\0', 256 * sizeof(char));
|
::memset(buffer, '\0', 256 * sizeof(char));
|
||||||
const int i = static_cast<int>(val->getInt32());
|
const int i = static_cast<int>(val->getInt32());
|
||||||
snprintf(buffer, 256, "%d", i);
|
snprintf(buffer, sizeof(buffer), "%d", i);
|
||||||
statement += buffer;
|
statement += buffer;
|
||||||
} break;
|
} break;
|
||||||
case Value::ValueType::ddl_int64: {
|
case Value::ValueType::ddl_int64: {
|
||||||
|
|
Loading…
Reference in New Issue