Use correct printf format specifiers

use 'clang-tidy' to automatically fix a bunch of incorrect format
specifiers that don't match the arguments passed that compiler was
complaining about. This get us a lot closer to have silent warning
free output during a build.
One day we might even be able to turn on -Werror in CMakeList.txt
master
Nicholas Brown 2017-11-08 12:19:33 +00:00
parent c8178432d2
commit 346436c1b9
15 changed files with 19 additions and 19 deletions

View File

@ -268,7 +268,7 @@ std::vector<CfgNode*> Graph::topoSort()
result[nz-1-i] = nodes[postI[i]];
}
for (size_t i = 0; i < nz; i++) {
msg(MSG_DEBUG, "topological sort #%u: %s[%u]", i, result[i]->getCfg()->getName().c_str(), result[i]->getCfg()->getID());
msg(MSG_DEBUG, "topological sort #%zu: %s[%u]", i, result[i]->getCfg()->getName().c_str(), result[i]->getCfg()->getID());
}
return result;

View File

@ -43,7 +43,7 @@ void SensorManager::setParameters(uint32_t checkInterval = SM_DEFAULT_CHECK_INTE
#endif
if (gethostname(hostname, 100) != 0)
THROWEXCEPTION("failed to get hostname by gethostname()!");
msg(MSG_INFO, "SensorManager: hertz jiffy value=%u, hostname=%s", hertzValue, hostname);
msg(MSG_INFO, "SensorManager: hertz jiffy value=%lu, hostname=%s", hertzValue, hostname);
msg(MSG_INFO, "SensorManager started with following parameters:");
msg(MSG_INFO, " - outputfilename=%s", outputfilename.c_str());

View File

@ -208,7 +208,7 @@ void RBSWormDetector::addConnection(Connection* conn)
te->timeExpire = time(0)+timeExpireWorm;
msg(MSG_DEBUG, "Worm detected:");
msg(MSG_DEBUG, "srcIP: %s", IPToString(te->srcIP).c_str());
msg(MSG_DEBUG, "numFanOut: %d, totalTime: %d",te->numFanouts, trace_ela);
msg(MSG_DEBUG, "numFanOut: %d, totalTime: %f",te->numFanouts, trace_ela);
IDMEFMessage* msg = idmefManager.getNewInstance();
msg->init(idmefTemplate, analyzerId);
@ -357,7 +357,7 @@ void RBSWormDetector::adaptFrequencies ()
//sort list to cut off top and bottom 10 percent
adaptList.sort(RBSWormDetector::comp_entries);
msg(MSG_FATAL,"meta list size %d",adaptList.size());
msg(MSG_FATAL,"meta list size %zu",adaptList.size());
uint32_t num10 = adaptList.size()/10;
list<RBSEntry*>::iterator iter = adaptList.begin();

View File

@ -60,7 +60,7 @@ IpfixCsExporter::IpfixCsExporter(std::string filenamePrefix,
msg(MSG_INFO, " - maxChunkBufferRecords = %d seconds" , maxChunkBufferRecords);
msg(MSG_INFO, " - maxFileCreationInterval = %d seconds" , maxFileCreationInterval);
msg(MSG_INFO, " - exportMode = %d" , exportMode);
msg(MSG_INFO, " - export struct sizes = %u(Ipfix_basic_flow_sequence_chunk_header), %u(Ipfix_basic_flow)", sizeof(Ipfix_basic_flow_sequence_chunk_header), sizeof(Ipfix_basic_flow));
msg(MSG_INFO, " - export struct sizes = %lu(Ipfix_basic_flow_sequence_chunk_header), %lu(Ipfix_basic_flow)", sizeof(Ipfix_basic_flow_sequence_chunk_header), sizeof(Ipfix_basic_flow));
msg(MSG_INFO, "IpfixCsExporter: running");
}
@ -404,11 +404,11 @@ void IpfixCsExporter::registerTimeout()
if (nextChunkTimeout.tv_sec <= nextFileTimeout.tv_sec){
// Register a chunk timeout
timer->addTimeout(this, nextChunkTimeout, NULL);
msg(MSG_DEBUG, "next timeout: %u", nextChunkTimeout.tv_sec);
msg(MSG_DEBUG, "next timeout: %ld", nextChunkTimeout.tv_sec);
} else {
// register a file timeout
timer->addTimeout(this, nextFileTimeout, NULL);
msg(MSG_DEBUG, "next timeout: %u", nextFileTimeout.tv_sec);
msg(MSG_DEBUG, "next timeout: %ld", nextFileTimeout.tv_sec);
}
timeoutRegistered = true;

View File

@ -175,7 +175,7 @@ void IpfixNetflowExporter::sendPacket()
record->removeReference();
count++;
}
msg(MSG_DEBUG, "sending Netflow.v5 packet, flow count: %hu", count);
msg(MSG_DEBUG, "sending Netflow.v5 packet, flow count: %u", count);
packet.header.count = htons(count);
packet.header.unixSec = htonl(tv.tv_sec);
packet.header.unixNanoSec = htonl(tv.tv_usec*1000);

View File

@ -681,7 +681,7 @@ int IpfixParser::processNetflowV9Packet(boost::shared_array<uint8_t> message, ui
/* check if there are trailing bytes */
if ((uint8_t*)(set) != endOfMessage) {
msg(MSG_ERROR, "IpfixParser: NetFlowV9 message contains %u trailing bytes!", endOfMessage - (uint8_t*)(set));
msg(MSG_ERROR, "IpfixParser: NetFlowV9 message contains %ld trailing bytes!", endOfMessage - (uint8_t*)(set));
}
/* check if we got all records */
if ((numberOfDataRecords + numberOfTemplateRecords) != expectedNumberOfRecords) {

View File

@ -50,7 +50,7 @@ IpfixPayloadWriter::IpfixPayloadWriter(string path, string prefix, uint32_t noco
msg(MSG_INFO, " - path=%s", path.c_str());
msg(MSG_INFO, " - filenamePrefix=%s", filenamePrefix.c_str());
msg(MSG_INFO, " - noConnections=%u", noConnections);
msg(MSG_INFO, " - startIndex=%llu", connectionID);
msg(MSG_INFO, " - startIndex=%lu", connectionID);
msg(MSG_INFO, " - ignoreEmptyPayload=%u", ignoreEmptyPayload);
msg(MSG_INFO, " - ignoreIncompleteTCP=%u", ignoreIncompleteTCP);
}

View File

@ -288,7 +288,7 @@ void IpfixReceiverFile::run()
}
packetFile.close();
msg(MSG_INFO, "IpfixReceiverFile: File %s ended after %llu bytes.",
msg(MSG_INFO, "IpfixReceiverFile: File %s ended after %lu bytes.",
packet_file_path.c_str(), idx);
}
msg(MSG_DEBUG, "real_start: %lu msg_start: %lu real_now: %lu msg_now: %lu",

View File

@ -33,7 +33,7 @@ IpfixSampler::IpfixSampler(double flowrate)
msg(MSG_INFO, "IpfixSampler started with following parameters:");
msg(MSG_INFO, " - flowRate=%f", flowRate);
msg(MSG_INFO, " - resulting modulo: %llu", modulo);
msg(MSG_INFO, " - resulting modulo: %lu", modulo);
}
IpfixSampler::~IpfixSampler()

View File

@ -109,7 +109,7 @@ void NetflowV9Converter::onTemplate(IpfixTemplateRecord* record)
msg(MSG_ERROR, "NetflowV9Converter: flowStartSysUpTime has expected length 4, got %u", fi->type.length);
}
} else {
msg(MSG_ERROR, "NetflowV9Converter: Got enterprise specific IE (id=%u, enterprise=%lu, length=%u) in Netflow Template, which should not happen", fi->type.id, fi->type.enterprise, fi->type.length);
msg(MSG_ERROR, "NetflowV9Converter: Got enterprise specific IE (id=%u, enterprise=%u, length=%u) in Netflow Template, which should not happen", fi->type.id, fi->type.enterprise, fi->type.length);
}
}

View File

@ -115,7 +115,7 @@ Rule::Field* AggregatorBaseCfg::readNonFlowKeyRule(XMLElement* e)
InfoElementCfg ie(e);
if (!ie.isKnownIE())
THROWEXCEPTION("Unsupported non-key field %s (id=%u, enterprise=%lu).", (ie.getIeName()).c_str(), ie.getIeId(), ie.getEnterpriseNumber());
THROWEXCEPTION("Unsupported non-key field %s (id=%u, enterprise=%u).", (ie.getIeName()).c_str(), ie.getIeId(), ie.getEnterpriseNumber());
ruleField->modifier = Rule::Field::AGGREGATE;
ruleField->type.id = ie.getIeId();

View File

@ -150,7 +150,7 @@ void BaseAggregator::buildAggregator(Rules* rules, uint16_t inactiveTimeout, uin
rules->rule[i]->hashtable = createHashtable(rules->rule[i], inactiveTimeout, activeTimeout, hashbits);
}
msg(MSG_INFO, "Done. Parsed %d rules; inactiveTimeout %d, activeTimeout %d", rules->count, inactiveTimeout, activeTimeout);
msg(MSG_INFO, "Done. Parsed %zu rules; inactiveTimeout %d, activeTimeout %d", rules->count, inactiveTimeout, activeTimeout);
}

View File

@ -160,7 +160,7 @@ void *Observer::observerThread(void *arg)
if (obs->fileName) msg(MSG_INFO, " - fileName=%s", obs->fileName);
if (obs->captureInterface) msg(MSG_INFO, " - captureInterface=%s", obs->captureInterface);
msg(MSG_INFO, " - filterString='%s'", (obs->filter_exp ? obs->filter_exp : "none"));
msg(MSG_INFO, " - maxPackets=%u", obs->maxPackets);
msg(MSG_INFO, " - maxPackets=%lu", obs->maxPackets);
msg(MSG_INFO, " - capturelen=%d", obs->capturelen);
msg(MSG_INFO, " - dataLinkType=%d", obs->dataLinkType);
if (obs->readFromFile) {
@ -259,7 +259,7 @@ void *Observer::observerThread(void *arg)
if(!pcapData) {
/* no packet data was available */
if(feof(fh))
msg(MSG_DIALOG, "Observer: reached end of file (%llu packets)", obs->processedPackets);
msg(MSG_DIALOG, "Observer: reached end of file (%lu packets)", obs->processedPackets);
file_eof = true;
break;
}

View File

@ -33,7 +33,7 @@ public:
samplingType(type), samplingOnTime(spacing), samplingOffTime(interval-spacing), interval(interval), packetCount(0)
{
gettimeofday(&startTime, 0);
msg(MSG_INFO, "creating systematic sampler with interval=%d and spacing=%d", interval, spacing);
msg(MSG_INFO, "creating systematic sampler with interval=%lu and spacing=%lu", interval, spacing);
}
virtual ~SystematicSampler()

View File

@ -8,7 +8,7 @@ PrinterModule::~PrinterModule()
void PrinterModule::receive(Packet* p)
{
if (do_print)
msg(MSG_FATAL, "%s: packet %d received", prefix.c_str(), p->totalPacketsReceived);
msg(MSG_FATAL, "%s: packet %lu received", prefix.c_str(), p->totalPacketsReceived);
count++;
if (isEndPoint) {