From ce58ee2302f942a500abcbb1151e119df6939ebb Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Fri, 2 Jan 2015 14:04:33 +0100 Subject: [PATCH] Fix warnings produced with -Weffc++ in fairmq, base/MQ and Tutorial3. Remaining warnings originate from boost::msm and boost::mpl. Also, warnings with missing initializer list entries for DeviceOptions are false positives, since those are PODs. --- fairmq/FairMQConfigurable.h | 2 +- fairmq/FairMQDevice.cxx | 19 ++++++++++++++++--- fairmq/FairMQDevice.h | 12 ++++++------ fairmq/FairMQLogger.cxx | 13 +++++-------- fairmq/FairMQLogger.h | 2 +- fairmq/FairMQSocket.h | 3 +-- fairmq/FairMQStateMachine.cxx | 6 +++--- fairmq/FairMQStateMachine.h | 18 +++++++++++++----- fairmq/FairMQTransportFactory.h | 2 +- fairmq/devices/FairMQBenchmarkSampler.h | 1 + .../examples/req-rep/FairMQExampleClient.cxx | 1 + fairmq/examples/req-rep/runExampleClient.cxx | 2 +- fairmq/nanomsg/FairMQMessageNN.cxx | 14 +++++++++++--- fairmq/nanomsg/FairMQMessageNN.h | 4 ++++ fairmq/nanomsg/FairMQPollerNN.cxx | 2 ++ fairmq/nanomsg/FairMQPollerNN.h | 6 +++++- fairmq/nanomsg/FairMQSocketNN.cxx | 4 +++- fairmq/prototest/FairMQProtoSampler.cxx | 2 +- fairmq/prototest/FairMQProtoSampler.h | 2 ++ fairmq/run/runBenchmarkSampler.cxx | 2 +- fairmq/run/runBinSampler.cxx | 2 +- fairmq/run/runBinSink.cxx | 2 +- fairmq/run/runBuffer.cxx | 2 +- fairmq/run/runMerger.cxx | 2 +- fairmq/run/runProtoSampler.cxx | 2 +- fairmq/run/runProtoSink.cxx | 2 +- fairmq/run/runProxy.cxx | 2 +- fairmq/run/runSink.cxx | 2 +- fairmq/run/runSplitter.cxx | 2 +- fairmq/zeromq/FairMQContextZMQ.cxx | 1 + fairmq/zeromq/FairMQContextZMQ.h | 7 +++++++ fairmq/zeromq/FairMQMessageZMQ.cxx | 7 ++++++- fairmq/zeromq/FairMQPollerZMQ.cxx | 2 ++ fairmq/zeromq/FairMQPollerZMQ.h | 6 +++++- fairmq/zeromq/FairMQSocketZMQ.cxx | 4 +++- fairmq/zeromq/FairMQSocketZMQ.h | 4 ++++ 36 files changed, 116 insertions(+), 50 deletions(-) diff --git a/fairmq/FairMQConfigurable.h b/fairmq/FairMQConfigurable.h index 3160fa09..55524b9c 100644 --- a/fairmq/FairMQConfigurable.h +++ b/fairmq/FairMQConfigurable.h @@ -17,7 +17,7 @@ #include -using std::string; +using namespace std; class FairMQConfigurable { diff --git a/fairmq/FairMQDevice.cxx b/fairmq/FairMQDevice.cxx index 042c236f..935b846b 100644 --- a/fairmq/FairMQDevice.cxx +++ b/fairmq/FairMQDevice.cxx @@ -19,9 +19,22 @@ #include "FairMQLogger.h" FairMQDevice::FairMQDevice() - : fNumIoThreads(1) + : fId() + , fNumIoThreads(1) , fNumInputs(0) , fNumOutputs(0) + , fInputAddress() + , fInputMethod() + , fInputSocketType() + , fInputSndBufSize() + , fInputRcvBufSize() + , fLogInputRate() + , fOutputAddress() + , fOutputMethod() + , fOutputSocketType() + , fOutputSndBufSize() + , fOutputRcvBufSize() + , fLogOutputRate() , fPayloadInputs(new vector()) , fPayloadOutputs(new vector()) , fLogIntervalInMs(1000) @@ -78,7 +91,7 @@ void FairMQDevice::InitInput() fPayloadInputs->at(i)->Connect(fInputAddress.at(i)); } } - catch (std::out_of_range& e) + catch (out_of_range& e) { LOG(ERROR) << e.what(); } @@ -109,7 +122,7 @@ void FairMQDevice::InitOutput() fPayloadOutputs->at(i)->Connect(fOutputAddress.at(i)); } } - catch (std::out_of_range& e) + catch (out_of_range& e) { LOG(ERROR) << e.what(); } diff --git a/fairmq/FairMQDevice.h b/fairmq/FairMQDevice.h index 32086e1a..9402cd82 100644 --- a/fairmq/FairMQDevice.h +++ b/fairmq/FairMQDevice.h @@ -24,10 +24,7 @@ #include "FairMQTransportFactory.h" #include "FairMQSocket.h" -using std::vector; -using std::cin; -using std::cout; -using std::endl; +using namespace std; class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable { @@ -92,8 +89,6 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable vector* fPayloadInputs; vector* fPayloadOutputs; - FairMQSocket* fCommandSocket; - int fLogIntervalInMs; FairMQTransportFactory* fTransportFactory; @@ -106,6 +101,11 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable virtual void InitInput(); virtual void Terminate(); + + private: + /// Copy Constructor + FairMQDevice(const FairMQDevice&); + FairMQDevice operator=(const FairMQDevice&); }; #endif /* FAIRMQDEVICE_H_ */ diff --git a/fairmq/FairMQLogger.cxx b/fairmq/FairMQLogger.cxx index 21e80832..82e0f207 100644 --- a/fairmq/FairMQLogger.cxx +++ b/fairmq/FairMQLogger.cxx @@ -17,11 +17,8 @@ #include "FairMQLogger.h" -using std::string; -using std::cout; -using std::endl; - FairMQLogger::FairMQLogger() + : os() { } @@ -30,7 +27,7 @@ FairMQLogger::~FairMQLogger() cout << os.str() << endl; } -std::ostringstream& FairMQLogger::Log(int type) +ostringstream& FairMQLogger::Log(int type) { string type_str; switch (type) @@ -56,10 +53,10 @@ std::ostringstream& FairMQLogger::Log(int type) timestamp_t tm = get_timestamp(); timestamp_t ms = tm / 1000.0L; timestamp_t s = ms / 1000.0L; - std::time_t t = s; - // std::size_t fractional_seconds = ms % 1000; + time_t t = s; + // size_t fractional_seconds = ms % 1000; char mbstr[100]; - std::strftime(mbstr, 100, "%H:%M:%S", std::localtime(&t)); + strftime(mbstr, 100, "%H:%M:%S", localtime(&t)); os << "[\033[01;36m" << mbstr << "\033[0m]" << "[" << type_str << "]" diff --git a/fairmq/FairMQLogger.h b/fairmq/FairMQLogger.h index 2846622f..dd75a3e8 100644 --- a/fairmq/FairMQLogger.h +++ b/fairmq/FairMQLogger.h @@ -21,7 +21,7 @@ #include #include -using std::ostringstream; +using namespace std; class FairMQLogger { diff --git a/fairmq/FairMQSocket.h b/fairmq/FairMQSocket.h index 79c15102..5591d453 100644 --- a/fairmq/FairMQSocket.h +++ b/fairmq/FairMQSocket.h @@ -18,8 +18,7 @@ #include #include "FairMQMessage.h" -using std::string; -using std::stringstream; +using namespace std; class FairMQSocket { diff --git a/fairmq/FairMQStateMachine.cxx b/fairmq/FairMQStateMachine.cxx index 44547645..6addff9b 100644 --- a/fairmq/FairMQStateMachine.cxx +++ b/fairmq/FairMQStateMachine.cxx @@ -17,6 +17,8 @@ FairMQStateMachine::FairMQStateMachine() : fRunningFinished(false) + , fRunningCondition() + , fRunningMutex() { start(); } @@ -59,6 +61,4 @@ void FairMQStateMachine::ChangeState(int event) { LOG(ERROR) << e.what(); } - - - } +} diff --git a/fairmq/FairMQStateMachine.h b/fairmq/FairMQStateMachine.h index 701f8e97..9d7fdb38 100644 --- a/fairmq/FairMQStateMachine.h +++ b/fairmq/FairMQStateMachine.h @@ -47,6 +47,14 @@ namespace FairMQFSM // defining the boost MSM state machine struct FairMQFSM_ : public msm::front::state_machine_def { + FairMQFSM_() + : fState() + , fRunningStateThread() + {} + + // Destructor + virtual ~FairMQFSM_() {}; + template void on_entry(Event const&, FSM&) { @@ -109,7 +117,7 @@ namespace FairMQFSM void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&) { fsm.fState = RUNNING; - fsm.running_state = boost::thread(boost::bind(&FairMQFSM_::Run, &fsm)); + fsm.fRunningStateThread = boost::thread(boost::bind(&FairMQFSM_::Run, &fsm)); } }; struct StopFct @@ -119,7 +127,7 @@ namespace FairMQFSM { fsm.fState = IDLE; fsm.Terminate(); - fsm.running_state.join(); + fsm.fRunningStateThread.join(); } }; struct PauseFct @@ -128,7 +136,7 @@ namespace FairMQFSM void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&) { fsm.fState = WAITING; - fsm.running_state.join(); + fsm.fRunningStateThread.join(); fsm.Pause(); } }; @@ -160,10 +168,10 @@ namespace FairMQFSM template void no_transition(Event const& e, FSM&, int state) { - LOG(STATE) << "no transition from state " << state << " on event " << typeid(e).name() << std::endl; + LOG(STATE) << "no transition from state " << state << " on event " << typeid(e).name(); } // this is to run certain functions (e.g. Run()) as separate task - boost::thread running_state; + boost::thread fRunningStateThread; // backward compatibility to FairMQStateMachine enum State { diff --git a/fairmq/FairMQTransportFactory.h b/fairmq/FairMQTransportFactory.h index daeed2d5..339fada1 100644 --- a/fairmq/FairMQTransportFactory.h +++ b/fairmq/FairMQTransportFactory.h @@ -22,7 +22,7 @@ #include "FairMQPoller.h" #include "FairMQLogger.h" -using std::vector; +using namespace std; class FairMQTransportFactory { diff --git a/fairmq/devices/FairMQBenchmarkSampler.h b/fairmq/devices/FairMQBenchmarkSampler.h index 2c59688c..eafe63fe 100644 --- a/fairmq/devices/FairMQBenchmarkSampler.h +++ b/fairmq/devices/FairMQBenchmarkSampler.h @@ -46,6 +46,7 @@ class FairMQBenchmarkSampler : public FairMQDevice int fEventSize; int fEventRate; int fEventCounter; + virtual void Init(); virtual void Run(); }; diff --git a/fairmq/examples/req-rep/FairMQExampleClient.cxx b/fairmq/examples/req-rep/FairMQExampleClient.cxx index 387d41ab..7559a25a 100644 --- a/fairmq/examples/req-rep/FairMQExampleClient.cxx +++ b/fairmq/examples/req-rep/FairMQExampleClient.cxx @@ -19,6 +19,7 @@ #include "FairMQLogger.h" FairMQExampleClient::FairMQExampleClient() + : fText() { } diff --git a/fairmq/examples/req-rep/runExampleClient.cxx b/fairmq/examples/req-rep/runExampleClient.cxx index 0499ed19..d75952ae 100644 --- a/fairmq/examples/req-rep/runExampleClient.cxx +++ b/fairmq/examples/req-rep/runExampleClient.cxx @@ -59,7 +59,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/nanomsg/FairMQMessageNN.cxx b/fairmq/nanomsg/FairMQMessageNN.cxx index f804fc7a..76b53a64 100644 --- a/fairmq/nanomsg/FairMQMessageNN.cxx +++ b/fairmq/nanomsg/FairMQMessageNN.cxx @@ -20,14 +20,19 @@ #include "FairMQMessageNN.h" #include "FairMQLogger.h" +using namespace std; + FairMQMessageNN::FairMQMessageNN() - : fSize(0) - , fMessage(NULL) + : fMessage(NULL) + , fSize(0) , fReceiving(false) { } FairMQMessageNN::FairMQMessageNN(size_t size) + : fMessage(NULL) + , fSize(0) + , fReceiving(false) { fMessage = nn_allocmsg(size, 0); if (!fMessage) @@ -45,6 +50,9 @@ FairMQMessageNN::FairMQMessageNN(size_t size) * possible TODO: make this zero copy (will should then be as efficient as ZeroMQ). */ FairMQMessageNN::FairMQMessageNN(void* data, size_t size, fairmq_free_fn *ffn, void* hint) + : fMessage(NULL) + , fSize(0) + , fReceiving(false) { fMessage = nn_allocmsg(size, 0); if (!fMessage) @@ -146,7 +154,7 @@ void FairMQMessageNN::Copy(FairMQMessage* msg) { LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno); } - std::memcpy(fMessage, msg->GetMessage(), size); + memcpy(fMessage, msg->GetMessage(), size); fSize = size; } diff --git a/fairmq/nanomsg/FairMQMessageNN.h b/fairmq/nanomsg/FairMQMessageNN.h index b59b01b1..45ec4123 100644 --- a/fairmq/nanomsg/FairMQMessageNN.h +++ b/fairmq/nanomsg/FairMQMessageNN.h @@ -49,6 +49,10 @@ class FairMQMessageNN : public FairMQMessage bool fReceiving; void Clear(); + + /// Copy Constructor + FairMQMessageNN(const FairMQMessageNN&); + FairMQMessageNN operator=(const FairMQMessageNN&); }; #endif /* FAIRMQMESSAGENN_H_ */ diff --git a/fairmq/nanomsg/FairMQPollerNN.cxx b/fairmq/nanomsg/FairMQPollerNN.cxx index 4aa0c2b2..697992f4 100644 --- a/fairmq/nanomsg/FairMQPollerNN.cxx +++ b/fairmq/nanomsg/FairMQPollerNN.cxx @@ -17,6 +17,8 @@ #include "FairMQPollerNN.h" FairMQPollerNN::FairMQPollerNN(const vector& inputs) + : items() + , fNumItems() { fNumItems = inputs.size(); items = new nn_pollfd[fNumItems]; diff --git a/fairmq/nanomsg/FairMQPollerNN.h b/fairmq/nanomsg/FairMQPollerNN.h index 7cc9d2bc..6e32f06d 100644 --- a/fairmq/nanomsg/FairMQPollerNN.h +++ b/fairmq/nanomsg/FairMQPollerNN.h @@ -20,7 +20,7 @@ #include "FairMQPoller.h" #include "FairMQSocket.h" -using std::vector; +using namespace std; class FairMQPollerNN : public FairMQPoller { @@ -36,6 +36,10 @@ class FairMQPollerNN : public FairMQPoller private: nn_pollfd* items; int fNumItems; + + /// Copy Constructor + FairMQPollerNN(const FairMQPollerNN&); + FairMQPollerNN operator=(const FairMQPollerNN&); }; #endif /* FAIRMQPOLLERNN_H_ */ \ No newline at end of file diff --git a/fairmq/nanomsg/FairMQSocketNN.cxx b/fairmq/nanomsg/FairMQSocketNN.cxx index f3d76810..585f57c3 100644 --- a/fairmq/nanomsg/FairMQSocketNN.cxx +++ b/fairmq/nanomsg/FairMQSocketNN.cxx @@ -19,7 +19,9 @@ #include "FairMQLogger.h" FairMQSocketNN::FairMQSocketNN(const string& type, int num, int numIoThreads) - : fBytesTx(0) + : fSocket() + , fId() + , fBytesTx(0) , fBytesRx(0) , fMessagesTx(0) , fMessagesRx(0) diff --git a/fairmq/prototest/FairMQProtoSampler.cxx b/fairmq/prototest/FairMQProtoSampler.cxx index 2959d532..0e272d99 100644 --- a/fairmq/prototest/FairMQProtoSampler.cxx +++ b/fairmq/prototest/FairMQProtoSampler.cxx @@ -65,7 +65,7 @@ void FairMQProtoSampler::Run() // LOG(INFO) << content->x() << " " << content->y() << " " << content->z() << " " << content->a() << " " << content->b(); } - std::string str; + string str; p.SerializeToString(&str); size_t size = str.length(); diff --git a/fairmq/prototest/FairMQProtoSampler.h b/fairmq/prototest/FairMQProtoSampler.h index 065e2b00..7340e355 100644 --- a/fairmq/prototest/FairMQProtoSampler.h +++ b/fairmq/prototest/FairMQProtoSampler.h @@ -19,6 +19,8 @@ #include "FairMQDevice.h" +using namespace std; + class FairMQProtoSampler : public FairMQDevice { public: diff --git a/fairmq/run/runBenchmarkSampler.cxx b/fairmq/run/runBenchmarkSampler.cxx index 51351eb0..b055000e 100644 --- a/fairmq/run/runBenchmarkSampler.cxx +++ b/fairmq/run/runBenchmarkSampler.cxx @@ -66,7 +66,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runBinSampler.cxx b/fairmq/run/runBinSampler.cxx index cfd704fc..d7778003 100644 --- a/fairmq/run/runBinSampler.cxx +++ b/fairmq/run/runBinSampler.cxx @@ -66,7 +66,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runBinSink.cxx b/fairmq/run/runBinSink.cxx index 9fbd308a..50902b08 100644 --- a/fairmq/run/runBinSink.cxx +++ b/fairmq/run/runBinSink.cxx @@ -64,7 +64,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runBuffer.cxx b/fairmq/run/runBuffer.cxx index 0c2475f7..4c8df834 100644 --- a/fairmq/run/runBuffer.cxx +++ b/fairmq/run/runBuffer.cxx @@ -68,7 +68,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runMerger.cxx b/fairmq/run/runMerger.cxx index a6bc874e..8aad32be 100644 --- a/fairmq/run/runMerger.cxx +++ b/fairmq/run/runMerger.cxx @@ -69,7 +69,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runProtoSampler.cxx b/fairmq/run/runProtoSampler.cxx index eccd0777..b4b15f6f 100644 --- a/fairmq/run/runProtoSampler.cxx +++ b/fairmq/run/runProtoSampler.cxx @@ -66,7 +66,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runProtoSink.cxx b/fairmq/run/runProtoSink.cxx index 6b99f526..91bcc7e6 100644 --- a/fairmq/run/runProtoSink.cxx +++ b/fairmq/run/runProtoSink.cxx @@ -64,7 +64,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runProxy.cxx b/fairmq/run/runProxy.cxx index 640d65b4..d50c1db4 100644 --- a/fairmq/run/runProxy.cxx +++ b/fairmq/run/runProxy.cxx @@ -68,7 +68,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runSink.cxx b/fairmq/run/runSink.cxx index 8e9de458..eef07e45 100644 --- a/fairmq/run/runSink.cxx +++ b/fairmq/run/runSink.cxx @@ -64,7 +64,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/run/runSplitter.cxx b/fairmq/run/runSplitter.cxx index 932eb27b..452300e2 100644 --- a/fairmq/run/runSplitter.cxx +++ b/fairmq/run/runSplitter.cxx @@ -69,7 +69,7 @@ typedef struct DeviceOptions inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options) { if (_options == NULL) - throw std::runtime_error("Internal error: options' container is empty."); + throw runtime_error("Internal error: options' container is empty."); namespace bpo = boost::program_options; bpo::options_description desc("Options"); diff --git a/fairmq/zeromq/FairMQContextZMQ.cxx b/fairmq/zeromq/FairMQContextZMQ.cxx index f43203e4..d18d851d 100644 --- a/fairmq/zeromq/FairMQContextZMQ.cxx +++ b/fairmq/zeromq/FairMQContextZMQ.cxx @@ -17,6 +17,7 @@ #include FairMQContextZMQ::FairMQContextZMQ(int numIoThreads) + : fContext() { fContext = zmq_ctx_new(); if (fContext == NULL) diff --git a/fairmq/zeromq/FairMQContextZMQ.h b/fairmq/zeromq/FairMQContextZMQ.h index 76b5ef60..6dc3b8e5 100644 --- a/fairmq/zeromq/FairMQContextZMQ.h +++ b/fairmq/zeromq/FairMQContextZMQ.h @@ -20,13 +20,20 @@ class FairMQContextZMQ { public: + + /// Constructor FairMQContextZMQ(int numIoThreads); + virtual ~FairMQContextZMQ(); void* GetContext(); void Close(); private: void* fContext; + + /// Copy Constructor + FairMQContextZMQ(const FairMQContextZMQ&); + FairMQContextZMQ operator=(const FairMQContextZMQ&); }; #endif /* FAIRMQCONTEXTZMQ_H_ */ diff --git a/fairmq/zeromq/FairMQMessageZMQ.cxx b/fairmq/zeromq/FairMQMessageZMQ.cxx index 147926ba..63abdd58 100644 --- a/fairmq/zeromq/FairMQMessageZMQ.cxx +++ b/fairmq/zeromq/FairMQMessageZMQ.cxx @@ -18,7 +18,10 @@ #include "FairMQMessageZMQ.h" #include "FairMQLogger.h" +using namespace std; + FairMQMessageZMQ::FairMQMessageZMQ() + : fMessage() { int rc = zmq_msg_init(&fMessage); if (rc != 0) @@ -28,6 +31,7 @@ FairMQMessageZMQ::FairMQMessageZMQ() } FairMQMessageZMQ::FairMQMessageZMQ(size_t size) + : fMessage() { int rc = zmq_msg_init_size(&fMessage, size); if (rc != 0) @@ -37,6 +41,7 @@ FairMQMessageZMQ::FairMQMessageZMQ(size_t size) } FairMQMessageZMQ::FairMQMessageZMQ(void* data, size_t size, fairmq_free_fn *ffn, void* hint) + : fMessage() { int rc = zmq_msg_init_data(&fMessage, data, size, ffn ? ffn : &CleanUp, hint); if (rc != 0) @@ -109,7 +114,7 @@ void FairMQMessageZMQ::Copy(FairMQMessage* msg) // CloseMessage(); // size_t size = msg->GetSize(); // zmq_msg_init_size(&fMessage, size); - // std::memcpy(zmq_msg_data(&fMessage), msg->GetData(), size); + // memcpy(zmq_msg_data(&fMessage), msg->GetData(), size); } inline void FairMQMessageZMQ::CloseMessage() diff --git a/fairmq/zeromq/FairMQPollerZMQ.cxx b/fairmq/zeromq/FairMQPollerZMQ.cxx index 0292e67d..769d8fd7 100644 --- a/fairmq/zeromq/FairMQPollerZMQ.cxx +++ b/fairmq/zeromq/FairMQPollerZMQ.cxx @@ -18,6 +18,8 @@ #include "FairMQLogger.h" FairMQPollerZMQ::FairMQPollerZMQ(const vector& inputs) + : items() + , fNumItems() { fNumItems = inputs.size(); items = new zmq_pollitem_t[fNumItems]; diff --git a/fairmq/zeromq/FairMQPollerZMQ.h b/fairmq/zeromq/FairMQPollerZMQ.h index d76c42f3..121f40a6 100644 --- a/fairmq/zeromq/FairMQPollerZMQ.h +++ b/fairmq/zeromq/FairMQPollerZMQ.h @@ -20,7 +20,7 @@ #include "FairMQPoller.h" #include "FairMQSocket.h" -using std::vector; +using namespace std; class FairMQPollerZMQ : public FairMQPoller { @@ -36,6 +36,10 @@ class FairMQPollerZMQ : public FairMQPoller private: zmq_pollitem_t* items; int fNumItems; + + /// Copy Constructor + FairMQPollerZMQ(const FairMQPollerZMQ&); + FairMQPollerZMQ operator=(const FairMQPollerZMQ&); }; #endif /* FAIRMQPOLLERZMQ_H_ */ \ No newline at end of file diff --git a/fairmq/zeromq/FairMQSocketZMQ.cxx b/fairmq/zeromq/FairMQSocketZMQ.cxx index efdff2c9..87eebadc 100644 --- a/fairmq/zeromq/FairMQSocketZMQ.cxx +++ b/fairmq/zeromq/FairMQSocketZMQ.cxx @@ -20,7 +20,9 @@ boost::shared_ptr FairMQSocketZMQ::fContext = boost::shared_ptr(new FairMQContextZMQ(1)); FairMQSocketZMQ::FairMQSocketZMQ(const string& type, int num, int numIoThreads) - : fBytesTx(0) + : fSocket(NULL) + , fId() + , fBytesTx(0) , fBytesRx(0) , fMessagesTx(0) , fMessagesRx(0) diff --git a/fairmq/zeromq/FairMQSocketZMQ.h b/fairmq/zeromq/FairMQSocketZMQ.h index 77ae2ed6..23a3441b 100644 --- a/fairmq/zeromq/FairMQSocketZMQ.h +++ b/fairmq/zeromq/FairMQSocketZMQ.h @@ -61,6 +61,10 @@ class FairMQSocketZMQ : public FairMQSocket unsigned long fMessagesRx; static boost::shared_ptr fContext; + + /// Copy Constructor + FairMQSocketZMQ(const FairMQSocketZMQ&); + FairMQSocketZMQ operator=(const FairMQSocketZMQ&); }; #endif /* FAIRMQSOCKETZMQ_H_ */