From 0f0049f0cd1800fa63a6c3a028418f00264ec3d8 Mon Sep 17 00:00:00 2001
From: "m.marn" <matic.marn@cosylab.com>
Date: Tue, 21 Mar 2023 13:17:48 +0100
Subject: [PATCH] Fix most of the compilation warnings.

---
 .../interface/communication/CNVConnection.cpp |   2 +-
 .../interface/communication/MBConnection.cpp  |   6 +-
 .../communication/SNAP7Connection.cpp         |   4 +-
 .../interface/communication/SNAP7Utils.cpp    |   8 +-
 .../interface/communication/SNAP7Utils.h      |   4 +-
 .../communication/SilecsConnection.cpp        |  10 +-
 .../communication/SilecsConnection.h          |   2 +-
 .../interface/core/PLCSendAction.cpp          | 100 +++++++++---------
 .../interface/core/SilecsService.cpp          |   2 +-
 .../interface/equipment/PLCRegister.cpp       |   5 +-
 .../interface/equipment/SilecsRegister.cpp    |   2 +-
 .../interface/utility/Condition.cpp           |  10 +-
 .../interface/utility/Mutex.cpp               |  14 +--
 .../interface/utility/SilecsException.cpp     |   5 +-
 .../interface/utility/SilecsException.h       |   2 +-
 .../interface/utility/SilecsLog.cpp           |   2 +-
 .../interface/utility/Thread.h                |   4 +-
 .../interface/utility/TimeStamp.cpp           |   3 +
 .../interface/utility/XMLParser.cpp           |   2 +-
 19 files changed, 94 insertions(+), 93 deletions(-)

diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/CNVConnection.cpp b/silecs-communication-cpp/src/silecs-communication/interface/communication/CNVConnection.cpp
index e326999..9315ca2 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/communication/CNVConnection.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/CNVConnection.cpp
@@ -25,7 +25,7 @@ namespace Silecs
 {
 
 CNVConnection::CNVConnection(PLC* thePLC) :
-                Connection(thePLC)
+                Connection{}
 {
     LOG(ALLOC) << "CNVConnection (create): " << thePLC->getName();
 }
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/MBConnection.cpp b/silecs-communication-cpp/src/silecs-communication/interface/communication/MBConnection.cpp
index f4d5eb9..a21bba4 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/communication/MBConnection.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/MBConnection.cpp
@@ -28,7 +28,7 @@ namespace Silecs
 {
 
 MBConnection::MBConnection(PLC *thePLC) :
-                Connection(thePLC)
+                Connection{}
 {
     LOG(ALLOC) << "MBConnection (create): " << thePLC->getName();
 
@@ -61,14 +61,14 @@ MBConnection::~MBConnection()
     modbus_free(readCtx_);
 }
 
-bool MBConnection::open(PLC *thePLC)
+bool MBConnection::open(PLC*)
 {
     int readErr = modbus_connect(readCtx_);
     int writeErr = modbus_connect(writeCtx_);
     return ( (readErr != -1) && (writeErr != -1));
 }
 
-bool MBConnection::close(PLC *thePLC)
+bool MBConnection::close(PLC*)
 {
     modbus_close(readCtx_);
     modbus_close(writeCtx_);
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp
index c87d078..35d3ab1 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Connection.cpp
@@ -24,7 +24,7 @@ namespace Silecs
 {
 
 SNAP7Connection::SNAP7Connection(PLC* thePLC) :
-                Connection(thePLC)
+                Connection{}
 {
     rackNb_ = 0; //rackNb - common rack is 0 so far
     slotNb_ = -1; //slotNb - depends on hardware configuration (scan is required the first connect)
@@ -97,7 +97,7 @@ bool SNAP7Connection::open(PLC* thePLC)
     return (ret);
 }
 
-bool SNAP7Connection::close(PLC* thePLC)
+bool SNAP7Connection::close(PLC*)
 {
     bool ret = (Cli_Disconnect(recvClient_) == 0) && (Cli_Disconnect(sendClient_) == 0);
     return ret;
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.cpp b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.cpp
index 2307cfe..3ccd0ce 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.cpp
@@ -9,22 +9,20 @@
 // Helper GET routines
 //==============================================================================
 
-bool GetBitAt(void *Buffer, int Pos, int Bit)
+bool GetBitAt(void *Buffer, unsigned long Pos, unsigned long Bit)
 {
     byte Mask[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
-    if (Bit < 0) Bit = 0;
     if (Bit > 7) Bit = 7;
-    return (*(pbyte(Buffer)+Pos) & Mask[Bit]) != 0;
+    return (*(pbyte(Buffer) + Pos) & Mask[Bit]) != 0;
 }
 
 //==============================================================================
 // Helper SET routines
 //==============================================================================
-void SetBitAt(void *Buffer, int Pos, int Bit, bool Value)
+void SetBitAt(void *Buffer, unsigned long Pos, unsigned long Bit, bool Value)
 {
     byte Mask[] = {0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
     pbyte p = pbyte(Buffer)+Pos;
-    if (Bit < 0) Bit = 0;
     if (Bit > 7) Bit = 7;
     (Value) ? *p |= Mask[Bit] : *p &= ~Mask[Bit];
 }
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.h b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.h
index e10f10f..5be3e6e 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.h
+++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SNAP7Utils.h
@@ -6,9 +6,9 @@
 //  They were no accessible in SNAP7 version 1.4.x
 //******************************************************************************
 // GET 
-bool GetBitAt(void *Buffer, int Pos, int Bit);
+bool GetBitAt(void *Buffer, unsigned long Pos, unsigned long Bit);
 // SET
-void SetBitAt(void *Buffer, int Pos, int Bit, bool Value);
+void SetBitAt(void *Buffer, unsigned long Pos, unsigned long Bit, bool Value);
 
 
 
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp
index 3e2451c..b1f7810 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.cpp
@@ -27,7 +27,7 @@ namespace Silecs
 bool Connection::isAlive_ = false;
 
 //------------------------------------------------------------------------------------------------------------------------------------------------
-Connection::Connection(PLC* thePLC)
+Connection::Connection()
 {
     // Start the PLC Thread
     readMux_ = new Mutex("readMux");
@@ -243,25 +243,25 @@ bool Connection::isConnected()
 }
 
 //-------------------------------------------------------------------------------------------------------------------
-int Connection::readUnitCode(PLC* thePLC, UnitCodeType& dataStruct)
+int Connection::readUnitCode(PLC* thePLC, UnitCodeType&)
 {
     throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
     return -1;
 }
 
-int Connection::readUnitStatus(PLC* thePLC, UnitStatusType& dataStruct)
+int Connection::readUnitStatus(PLC* thePLC, UnitStatusType&)
 {
     throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
     return -1;
 }
 
-int Connection::readCPUInfo(PLC* thePLC, CPUInfoType& dataStruct)
+int Connection::readCPUInfo(PLC* thePLC, CPUInfoType&)
 {
     throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
     return -1;
 }
 
-int Connection::readCPInfo(PLC* thePLC, CPInfoType& dataStruct)
+int Connection::readCPInfo(PLC* thePLC, CPInfoType&)
 {
     throw SilecsException(__FILE__, __LINE__, DIAG_PLC_REPORT_NOT_SUPPORTED, thePLC->getName());
     return -1;
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h
index f55e79f..88796f5 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h
+++ b/silecs-communication-cpp/src/silecs-communication/interface/communication/SilecsConnection.h
@@ -45,7 +45,7 @@ class Connection
 {
 
 public:
-    Connection(PLC* thePLC);
+    Connection();
     virtual ~Connection();
 
     virtual int readMemory(PLC* thePLC, long address, unsigned long offset, unsigned long size, unsigned char* buffer) = 0;
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/core/PLCSendAction.cpp b/silecs-communication-cpp/src/silecs-communication/interface/core/PLCSendAction.cpp
index 8e5dfb5..8c6124e 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/core/PLCSendAction.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/core/PLCSendAction.cpp
@@ -94,27 +94,27 @@ int PLCSendBlockMode::execute(Context* pContext)
                 {
                     case AccessArea::Digital:
                         errorCode = pConn->writeDIO(theBlock_->getPLC(), usedAddress, //Base address (or DBn) of the block
-                        usedDeviceOffset, //Device data address within the block
-                        usedSize, //Set one device-block only
-                        pBuffer //Buffer which contain the data
-                        );
+                            usedDeviceOffset, //Device data address within the block
+                            usedSize, //Set one device-block only
+                            pBuffer //Buffer which contain the data
+                            );
                         break;
                     case AccessArea::Analog:
                     {
                         errorCode = pConn->writeAIO(theBlock_->getPLC(), usedAddress, //Base address (or DBn) of the block
-                        usedDeviceOffset, //Device data address within the block
-                        usedSize, //Set one device-block only
-                        pBuffer //Buffer which contain the data
-                        );
+                            usedDeviceOffset, //Device data address within the block
+                            usedSize, //Set one device-block only
+                            pBuffer //Buffer which contain the data
+                            );
                         break;
                     }
                     case AccessArea::Memory:
                     default:
                         errorCode = pConn->writeMemory(theBlock_->getPLC(), usedAddress, //Base address (or DBn) of the block
-                        usedDeviceOffset, //Device data address within the block
-                        usedSize, //Set one device-block only
-                        pBuffer //Buffer which contain the data
-                        );
+                            usedDeviceOffset, //Device data address within the block
+                            usedSize, //Set one device-block only
+                            pBuffer //Buffer which contain the data
+                            );
                         break;
                 }
             }
@@ -158,27 +158,27 @@ int PLCSendBlockMode::execute(Context* pContext)
                 {
                     case AccessArea::Digital:
                         errorCode = pConn->writeDIO(theBlock_->getPLC(), theBlock_->getAddress(), //Base address (or DBn) of the block
-                        0, //Set all devices from the first one
-                        ((PLCBlock*)theBlock_)->getBufferSize(), //Set blocks of all devices (full buffer size)
-                        (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data (full buffer)
-                        );
+                            0, //Set all devices from the first one
+                            ((PLCBlock*)theBlock_)->getBufferSize(), //Set blocks of all devices (full buffer size)
+                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data (full buffer)
+                            );
                         break;
                     case AccessArea::Analog:
                     {
                         errorCode = pConn->writeAIO(theBlock_->getPLC(), theBlock_->getAddress(), //Base address (or DBn) of the block
-                        0, //Set all devices from the first one
-                        ((PLCBlock*)theBlock_)->getBufferSize(), //Set blocks of all devices (full buffer size)
-                        (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data (full buffer)
-                        );
+                            0, //Set all devices from the first one
+                            ((PLCBlock*)theBlock_)->getBufferSize(), //Set blocks of all devices (full buffer size)
+                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data (full buffer)
+                            );
                         break;
                     }
                     case AccessArea::Memory:
                     default:
                         errorCode = pConn->writeMemory(theBlock_->getPLC(), theBlock_->getAddress(), //Base address (or DBn) of the block
-                        0, //Set all devices from the first one
-                        ((PLCBlock*)theBlock_)->getBufferSize(), //Set blocks of all devices (full buffer size)
-                        (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data (full buffer)
-                        );
+                            0, //Set all devices from the first one
+                            ((PLCBlock*)theBlock_)->getBufferSize(), //Set blocks of all devices (full buffer size)
+                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data (full buffer)
+                            );
                         break;
                 }
             }
@@ -198,7 +198,7 @@ int PLCSendBlockMode::execute(Context* pContext)
         LOG(ERROR) << "SendAction (execute/ DeviceMode) on block: " << theBlock_->getName() << " has failed";
         return ex.getCode();
     }
-    return 0;
+    return errorCode;
 }
 
 int PLCSendDeviceMode::execute(Context* pContext)
@@ -241,27 +241,27 @@ int PLCSendDeviceMode::execute(Context* pContext)
                 {
                     case AccessArea::Digital:
                         errorCode = pConn->writeDIO(theBlock_->getPLC(), usedDeviceAddress, //Base address (or DBn) of the device
-                        usedBlockAddress, //Block data address within the device
-                        usedSize, //Set one device-block only
-                        (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
-                        );
+                            usedBlockAddress, //Block data address within the device
+                            usedSize, //Set one device-block only
+                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
+                            );
                         break;
                     case AccessArea::Analog:
                     {
                         errorCode = pConn->writeAIO(theBlock_->getPLC(), usedDeviceAddress, //Base address (or DBn) of the device
-                        usedBlockAddress, //Block data address within the device
-                        usedSize, //Set one device-block only
-                        (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
-                        );
+                            usedBlockAddress, //Block data address within the device
+                            usedSize, //Set one device-block only
+                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
+                            );
                         break;
                     }
                     case AccessArea::Memory:
                     default:
                         errorCode = pConn->writeMemory(theBlock_->getPLC(), usedDeviceAddress, //Base address (or DBn) of the device
-                        usedBlockAddress, //Block data address within the device
-                        usedSize, //Set one device-block only
-                        (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
-                        );
+                            usedBlockAddress, //Block data address within the device
+                            usedSize, //Set one device-block only
+                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
+                            );
                         break;
                 }
             }
@@ -302,27 +302,27 @@ int PLCSendDeviceMode::execute(Context* pContext)
                     {
                         case AccessArea::Digital:
                             errorCode = pConn->writeDIO(theBlock_->getPLC(), pDev->getOutputAddress(area), //Base address (or DBn) of the device
-                            theBlock_->getAddress(), //Block data address within the device
-                            theBlock_->getMemSize(), //Set one device-block only
-                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
-                            );
+                                theBlock_->getAddress(), //Block data address within the device
+                                theBlock_->getMemSize(), //Set one device-block only
+                                (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
+                                );
                             break;
                         case AccessArea::Analog:
                         {
                             errorCode = pConn->writeAIO(theBlock_->getPLC(), pDev->getOutputAddress(area), //Base address (or DBn) of the device
-                            theBlock_->getAddress(), //Block data address within the device
-                            theBlock_->getMemSize(), //Set one device-block only
-                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
-                            );
+                                theBlock_->getAddress(), //Block data address within the device
+                                theBlock_->getMemSize(), //Set one device-block only
+                                (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
+                                );
                             break;
                         }
                         case AccessArea::Memory:
                         default:
                             errorCode = pConn->writeMemory(theBlock_->getPLC(), pDev->getOutputAddress(area), //Base address (or DBn) of the device
-                            theBlock_->getAddress(), //Block data address within the device
-                            theBlock_->getMemSize(), //Set one device-block only
-                            (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
-                            );
+                                theBlock_->getAddress(), //Block data address within the device
+                                theBlock_->getMemSize(), //Set one device-block only
+                                (unsigned char*)theBlock_->getBuffer() //Buffer which contain the data
+                                );
                             break;
                     }
                 }
@@ -343,7 +343,7 @@ int PLCSendDeviceMode::execute(Context* pContext)
         LOG(ERROR) << "SendAction (execute/ DeviceMode) failed";
         return ex.getCode();
     }
-    return 0;
+    return errorCode;
 }
 
 } // namespace
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/core/SilecsService.cpp b/silecs-communication-cpp/src/silecs-communication/interface/core/SilecsService.cpp
index 30c41d5..ec59fb3 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/core/SilecsService.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/core/SilecsService.cpp
@@ -284,7 +284,7 @@ bool Service::fileExists(std::string filename)
         }
     }
     //Unexpected error
-    throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+    throw SilecsException(__FILE__, __LINE__, errno);
 }
 
 bool Service::checkArgs(int argc, char ** argv)
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCRegister.cpp b/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCRegister.cpp
index eef367f..ba178e6 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCRegister.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCRegister.cpp
@@ -15,7 +15,6 @@ Contributors:
 #include <silecs-communication/interface/communication/MBHardware.h>
 #include <silecs-communication/interface/communication/SNAP7Hardware.h>
 #include <silecs-communication/interface/communication/SNAP7Utils.h>
-#include <snap7.h>
 
 namespace Silecs
 {
@@ -360,7 +359,7 @@ void PLCRegister::importValue(void* pBuffer, timeval ts)
                     }
                     else
                     { //should never occur!
-                        throw SilecsException(__FILE__, __LINE__, (int)UNEXPECTED_ERROR, "Controller protocol type undefined!");
+                        throw SilecsException(__FILE__, __LINE__, UNEXPECTED_ERROR, "Controller protocol type undefined!");
                     }
                     pData += dtSize;
                 }
@@ -452,7 +451,7 @@ void PLCRegister::exportValue(void* pBuffer)
                 }
                 else
                 { //should never occur!
-                    throw SilecsException(__FILE__, __LINE__, (int)UNEXPECTED_ERROR, "Controller protocol type undefined!");
+                    throw SilecsException(__FILE__, __LINE__, UNEXPECTED_ERROR, "Controller protocol type undefined!");
                 }
                 pData += dtSize;
             }
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsRegister.cpp b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsRegister.cpp
index bc48ec2..d704aaa 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsRegister.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsRegister.cpp
@@ -1357,7 +1357,7 @@ void Register::setScalarfromString(std::string stringValue)
             uint16_t val = 0;
             if(!StringUtilities::from_string<uint16_t>(val, stringValue, std::dec))
                 throw SilecsException(__FILE__, __LINE__,"Conversion from string '" + stringValue + "'to uInt8 failed for register '" + name_ + "'");
-            setValUInt8((uint16_t)val);
+            setValUInt8(static_cast<uint8_t>(val));
             break;
         }
         case Int8:
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/Condition.cpp b/silecs-communication-cpp/src/silecs-communication/interface/utility/Condition.cpp
index aa65b9f..92c41a9 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/Condition.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/Condition.cpp
@@ -29,7 +29,7 @@ Condition::Condition(std::string name)
     pMutex_ = new Mutex(name_);
 
     if ( (err = pthread_cond_init(&condVar_, NULL)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
 }
 
 Condition::~Condition()
@@ -37,7 +37,7 @@ Condition::~Condition()
     int err;
     if ( (err = pthread_cond_destroy(&condVar_)) != 0)
     { //can be broken by SIGKILL (just leave with no Exception)
-      //throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+      //throw SilecsException(__FILE__, __LINE__, errno);
     }
     delete pMutex_;
 }
@@ -56,7 +56,7 @@ void Condition::signal()
 {
     int err;
     if ( (err = pthread_cond_signal(&condVar_)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
     LOG(LOCK) << "Has signaled condition: " << this->name_;
 }
 
@@ -64,7 +64,7 @@ void Condition::broadcast()
 {
     int err;
     if ( (err = pthread_cond_broadcast(&condVar_)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
 }
 
 void Condition::wait()
@@ -72,7 +72,7 @@ void Condition::wait()
     int err;
     LOG(LOCK) << "Waiting for condition: " << this->name_;
     if ( (err = pthread_cond_wait(&condVar_, pMutex_->pMutex_)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
     LOG(LOCK) << "Has get condition: " << this->name_;
 }
 
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/Mutex.cpp b/silecs-communication-cpp/src/silecs-communication/interface/utility/Mutex.cpp
index 10c5c0b..a248a19 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/Mutex.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/Mutex.cpp
@@ -32,14 +32,14 @@ Mutex::Mutex(std::string name)
     pMutex_ = new pthread_mutex_t();
 
     if ( (err = pthread_mutexattr_init(&attr_)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
 
     //Mutex supports re-entrance for re-open mechanism inside send/recv action (doOpen() method call)
     if ( (err = pthread_mutexattr_settype(&attr_, PTHREAD_MUTEX_RECURSIVE)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
 
     if ( (err = pthread_mutex_init(pMutex_, &attr_)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
 }
 
 Mutex::~Mutex()
@@ -50,11 +50,11 @@ Mutex::~Mutex()
         LOG(ALLOC) << "Mutex (delete): " << name_;
 
     if ( (err = pthread_mutexattr_destroy(&attr_)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        throw SilecsException(__FILE__, __LINE__, errno);
 
     if ( (err = pthread_mutex_destroy(pMutex_)) != 0)
     { //can be broken by SIGKILL (just leave with no Exception)
-      //throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+      //throw SilecsException(__FILE__, __LINE__, errno);
     }
 
     // patch by Stefano Magnoni (20-03-2012)
@@ -73,7 +73,7 @@ void Mutex::lock()
     if ( (err = pthread_mutex_lock(pMutex_)) != 0)
     { // lock can be broken by SIGKILL (just release it with no Exception)
         pthread_mutex_unlock(pMutex_);
-        //throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        //throw SilecsException(__FILE__, __LINE__, errno);
     }
     LOG(LOCK) << "Has locked: " << this->name_;
 }
@@ -84,7 +84,7 @@ void Mutex::unlock()
     if ( (err = pthread_mutex_unlock(pMutex_)) != 0)
     { // unlock can be broken by SIGKILL (just force release again but no Exception)
         pthread_mutex_unlock(pMutex_);
-        //throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+        //throw SilecsException(__FILE__, __LINE__, errno);
     }
     LOG(LOCK) << "Has unlocked: " << this->name_;
 }
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.cpp b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.cpp
index c86f146..57245d2 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.cpp
@@ -14,6 +14,7 @@ Contributors:
 #include "SilecsException.h"
 #include "SilecsLog.h"
 
+#include <cstring>
 #include <string>
 
 namespace Silecs
@@ -31,13 +32,13 @@ SilecsException::SilecsException(const std::string& file, const uint32_t line, c
     log();
 }
 
-SilecsException::SilecsException(const std::string& file, const uint32_t line, const int err, const char *str)
+SilecsException::SilecsException(const std::string& file, const uint32_t line, const int err)
 {
     errFile_ = file;
     errLine_ = line;
     errCategory_ = CLIENT_SYSTEM_FAULT;
     errCode_ = UNEXPECTED_ERROR;
-    errMessage_ = str;
+    errMessage_ = std::strerror(err);
     buildFullMessage();
 
     //Log the error to the std. output (if ERROR topic is enable)
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.h b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.h
index 28026c2..8e06836 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.h
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsException.h
@@ -117,7 +117,7 @@ public:
      * \param file-name, line-number, error-no and error-str for system faults or extra-str if needed
      */
     SilecsException(const std::string& file, const uint32_t line, const ErrorCode code, const std::string& extMsg = std::string());
-    SilecsException(const std::string& file, const uint32_t line, const int err, const char *str);
+    SilecsException(const std::string& file, const uint32_t line, const int err);
     SilecsException(const std::string& file, const uint32_t line, const std::string& msg);
 
     /*!
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp
index abc2092..bdd994c 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/SilecsLog.cpp
@@ -157,7 +157,7 @@ void Log::startSyslog(char* ident, unsigned long topics)
     {
         char hostName[128];
         if (gethostname(hostName, 128) == -1)
-            throw SilecsException(__FILE__, __LINE__, errno, strerror(errno));
+            throw SilecsException(__FILE__, __LINE__, errno);
 
         //remove domain name (.cern.ch) if any
         host_ = std::string(hostName);
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/Thread.h b/silecs-communication-cpp/src/silecs-communication/interface/utility/Thread.h
index a883c29..82b17c4 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/Thread.h
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/Thread.h
@@ -111,7 +111,7 @@ Thread<UserDataType>::Thread() :
     pTid_ = (pthread_t *)malloc(sizeof(pthread_t));
     pThreadCompletion_->lock(); // The constructor will wait until thread is ready
     if ( (err = pthread_create(pTid_, NULL, run, this)) != 0)
-        throw SilecsException(__FILE__, __LINE__, errno, strerror(err));
+        throw SilecsException(__FILE__, __LINE__, err);
     //err = pthread_detach(*pTid_); not necessary because PLC thread are infinite loop
     pThreadCompletion_->wait(); // Wait until thread is ready
     pThreadCompletion_->unlock(); // Thread is ready
@@ -131,7 +131,7 @@ void *Thread<UserDataType>::run(void *pThisThread)
     {
         int err;
         if ( (err = pthread_sigmask(SIG_BLOCK, &smask, NULL)) != 0)
-            throw SilecsException(__FILE__, __LINE__, errno, strerror(err));
+            throw SilecsException(__FILE__, __LINE__, err);
     }
     pthis->execute();
     return 0;
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/TimeStamp.cpp b/silecs-communication-cpp/src/silecs-communication/interface/utility/TimeStamp.cpp
index 578e946..3ef15c9 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/TimeStamp.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/TimeStamp.cpp
@@ -83,6 +83,9 @@ void TsCounter::calibrateCountPeriod(unsigned int inDelay/*ms*/, unsigned int in
         }
         mPeriod = lPeriod/(inTimes-1);
 #else
+        // Cast to void to avoid unsued warnings.
+        static_cast<void>(inDelay);
+        static_cast<void>(inTimes);
         // use the microseconds of gettimeofday
         mPeriod = 0.000001;
 #endif
diff --git a/silecs-communication-cpp/src/silecs-communication/interface/utility/XMLParser.cpp b/silecs-communication-cpp/src/silecs-communication/interface/utility/XMLParser.cpp
index 2dc2854..5c0cd06 100644
--- a/silecs-communication-cpp/src/silecs-communication/interface/utility/XMLParser.cpp
+++ b/silecs-communication-cpp/src/silecs-communication/interface/utility/XMLParser.cpp
@@ -144,7 +144,7 @@ boost::optional<boost::ptr_vector<ElementXML> > XMLParser::getElementsFromXPath(
     {
         for (int i = 0; i < xpathObject->nodesetval->nodeNr; ++i)
         {
-            std::auto_ptr<ElementXML> element(new ElementXML());
+            std::unique_ptr<ElementXML> element(new ElementXML());
             fillElement(xpathObject->nodesetval->nodeTab[i], *element);
             if (!elements)
             {
-- 
GitLab