code style
This commit is contained in:
@@ -146,7 +146,7 @@ class PollRequest : public BusRequest {
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
* @param message the associated @a Message.
|
* @param message the associated @a Message.
|
||||||
*/
|
*/
|
||||||
PollRequest(Message* message)
|
explicit PollRequest(Message* message)
|
||||||
: BusRequest(m_master, true), m_message(message), m_index(0) {}
|
: BusRequest(m_master, true), m_message(message), m_index(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ class DataSource : virtual public DataHandler {
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
* @param busHandler the @a BusHandler instance.
|
* @param busHandler the @a BusHandler instance.
|
||||||
*/
|
*/
|
||||||
DataSource(BusHandler* busHandler)
|
explicit DataSource(BusHandler* busHandler)
|
||||||
: m_busHandler(busHandler) {}
|
: m_busHandler(busHandler) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+10
-8
@@ -1047,17 +1047,19 @@ string MainLoop::executeFind(vector<string> &args) {
|
|||||||
if (verbosity == (OF_NAMES|OF_UNITS|OF_COMMENTS)) {
|
if (verbosity == (OF_NAMES|OF_UNITS|OF_COMMENTS)) {
|
||||||
unsigned char dstAddress = message->getDstAddress();
|
unsigned char dstAddress = message->getDstAddress();
|
||||||
if (dstAddress != SYN) {
|
if (dstAddress != SYN) {
|
||||||
sprintf(str, "%02x", dstAddress);
|
snprintf(str, sizeof(str), "%02x", dstAddress);
|
||||||
} else if (lastup != 0 && message->getLastMasterData().size() > 1) {
|
} else if (lastup != 0 && message->getLastMasterData().size() > 1) {
|
||||||
sprintf(str, "%02x", message->getLastMasterData()[1]);
|
snprintf(str, sizeof(str), "%02x", message->getLastMasterData()[1]);
|
||||||
} else {
|
} else {
|
||||||
sprintf(str, "any");
|
snprintf(str, sizeof(str), "any");
|
||||||
}
|
}
|
||||||
if (lastup != 0) {
|
if (lastup != 0) {
|
||||||
struct tm* td = localtime(&lastup);
|
struct tm td;
|
||||||
sprintf(str+strlen(str), ", lastup=%04d-%02d-%02d %02d:%02d:%02d",
|
localtime_r(&lastup, &td);
|
||||||
td->tm_year+1900, td->tm_mon+1, td->tm_mday,
|
size_t len = strlen(str);
|
||||||
td->tm_hour, td->tm_min, td->tm_sec);
|
snprintf(str+len, sizeof(str)-len, ", lastup=%04d-%02d-%02d %02d:%02d:%02d",
|
||||||
|
td.tm_year+1900, td.tm_mon+1, td.tm_mday,
|
||||||
|
td.tm_hour, td.tm_min, td.tm_sec);
|
||||||
}
|
}
|
||||||
result << " [ZZ=" << str;
|
result << " [ZZ=" << str;
|
||||||
if (message->isPassive()) {
|
if (message->isPassive()) {
|
||||||
@@ -1187,7 +1189,7 @@ string MainLoop::executeScan(vector<string> &args) {
|
|||||||
string MainLoop::executeLog(vector<string> &args) {
|
string MainLoop::executeLog(vector<string> &args) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
ostringstream ret;
|
ostringstream ret;
|
||||||
char str[32];
|
char str[48];
|
||||||
if (getLogFacilities(str)) {
|
if (getLogFacilities(str)) {
|
||||||
ret << str << ' ';
|
ret << str << ' ';
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -44,7 +44,7 @@ class NetMessage {
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
* @param isHttp whether this is a HTTP message.
|
* @param isHttp whether this is a HTTP message.
|
||||||
*/
|
*/
|
||||||
NetMessage(const bool isHttp)
|
explicit NetMessage(const bool isHttp)
|
||||||
: m_isHttp(isHttp), m_resultSet(false), m_disconnect(false), m_listening(false), m_listenSince(0) {
|
: m_isHttp(isHttp), m_resultSet(false), m_disconnect(false), m_listening(false), m_listenSince(0) {
|
||||||
pthread_mutex_init(&m_mutex, NULL);
|
pthread_mutex_init(&m_mutex, NULL);
|
||||||
pthread_cond_init(&m_cond, NULL);
|
pthread_cond_init(&m_cond, NULL);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class TemParamDataType : public NumberDataType {
|
|||||||
* Constructs a new instance.
|
* Constructs a new instance.
|
||||||
* @param id the type identifier.
|
* @param id the type identifier.
|
||||||
*/
|
*/
|
||||||
TemParamDataType(const string id)
|
explicit TemParamDataType(const string id)
|
||||||
: NumberDataType(id, 16, 0, 0xffff, 0, 0xffff, 0) {}
|
: NumberDataType(id, 16, 0, 0xffff, 0, 0xffff, 0) {}
|
||||||
|
|
||||||
// @copydoc
|
// @copydoc
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ class FileReader {
|
|||||||
/**
|
/**
|
||||||
* Construct a new instance.
|
* Construct a new instance.
|
||||||
*/
|
*/
|
||||||
FileReader(bool supportsDefaults)
|
explicit FileReader(bool supportsDefaults)
|
||||||
: m_supportsDefaults(supportsDefaults) {}
|
: m_supportsDefaults(supportsDefaults) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ result_t Message::create(vector<string>::iterator& it, const vector<string>::ite
|
|||||||
unsigned char dstAddress = *it;
|
unsigned char dstAddress = *it;
|
||||||
string useCircuit = circuit;
|
string useCircuit = circuit;
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
sprintf(num, ".%d", index);
|
snprintf(num, sizeof(num), ".%d", index);
|
||||||
useCircuit = useCircuit + num;
|
useCircuit = useCircuit + num;
|
||||||
}
|
}
|
||||||
Message* message;
|
Message* message;
|
||||||
|
|||||||
@@ -1136,7 +1136,7 @@ class MessageMap : public FileReader {
|
|||||||
* Construct a new instance.
|
* Construct a new instance.
|
||||||
* @param addAll whether to add all messages, even if duplicate.
|
* @param addAll whether to add all messages, even if duplicate.
|
||||||
*/
|
*/
|
||||||
MessageMap(const bool addAll = false) : FileReader::FileReader(true),
|
explicit MessageMap(const bool addAll = false) : FileReader::FileReader(true),
|
||||||
m_addAll(addAll), m_maxIdLength(0), m_messageCount(0), m_conditionalMessageCount(0), m_passiveMessageCount(0) {
|
m_addAll(addAll), m_maxIdLength(0), m_messageCount(0), m_conditionalMessageCount(0), m_passiveMessageCount(0) {
|
||||||
m_scanMessage = Message::createScanMessage();
|
m_scanMessage = Message::createScanMessage();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class SymbolString {
|
|||||||
* Creates a new empty escaped or unescaped instance.
|
* Creates a new empty escaped or unescaped instance.
|
||||||
* @param escaped whether to create an escaped instance.
|
* @param escaped whether to create an escaped instance.
|
||||||
*/
|
*/
|
||||||
SymbolString(const bool escaped = true) : m_unescapeState(escaped ? 0 : 1), m_crc(0) {}
|
explicit SymbolString(const bool escaped = true) : m_unescapeState(escaped ? 0 : 1), m_crc(0) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all symbols from the other @a SymbolString and the calculated CRC if escaped.
|
* Add all symbols from the other @a SymbolString and the calculated CRC if escaped.
|
||||||
|
|||||||
@@ -79,17 +79,18 @@ bool setLogFacilities(const char* facilities) {
|
|||||||
|
|
||||||
bool getLogFacilities(char* buffer) {
|
bool getLogFacilities(char* buffer) {
|
||||||
if (s_logFacilites == LF_ALL) {
|
if (s_logFacilites == LF_ALL) {
|
||||||
return strcpy(buffer, facilityNames[lf_COUNT]) != NULL;
|
return snprintf(buffer, 48, "%s", facilityNames[lf_COUNT]) != 0;
|
||||||
}
|
}
|
||||||
*buffer = 0; // for strcat to work
|
*buffer = 0; // for strcat to work
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
size_t len = 0;
|
||||||
for (int val = 0; val < lf_COUNT; val++) {
|
for (int val = 0; val < lf_COUNT; val++) {
|
||||||
if (s_logFacilites&(1 << val)) {
|
if (s_logFacilites&(1 << val)) {
|
||||||
if (found) {
|
if (found) {
|
||||||
strcat(buffer, ",");
|
len += snprintf(buffer+len, 48-len, ",");
|
||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
strcat(buffer, facilityNames[val]);
|
len += snprintf(buffer+len, 48-len, "%s", facilityNames[val]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -142,14 +143,14 @@ bool needsLog(const LogFacility facility, const LogLevel level) {
|
|||||||
|
|
||||||
void logWrite(const char* facility, const char* level, const char* message, va_list ap) {
|
void logWrite(const char* facility, const char* level, const char* message, va_list ap) {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
struct tm* tm;
|
struct tm td;
|
||||||
clockGettime(&ts);
|
clockGettime(&ts);
|
||||||
tm = localtime(&ts.tv_sec);
|
localtime_r(&ts.tv_sec, &td);
|
||||||
char* buf;
|
char* buf;
|
||||||
if (vasprintf(&buf, message, ap) >= 0 && buf) {
|
if (vasprintf(&buf, message, ap) >= 0 && buf) {
|
||||||
fprintf(s_logFile, "%04d-%02d-%02d %02d:%02d:%02d.%03ld [%s %s] %s\n",
|
fprintf(s_logFile, "%04d-%02d-%02d %02d:%02d:%02d.%03ld [%s %s] %s\n",
|
||||||
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
|
td.tm_year+1900, td.tm_mon+1, td.tm_mday,
|
||||||
tm->tm_hour, tm->tm_min, tm->tm_sec, ts.tv_nsec/1000000,
|
td.tm_hour, td.tm_min, td.tm_sec, ts.tv_nsec/1000000,
|
||||||
facility, level, buf);
|
facility, level, buf);
|
||||||
fflush(s_logFile);
|
fflush(s_logFile);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ bool setLogFacilities(const char* facilities);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the log facilities.
|
* Get the log facilities.
|
||||||
* @param buffer the buffer into which the facilities are written to (separated by comma, buffer needs to be at last 32 characters long).
|
* @param buffer the buffer into which the facilities are written to (separated by comma, buffer needs to be at last 48 characters long).
|
||||||
* @return true on success, false on error.
|
* @return true on success, false on error.
|
||||||
*/
|
*/
|
||||||
bool getLogFacilities(char* buffer);
|
bool getLogFacilities(char* buffer);
|
||||||
|
|||||||
@@ -58,12 +58,12 @@ void RotateFile::write(unsigned char* value, unsigned int size, bool received) {
|
|||||||
}
|
}
|
||||||
if (m_textMode) {
|
if (m_textMode) {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
struct tm* tm;
|
struct tm td;
|
||||||
clockGettime(&ts);
|
clockGettime(&ts);
|
||||||
tm = localtime(&ts.tv_sec);
|
localtime_r(&ts.tv_sec, &td);
|
||||||
fprintf(m_stream, "%04d-%02d-%02d %02d:%02d:%02d.%03ld %c",
|
fprintf(m_stream, "%04d-%02d-%02d %02d:%02d:%02d.%03ld %c",
|
||||||
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday,
|
td.tm_year+1900, td.tm_mon+1, td.tm_mday,
|
||||||
tm->tm_hour, tm->tm_min, tm->tm_sec, ts.tv_nsec/1000000,
|
td.tm_hour, td.tm_min, td.tm_sec, ts.tv_nsec/1000000,
|
||||||
received ? '<' : '>');
|
received ? '<' : '>');
|
||||||
for (unsigned int pos = 0; pos < size; pos++) {
|
for (unsigned int pos = 0; pos < size; pos++) {
|
||||||
fprintf(m_stream, "%2.2x ", value[pos]);
|
fprintf(m_stream, "%2.2x ", value[pos]);
|
||||||
|
|||||||
Reference in New Issue
Block a user