aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-10-29 16:06:11 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-10-29 16:06:11 +0100
commit09bd8f26cb37b58310ce16bf7b8b6003b4244ed5 (patch)
tree3f6b0c1e62f13e610611240ddfbe366fce98d3a3
parentbf82967d4c04946ae6e0490ea28e160a856fc81b (diff)
downloaddabmux-09bd8f26cb37b58310ce16bf7b8b6003b4244ed5.tar.gz
dabmux-09bd8f26cb37b58310ce16bf7b8b6003b4244ed5.tar.bz2
dabmux-09bd8f26cb37b58310ce16bf7b8b6003b4244ed5.zip
Some fixes for issues seen with cppcheck
-rw-r--r--src/ClockTAI.h2
-rw-r--r--src/InetAddress.cpp16
-rw-r--r--src/InetAddress.h2
-rw-r--r--src/RemoteControl.cpp2
-rw-r--r--src/RemoteControl.h7
5 files changed, 7 insertions, 22 deletions
diff --git a/src/ClockTAI.h b/src/ClockTAI.h
index ac4978c..e0dc439 100644
--- a/src/ClockTAI.h
+++ b/src/ClockTAI.h
@@ -78,7 +78,7 @@ class ClockTAI : public RemoteControllable {
mutable std::mutex m_data_mutex;
// The currently used TAI-UTC offset
- int m_offset;
+ int m_offset = 0;
int m_offset_valid = false;
mutable std::stringstream m_bulletin;
diff --git a/src/InetAddress.cpp b/src/InetAddress.cpp
index d92e1b9..7660263 100644
--- a/src/InetAddress.cpp
+++ b/src/InetAddress.cpp
@@ -63,22 +63,6 @@ InetAddress::InetAddress(int port, const char* name) {
}
-/**
- * Constructs a copy of inet
- * @param inet The address to be copied
- */
-InetAddress::InetAddress(const InetAddress &inet) {
- TRACE_CLASS("InetAddress", "InetAddress(InetAddress)");
- memcpy(&addr, &inet.addr, sizeof(addr));
-}
-
-
-/// Destructor
-InetAddress::~InetAddress() {
- TRACE_CLASS("InetAddress" ,"~InetAddress()");
-}
-
-
/// Returns the raw IP address of this InetAddress object.
sockaddr *InetAddress::getAddress() {
TRACE_CLASS("InetAddress", "getAddress()");
diff --git a/src/InetAddress.h b/src/InetAddress.h
index 0ccc70b..e246d4c 100644
--- a/src/InetAddress.h
+++ b/src/InetAddress.h
@@ -62,8 +62,6 @@ void setInetError(const char* description);
class InetAddress {
public:
InetAddress(int port = 0, const char* name = NULL);
- InetAddress(const InetAddress &addr);
- ~InetAddress();
sockaddr *getAddress();
const char *getHostAddress();
diff --git a/src/RemoteControl.cpp b/src/RemoteControl.cpp
index 517d99e..18c74b7 100644
--- a/src/RemoteControl.cpp
+++ b/src/RemoteControl.cpp
@@ -52,7 +52,7 @@ RemoteControllerTelnet::~RemoteControllerTelnet()
}
}
-void RemoteControllerTelnet::restart()
+void RemoteControllerTelnet::internal_restart()
{
if (m_restarter_thread.joinable()) {
m_restarter_thread.join();
diff --git a/src/RemoteControl.h b/src/RemoteControl.h
index b133a8f..7fc8e04 100644
--- a/src/RemoteControl.h
+++ b/src/RemoteControl.h
@@ -210,7 +210,9 @@ class RemoteControllerTelnet : public BaseRemoteController {
m_fault(false),
m_port(port)
{
- restart();
+ // Don't call virtual functions from the ctor
+ // https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors
+ internal_restart();
}
@@ -221,9 +223,10 @@ class RemoteControllerTelnet : public BaseRemoteController {
virtual bool fault_detected() { return m_fault; }
- virtual void restart();
+ virtual void restart() { internal_restart(); }
private:
+ void internal_restart();
void restart_thread(long);
void process(long);