more snprintf...

parent 6e10fe25
This diff is collapsed.
...@@ -153,11 +153,11 @@ FileLogHandler::createNewFile() ...@@ -153,11 +153,11 @@ FileLogHandler::createNewFile()
if (fileNo >= m_maxNoFiles) if (fileNo >= m_maxNoFiles)
{ {
fileNo = 1; fileNo = 1;
::snprintf(newName, sizeof(newName), BaseString::snprintf(newName, sizeof(newName),
"%s.%d", m_pLogFile->getName(), fileNo); "%s.%d", m_pLogFile->getName(), fileNo);
break; break;
} }
::snprintf(newName, sizeof(newName), BaseString::snprintf(newName, sizeof(newName),
"%s.%d", m_pLogFile->getName(), fileNo++); "%s.%d", m_pLogFile->getName(), fileNo++);
} while (File_class::exists(newName)); } while (File_class::exists(newName));
......
...@@ -45,7 +45,7 @@ LogHandler::getDefaultHeader(char* pStr, const char* pCategory, ...@@ -45,7 +45,7 @@ LogHandler::getDefaultHeader(char* pStr, const char* pCategory,
Logger::LoggerLevel level) const Logger::LoggerLevel level) const
{ {
char time[MAX_DATE_TIME_HEADER_LENGTH]; char time[MAX_DATE_TIME_HEADER_LENGTH];
::snprintf(pStr, MAX_HEADER_LENGTH, "%s [%s] %s -- ", BaseString::snprintf(pStr, MAX_HEADER_LENGTH, "%s [%s] %s -- ",
getTimeAsString((char*)time), getTimeAsString((char*)time),
pCategory, pCategory,
Logger::LoggerLevelNames[level]); Logger::LoggerLevelNames[level]);
...@@ -84,7 +84,7 @@ LogHandler::getTimeAsString(char* pStr) const ...@@ -84,7 +84,7 @@ LogHandler::getTimeAsString(char* pStr) const
tm_now = ::localtime(&now); //uses the "current" timezone tm_now = ::localtime(&now); //uses the "current" timezone
#endif #endif
::snprintf(pStr, MAX_DATE_TIME_HEADER_LENGTH, BaseString::snprintf(pStr, MAX_DATE_TIME_HEADER_LENGTH,
m_pDateTimeFormat, m_pDateTimeFormat,
tm_now->tm_year + 1900, tm_now->tm_year + 1900,
tm_now->tm_mon + 1, //month is [0,11]. +1 -> [1,12] tm_now->tm_mon + 1, //month is [0,11]. +1 -> [1,12]
......
...@@ -128,7 +128,7 @@ LogHandlerListUnitTest::testTraverseNext(const char* msg) ...@@ -128,7 +128,7 @@ LogHandlerListUnitTest::testTraverseNext(const char* msg)
{ {
char* str = new char[3]; char* str = new char[3];
pHandlers[i] = new ConsoleLogHandler(); pHandlers[i] = new ConsoleLogHandler();
::snprintf(str, 3, "%d", i); BaseString::snprintf(str, 3, "%d", i);
pHandlers[i]->setDateTimeFormat(str); pHandlers[i]->setDateTimeFormat(str);
list.add(pHandlers[i]); list.add(pHandlers[i]);
} }
......
...@@ -86,7 +86,7 @@ NDB_COMMAND(loggertest, "loggertest", "loggertest -console | -file", ...@@ -86,7 +86,7 @@ NDB_COMMAND(loggertest, "loggertest", "loggertest -console | -file",
{ {
ndbout << "-- " << " Test " << i + 1 ndbout << "-- " << " Test " << i + 1
<< " [" << testCases[i].name << "] --" << endl; << " [" << testCases[i].name << "] --" << endl;
::snprintf(str, 256, "%s %s %s %d", "Logging ", BaseString::snprintf(str, 256, "%s %s %s %d", "Logging ",
testCases[i].name, " message ", i); testCases[i].name, " message ", i);
if (testCases[i].test(str)) if (testCases[i].test(str))
{ {
......
...@@ -83,7 +83,7 @@ File_class::File_class(const char* aFileName, const char* mode) : ...@@ -83,7 +83,7 @@ File_class::File_class(const char* aFileName, const char* mode) :
m_file(NULL), m_file(NULL),
m_fileMode(mode) m_fileMode(mode)
{ {
::snprintf(m_fileName, MAX_FILE_NAME_SIZE, aFileName); BaseString::snprintf(m_fileName, MAX_FILE_NAME_SIZE, aFileName);
} }
bool bool
...@@ -99,7 +99,7 @@ File_class::open(const char* aFileName, const char* mode) ...@@ -99,7 +99,7 @@ File_class::open(const char* aFileName, const char* mode)
/** /**
* Only copy if it's not the same string * Only copy if it's not the same string
*/ */
::snprintf(m_fileName, MAX_FILE_NAME_SIZE, aFileName); BaseString::snprintf(m_fileName, MAX_FILE_NAME_SIZE, aFileName);
} }
m_fileMode = mode; m_fileMode = mode;
bool rc = true; bool rc = true;
......
...@@ -346,15 +346,15 @@ extern "C" OSBOOLEAN ndb_err_hnd(bool user_called, ...@@ -346,15 +346,15 @@ extern "C" OSBOOLEAN ndb_err_hnd(bool user_called,
file_name = "ose_err.h"; file_name = "ose_err.h";
} }
snprintf (error_message.header1, BaseString::snprintf(error_message.header1,
BUFSIZE, BUFSIZE,
"This is the OSE Example System Error handler\r\n"); "This is the OSE Example System Error handler\r\n");
snprintf (error_message.err_hnd_file, BaseString::snprintf(error_message.err_hnd_file,
BUFSIZE, BUFSIZE,
"located in: " __FILE__ "\r\n"); "located in: " __FILE__ "\r\n");
snprintf (error_message.header2, BaseString::snprintf(error_message.header2,
BUFSIZE, BUFSIZE,
"An Error has been reported:\r\n"); "An Error has been reported:\r\n");
...@@ -371,28 +371,28 @@ extern "C" OSBOOLEAN ndb_err_hnd(bool user_called, ...@@ -371,28 +371,28 @@ extern "C" OSBOOLEAN ndb_err_hnd(bool user_called,
user_called); user_called);
} }
snprintf (error_message.error_code_line, BaseString::snprintf(error_message.error_code_line,
BUFSIZE, BUFSIZE,
"error code: 0x%08x\r\n", "error code: 0x%08x\r\n",
error_code); error_code);
snprintf (error_message.subcode_line, BaseString::snprintf(error_message.subcode_line,
BUFSIZE, BUFSIZE,
" subcode: %s (0x%08x)\r\n", " subcode: %s (0x%08x)\r\n",
subcode_mnemonic, subcode_mnemonic,
( subcode << 16)); ( subcode << 16));
snprintf (error_message.product_line, BaseString::snprintf(error_message.product_line,
BUFSIZE, BUFSIZE,
" product: %s\r\n", " product: %s\r\n",
product_name); product_name);
snprintf (error_message.header_file_line, BaseString::snprintf(error_message.header_file_line,
BUFSIZE, BUFSIZE,
" header file: %s\r\n", " header file: %s\r\n",
file_name); file_name);
snprintf (error_message.extra_line, BaseString::snprintf(error_message.extra_line,
BUFSIZE, BUFSIZE,
"extra: 0x%08x\r\n", "extra: 0x%08x\r\n",
extra); extra);
......
...@@ -3405,9 +3405,9 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -3405,9 +3405,9 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
s.m_sectionType= BaseString("TCP"); s.m_sectionType= BaseString("TCP");
s.m_sectionData= new Properties(true); s.m_sectionData= new Properties(true);
char buf[16]; char buf[16];
snprintf(buf, sizeof(buf), "%u", nodeId1); BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1);
s.m_sectionData->put("NodeId1", buf); s.m_sectionData->put("NodeId1", buf);
snprintf(buf, sizeof(buf), "%u", nodeId2); BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2);
s.m_sectionData->put("NodeId2", buf); s.m_sectionData->put("NodeId2", buf);
sections.push_back(s); sections.push_back(s);
} }
...@@ -3422,9 +3422,9 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections, ...@@ -3422,9 +3422,9 @@ add_node_connections(Vector<ConfigInfo::ConfigRuleSection>&sections,
s.m_sectionType= BaseString("TCP"); s.m_sectionType= BaseString("TCP");
s.m_sectionData= new Properties(true); s.m_sectionData= new Properties(true);
char buf[16]; char buf[16];
snprintf(buf, sizeof(buf), "%u", nodeId1); BaseString::snprintf(buf, sizeof(buf), "%u", nodeId1);
s.m_sectionData->put("NodeId1", buf); s.m_sectionData->put("NodeId1", buf);
snprintf(buf, sizeof(buf), "%u", nodeId2); BaseString::snprintf(buf, sizeof(buf), "%u", nodeId2);
s.m_sectionData->put("NodeId2", buf); s.m_sectionData->put("NodeId2", buf);
sections.push_back(s); sections.push_back(s);
} }
......
...@@ -103,7 +103,7 @@ void showTime() ...@@ -103,7 +103,7 @@ void showTime()
now = ::time((time_t*)NULL); now = ::time((time_t*)NULL);
tm_now = ::gmtime(&now); tm_now = ::gmtime(&now);
::snprintf(buf, 128, BaseString::snprintf(buf, 128,
"%d-%.2d-%.2d %.2d:%.2d:%.2d", "%d-%.2d-%.2d %.2d:%.2d:%.2d",
tm_now->tm_year + 1900, tm_now->tm_year + 1900,
tm_now->tm_mon, tm_now->tm_mon,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment