From fa7040fe65f259fa86ba22ea774496160d465c50 Mon Sep 17 00:00:00 2001 From: Florian Uhlig Date: Wed, 9 Mar 2016 15:52:10 +0100 Subject: [PATCH] Fix compiler warnings. Initialize all data members in initializer lists. Reorder data members in initializer list to have the same order as in the class declaration. Comment or remove unused parameters and unused variables. Convert all old style casts to the correct and explicit c++ cast like const_cast, static_cast, dynamic_cast or reinterpret_cast. In most cases static_cast is used. --- fairmq/FairMQChannel.cxx | 12 ++++++------ fairmq/FairMQDevice.cxx | 10 +++++----- fairmq/FairMQLogger.cxx | 2 +- fairmq/devices/GenericSampler.h | 2 +- fairmq/nanomsg/FairMQPollerNN.cxx | 2 +- fairmq/nanomsg/FairMQSocketNN.cxx | 6 +++--- fairmq/options/FairMQParser.cxx | 2 +- fairmq/options/FairMQProgOptions.cxx | 2 +- fairmq/options/FairProgOptions.cxx | 8 ++++---- .../ProgOptionTest/lib/FairMQParserExample.cxx | 2 +- fairmq/run/runSink.cxx | 2 +- fairmq/run/runSplitter.cxx | 2 +- fairmq/test/pub-sub/runTestPub.cxx | 2 +- fairmq/test/pub-sub/runTestSub.cxx | 2 +- fairmq/test/push-pull/runTestPull.cxx | 2 +- fairmq/test/push-pull/runTestPush.cxx | 2 +- fairmq/test/req-rep/runTestRep.cxx | 2 +- fairmq/test/req-rep/runTestReq.cxx | 2 +- fairmq/test/runTransferTimeoutTest.cxx | 6 +++--- fairmq/zeromq/FairMQMessageZMQ.cxx | 6 +++--- 20 files changed, 38 insertions(+), 38 deletions(-) diff --git a/fairmq/FairMQChannel.cxx b/fairmq/FairMQChannel.cxx index 40f884fe..7258061a 100644 --- a/fairmq/FairMQChannel.cxx +++ b/fairmq/FairMQChannel.cxx @@ -24,13 +24,13 @@ using namespace std; boost::mutex FairMQChannel::fChannelMutex; FairMQChannel::FairMQChannel() - : fType("unspecified") + : fSocket(nullptr) + , fType("unspecified") , fMethod("unspecified") , fAddress("unspecified") , fSndBufSize(1000) , fRcvBufSize(1000) , fRateLogging(1) - , fSocket(nullptr) , fChannelName("") , fIsValid(false) , fPoller(nullptr) @@ -44,13 +44,13 @@ FairMQChannel::FairMQChannel() } FairMQChannel::FairMQChannel(const string& type, const string& method, const string& address) - : fType(type) + : fSocket(nullptr) + , fType(type) , fMethod(method) , fAddress(address) , fSndBufSize(1000) , fRcvBufSize(1000) , fRateLogging(1) - , fSocket(nullptr) , fChannelName("") , fIsValid(false) , fPoller(nullptr) @@ -64,13 +64,13 @@ FairMQChannel::FairMQChannel(const string& type, const string& method, const str } FairMQChannel::FairMQChannel(const FairMQChannel& chan) - : fType(chan.fType) + : fSocket(nullptr) + , fType(chan.fType) , fMethod(chan.fMethod) , fAddress(chan.fAddress) , fSndBufSize(chan.fSndBufSize) , fRcvBufSize(chan.fRcvBufSize) , fRateLogging(chan.fRateLogging) - , fSocket(nullptr) , fChannelName(chan.fChannelName) , fIsValid(false) , fPoller(nullptr) diff --git a/fairmq/FairMQDevice.cxx b/fairmq/FairMQDevice.cxx index 923fe8fe..d8af1dd8 100644 --- a/fairmq/FairMQDevice.cxx +++ b/fairmq/FairMQDevice.cxx @@ -225,7 +225,7 @@ bool FairMQDevice::InitChannel(FairMQChannel& ch) size_t pos = ch.fAddress.rfind(":"); stringstream newPort; - newPort << (int)randomPort(gen); + newPort << static_cast(randomPort(gen)); ch.fAddress = ch.fAddress.substr(0, pos + 1) + newPort.str(); LOG(DEBUG) << "Binding channel " << ch.fChannelName << " on " << ch.fAddress; @@ -559,19 +559,19 @@ void FairMQDevice::LogSocketRates() for (auto itr = filteredSockets.begin(); itr != filteredSockets.end(); itr++) { bytesInNew.at(i) = (*itr)->GetBytesRx(); - mbPerSecIn.at(i) = ((double)(bytesInNew.at(i) - bytesIn.at(i)) / (1024. * 1024.)) / (double)msSinceLastLog * 1000.; + mbPerSecIn.at(i) = (static_cast(bytesInNew.at(i) - bytesIn.at(i)) / (1024. * 1024.)) / static_cast(msSinceLastLog) * 1000.; bytesIn.at(i) = bytesInNew.at(i); msgInNew.at(i) = (*itr)->GetMessagesRx(); - msgPerSecIn.at(i) = (double)(msgInNew.at(i) - msgIn.at(i)) / (double)msSinceLastLog * 1000.; + msgPerSecIn.at(i) = static_cast(msgInNew.at(i) - msgIn.at(i)) / static_cast(msSinceLastLog) * 1000.; msgIn.at(i) = msgInNew.at(i); bytesOutNew.at(i) = (*itr)->GetBytesTx(); - mbPerSecOut.at(i) = ((double)(bytesOutNew.at(i) - bytesOut.at(i)) / (1024. * 1024.)) / (double)msSinceLastLog * 1000.; + mbPerSecOut.at(i) = (static_cast(bytesOutNew.at(i) - bytesOut.at(i)) / (1024. * 1024.)) / static_cast(msSinceLastLog) * 1000.; bytesOut.at(i) = bytesOutNew.at(i); msgOutNew.at(i) = (*itr)->GetMessagesTx(); - msgPerSecOut.at(i) = (double)(msgOutNew.at(i) - msgOut.at(i)) / (double)msSinceLastLog * 1000.; + msgPerSecOut.at(i) = static_cast(msgOutNew.at(i) - msgOut.at(i)) / static_cast(msSinceLastLog) * 1000.; msgOut.at(i) = msgOutNew.at(i); LOG(DEBUG) << filteredChannelNames.at(i) << ": " diff --git a/fairmq/FairMQLogger.cxx b/fairmq/FairMQLogger.cxx index 5a8cc71d..9b37929d 100644 --- a/fairmq/FairMQLogger.cxx +++ b/fairmq/FairMQLogger.cxx @@ -20,5 +20,5 @@ timestamp_t get_timestamp() { struct timeval now; gettimeofday(&now, NULL); - return now.tv_usec + (timestamp_t)now.tv_sec * 1000000; + return now.tv_usec + static_cast(now.tv_sec) * 1000000; } diff --git a/fairmq/devices/GenericSampler.h b/fairmq/devices/GenericSampler.h index 76ae4d1a..fe84b043 100644 --- a/fairmq/devices/GenericSampler.h +++ b/fairmq/devices/GenericSampler.h @@ -181,7 +181,7 @@ class base_GenericSampler : public FairMQDevice, public T, public U } template = 0> - void SendHeader(int socketIdx) {} + void SendHeader(int /*socketIdx*/) {} template = 0> void SendHeader(int socketIdx) { diff --git a/fairmq/nanomsg/FairMQPollerNN.cxx b/fairmq/nanomsg/FairMQPollerNN.cxx index b9305190..570eae89 100644 --- a/fairmq/nanomsg/FairMQPollerNN.cxx +++ b/fairmq/nanomsg/FairMQPollerNN.cxx @@ -81,7 +81,7 @@ FairMQPollerNN::FairMQPollerNN(const unordered_map int index = 0; for (string channel : channelList) { - for (int i = 0; i < channelsMap.at(channel).size(); ++i) + for (unsigned int i = 0; i < channelsMap.at(channel).size(); ++i) { index = fOffsetMap[channel] + i; items[index].fd = channelsMap.at(channel).at(i).fSocket->GetSocket(1); diff --git a/fairmq/nanomsg/FairMQSocketNN.cxx b/fairmq/nanomsg/FairMQSocketNN.cxx index 28204d1f..f5278884 100644 --- a/fairmq/nanomsg/FairMQSocketNN.cxx +++ b/fairmq/nanomsg/FairMQSocketNN.cxx @@ -208,7 +208,7 @@ void* FairMQSocketNN::GetSocket() const return NULL; // dummy method to comply with the interface. functionality not possible in zeromq. } -int FairMQSocketNN::GetSocket(int nothing) const +int FairMQSocketNN::GetSocket(int /*nothing*/) const { return fSocket; } @@ -250,7 +250,7 @@ unsigned long FairMQSocketNN::GetMessagesRx() const return fMessagesRx; } -bool FairMQSocketNN::SetSendTimeout(const int timeout, const string& address, const string& method) +bool FairMQSocketNN::SetSendTimeout(const int timeout, const string& /*address*/, const string& /*method*/) { if (nn_setsockopt(fSocket, NN_SOL_SOCKET, NN_SNDTIMEO, &timeout, sizeof(int)) != 0) { @@ -274,7 +274,7 @@ int FairMQSocketNN::GetSendTimeout() const return timeout; } -bool FairMQSocketNN::SetReceiveTimeout(const int timeout, const string& address, const string& method) +bool FairMQSocketNN::SetReceiveTimeout(const int timeout, const string& /*address*/, const string& /*method*/) { if (nn_setsockopt(fSocket, NN_SOL_SOCKET, NN_RCVTIMEO, &timeout, sizeof(int)) != 0) { diff --git a/fairmq/options/FairMQParser.cxx b/fairmq/options/FairMQParser.cxx index 59bd499b..fc6c5050 100644 --- a/fairmq/options/FairMQParser.cxx +++ b/fairmq/options/FairMQParser.cxx @@ -196,4 +196,4 @@ FairMQMap XML::UserParser(stringstream& input, const string& deviceId, const str return ptreeToMQMap(pt, deviceId, rootNode, "xml"); } -} // end FairMQParser namespace \ No newline at end of file +} // end FairMQParser namespace diff --git a/fairmq/options/FairMQProgOptions.cxx b/fairmq/options/FairMQProgOptions.cxx index 2bcddfe4..b0a114f5 100644 --- a/fairmq/options/FairMQProgOptions.cxx +++ b/fairmq/options/FairMQProgOptions.cxx @@ -20,8 +20,8 @@ using namespace std; FairMQProgOptions::FairMQProgOptions() : FairProgOptions() , fMQParserOptions("MQ-Device parser options") - , fMQOptionsInCmd("MQ-Device options") , fMQOptionsInCfg("MQ-Device options") + , fMQOptionsInCmd("MQ-Device options") , fMQtree() , fFairMQMap() { diff --git a/fairmq/options/FairProgOptions.cxx b/fairmq/options/FairProgOptions.cxx index 9269da87..74c35b54 100644 --- a/fairmq/options/FairProgOptions.cxx +++ b/fairmq/options/FairProgOptions.cxx @@ -19,18 +19,18 @@ using namespace std; /// ////////////////////////////////////////////////////////////////////////////////////////////////////// /// Constructor FairProgOptions::FairProgOptions() : + fVarMap(), fGenericDesc("Generic options description"), fConfigDesc("Configuration options description"), - fHiddenDesc("Hidden options description"), fEnvironmentDesc("Environment variables"), + fHiddenDesc("Hidden options description"), fCmdLineOptions("Command line options"), fConfigFileOptions("Configuration file options"), + fSeverityMap(), fVisibleOptions("Visible options"), fVerboseLvl("INFO"), fUseConfigFile(false), - fConfigFile(), - fVarMap(), - fSeverityMap() + fConfigFile() { fGenericDesc.add_options() ("help,h", "produce help") diff --git a/fairmq/options/ProgOptionTest/lib/FairMQParserExample.cxx b/fairmq/options/ProgOptionTest/lib/FairMQParserExample.cxx index 4df42dc1..bdd74ad5 100644 --- a/fairmq/options/ProgOptionTest/lib/FairMQParserExample.cxx +++ b/fairmq/options/ProgOptionTest/lib/FairMQParserExample.cxx @@ -71,4 +71,4 @@ namespace FairMQParser -} // end FairMQParser namespace \ No newline at end of file +} // end FairMQParser namespace diff --git a/fairmq/run/runSink.cxx b/fairmq/run/runSink.cxx index b4f502ad..f22cf567 100644 --- a/fairmq/run/runSink.cxx +++ b/fairmq/run/runSink.cxx @@ -49,7 +49,7 @@ int main(int argc, char** argv) string filename = config.GetValue("config-json-file"); string id = config.GetValue("id"); - int ioThreads = config.GetValue("io-threads"); +// int ioThreads = config.GetValue("io-threads"); config.UserParser(filename, id); diff --git a/fairmq/run/runSplitter.cxx b/fairmq/run/runSplitter.cxx index ecc50bc3..4b46c3f7 100644 --- a/fairmq/run/runSplitter.cxx +++ b/fairmq/run/runSplitter.cxx @@ -120,7 +120,7 @@ int main(int argc, char** argv) splitter.fChannels["data-in"].push_back(inputChannel); - for (int i = 0; i < options.outputAddress.size(); ++i) + for (unsigned int i = 0; i < options.outputAddress.size(); ++i) { FairMQChannel outputChannel(options.outputSocketType.at(i), options.outputMethod.at(i), options.outputAddress.at(i)); outputChannel.UpdateSndBufSize(options.outputBufSize.at(i)); diff --git a/fairmq/test/pub-sub/runTestPub.cxx b/fairmq/test/pub-sub/runTestPub.cxx index 0af27dda..4057a2b6 100644 --- a/fairmq/test/pub-sub/runTestPub.cxx +++ b/fairmq/test/pub-sub/runTestPub.cxx @@ -15,7 +15,7 @@ #include "FairMQLogger.h" #include "FairMQTestPub.h" -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { FairMQTestPub testPub; testPub.CatchSignals(); diff --git a/fairmq/test/pub-sub/runTestSub.cxx b/fairmq/test/pub-sub/runTestSub.cxx index e66f1154..acf622c3 100644 --- a/fairmq/test/pub-sub/runTestSub.cxx +++ b/fairmq/test/pub-sub/runTestSub.cxx @@ -17,7 +17,7 @@ #include "FairMQLogger.h" #include "FairMQTestSub.h" -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { FairMQTestSub testSub; testSub.CatchSignals(); diff --git a/fairmq/test/push-pull/runTestPull.cxx b/fairmq/test/push-pull/runTestPull.cxx index 12de2a18..0b102569 100644 --- a/fairmq/test/push-pull/runTestPull.cxx +++ b/fairmq/test/push-pull/runTestPull.cxx @@ -15,7 +15,7 @@ #include "FairMQLogger.h" #include "FairMQTestPull.h" -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { FairMQTestPull testPull; testPull.CatchSignals(); diff --git a/fairmq/test/push-pull/runTestPush.cxx b/fairmq/test/push-pull/runTestPush.cxx index 62dcc19c..8077f56e 100644 --- a/fairmq/test/push-pull/runTestPush.cxx +++ b/fairmq/test/push-pull/runTestPush.cxx @@ -15,7 +15,7 @@ #include "FairMQLogger.h" #include "FairMQTestPush.h" -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { FairMQTestPush testPush; testPush.CatchSignals(); diff --git a/fairmq/test/req-rep/runTestRep.cxx b/fairmq/test/req-rep/runTestRep.cxx index ce0abb54..67bba532 100644 --- a/fairmq/test/req-rep/runTestRep.cxx +++ b/fairmq/test/req-rep/runTestRep.cxx @@ -17,7 +17,7 @@ #include "FairMQLogger.h" #include "FairMQTestRep.h" -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { FairMQTestRep testRep; testRep.CatchSignals(); diff --git a/fairmq/test/req-rep/runTestReq.cxx b/fairmq/test/req-rep/runTestReq.cxx index 0715c172..6c56346c 100644 --- a/fairmq/test/req-rep/runTestReq.cxx +++ b/fairmq/test/req-rep/runTestReq.cxx @@ -17,7 +17,7 @@ #include "FairMQLogger.h" #include "FairMQTestReq.h" -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { FairMQTestReq testReq; testReq.CatchSignals(); diff --git a/fairmq/test/runTransferTimeoutTest.cxx b/fairmq/test/runTransferTimeoutTest.cxx index 75e878dd..49862bd8 100644 --- a/fairmq/test/runTransferTimeoutTest.cxx +++ b/fairmq/test/runTransferTimeoutTest.cxx @@ -24,8 +24,8 @@ class TransferTimeoutTester : public FairMQDevice protected: virtual void Run() { - bool setSndOK = false; - bool setRcvOK = false; +// bool setSndOK = false; +// bool setRcvOK = false; bool getSndOK = false; bool getRcvOK = false; bool sendCanceling = false; @@ -87,7 +87,7 @@ class TransferTimeoutTester : public FairMQDevice } }; -int main(int argc, char** argv) +int main(int /*argc*/, char** /*argv*/) { TransferTimeoutTester timeoutTester; timeoutTester.CatchSignals(); diff --git a/fairmq/zeromq/FairMQMessageZMQ.cxx b/fairmq/zeromq/FairMQMessageZMQ.cxx index 6f464e6a..5a6bf85b 100644 --- a/fairmq/zeromq/FairMQMessageZMQ.cxx +++ b/fairmq/zeromq/FairMQMessageZMQ.cxx @@ -99,7 +99,7 @@ void FairMQMessageZMQ::Copy(FairMQMessage* msg) // DEPRECATED: Use Copy(const unique_ptr&) // Shares the message buffer between msg and this fMessage. - if (zmq_msg_copy(&fMessage, (zmq_msg_t*)msg->GetMessage()) != 0) + if (zmq_msg_copy(&fMessage, static_cast(msg->GetMessage())) != 0) { LOG(ERROR) << "failed copying message, reason: " << zmq_strerror(errno); } @@ -115,7 +115,7 @@ void FairMQMessageZMQ::Copy(FairMQMessage* msg) void FairMQMessageZMQ::Copy(const unique_ptr& msg) { // Shares the message buffer between msg and this fMessage. - if (zmq_msg_copy(&fMessage, (zmq_msg_t*)msg->GetMessage()) != 0) + if (zmq_msg_copy(&fMessage, static_cast(msg->GetMessage())) != 0) { LOG(ERROR) << "failed copying message, reason: " << zmq_strerror(errno); } @@ -147,4 +147,4 @@ FairMQMessageZMQ::~FairMQMessageZMQ() { LOG(ERROR) << "failed closing message with data, reason: " << zmq_strerror(errno); } -} \ No newline at end of file +}