Skip to content
Snippets Groups Projects
Commit 8efb94d6 authored by Andrea Zoli's avatar Andrea Zoli
Browse files

Fix -Wextra warnings.

parent 281529a1
Branches
Tags
No related merge requests found
...@@ -82,6 +82,15 @@ typedef unsigned int dword; ...@@ -82,6 +82,15 @@ typedef unsigned int dword;
#define CONFIG_MAXNUMBER_OFCONFIGILES 20000 #define CONFIG_MAXNUMBER_OFCONFIGILES 20000
#define CONFIG_MAXNUMBEROFLINES_OFCONFIGILES 100000 #define CONFIG_MAXNUMBEROFLINES_OFCONFIGILES 100000
/// utility function to ignore unused function parameters.
#ifdef HAS_MOVE_SEMANTICS
template <typename T>
void UNUSED(T &&)
{ }
#else
#define UNUSED(expr) do { (void)(expr); } while (0)
#endif
/// typedef bool boolean; /// typedef bool boolean;
using namespace std; using namespace std;
......
...@@ -32,7 +32,7 @@ class SharedPtr ...@@ -32,7 +32,7 @@ class SharedPtr
SharedPtr() : p(0), c(0) {} SharedPtr() : p(0), c(0) {}
explicit SharedPtr(T* s) : p(s), c(new unsigned(1)) {} explicit SharedPtr(T* s) : p(s), c(new unsigned(1)) {}
SharedPtr(void* null) : p(0), c(0) {} SharedPtr(void*) : p(0), c(0) {}
SharedPtr(const SharedPtr& s) : p(s.p), c(s.c) { if(c) ++*c; } SharedPtr(const SharedPtr& s) : p(s.p), c(s.c) { if(c) ++*c; }
......
...@@ -164,6 +164,8 @@ ByteStreamPtr PacketLib::ByteStream::compress(enum CompressionAlgorithms algorit ...@@ -164,6 +164,8 @@ ByteStreamPtr PacketLib::ByteStream::compress(enum CompressionAlgorithms algorit
ByteStreamPtr PacketLib::ByteStream::decompress(enum CompressionAlgorithms algorithmType, byte compressionLevel, dword dmax) { ByteStreamPtr PacketLib::ByteStream::decompress(enum CompressionAlgorithms algorithmType, byte compressionLevel, dword dmax) {
ByteStreamPtr b; ByteStreamPtr b;
UNUSED(compressionLevel);
switch(algorithmType) switch(algorithmType)
{ {
case NONE: case NONE:
......
...@@ -79,6 +79,7 @@ bool OutputSerial::writeByteStream(ByteStreamPtr b) throw(PacketExceptionIO*) ...@@ -79,6 +79,7 @@ bool OutputSerial::writeByteStream(ByteStreamPtr b) throw(PacketExceptionIO*)
bool OutputSerial::writeString(const char* str) throw(PacketExceptionIO*) bool OutputSerial::writeString(const char* str) throw(PacketExceptionIO*)
{ {
UNUSED(str);
/* if(!isclosed) /* if(!isclosed)
file->writeString(str); file->writeString(str);
else else
......
...@@ -72,5 +72,7 @@ bool OutputSocketClient::writeByteStream(ByteStreamPtr b) throw(PacketExceptionI ...@@ -72,5 +72,7 @@ bool OutputSocketClient::writeByteStream(ByteStreamPtr b) throw(PacketExceptionI
bool OutputSocketClient::writeString(const char* str) throw(PacketExceptionIO*) bool OutputSocketClient::writeString(const char* str) throw(PacketExceptionIO*)
{ {
UNUSED(str);
throw new PacketExceptionIO("Method not implemented"); throw new PacketExceptionIO("Method not implemented");
} }
...@@ -582,6 +582,8 @@ void Packet::generateStream() ...@@ -582,6 +582,8 @@ void Packet::generateStream()
bool Packet::setPacketValueVerify(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField) bool Packet::setPacketValueVerify(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField)
{ {
UNUSED(prefix);
/// 1) Checking /// 1) Checking
/// First check: pointers control /// First check: pointers control
if(packetHeader == NULL || packetDataField == NULL) if(packetHeader == NULL || packetDataField == NULL)
......
...@@ -30,6 +30,9 @@ void PacketNotRecognized::createPacketType(pugi::xml_node node, int plPhysicalIn ...@@ -30,6 +30,9 @@ void PacketNotRecognized::createPacketType(pugi::xml_node node, int plPhysicalIn
bool PacketNotRecognized::createPacketType(char* fileName, bool prefix, word dimprefix) throw (PacketException*) bool PacketNotRecognized::createPacketType(char* fileName, bool prefix, word dimprefix) throw (PacketException*)
{ {
UNUSED(prefix);
UNUSED(dimprefix);
packetID = 0; packetID = 0;
if(header->loadHeader(fileName)) if(header->loadHeader(fileName))
{ {
...@@ -60,6 +63,8 @@ PacketNotRecognized::~PacketNotRecognized() ...@@ -60,6 +63,8 @@ PacketNotRecognized::~PacketNotRecognized()
bool PacketNotRecognized::setPacketValue(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField, int decodeType) bool PacketNotRecognized::setPacketValue(ByteStreamPtr prefix, ByteStreamPtr packetHeader, ByteStreamPtr packetDataField, int decodeType)
{ {
UNUSED(decodeType);
/// It reads and sets the packet header /// It reads and sets the packet header
if(!header->setByteStream(packetHeader)) if(!header->setByteStream(packetHeader))
return false; return false;
......
...@@ -75,9 +75,9 @@ void SDFBlockType::loadType(pugi::xml_node node, const pugi::xml_document& doc, ...@@ -75,9 +75,9 @@ void SDFBlockType::loadType(pugi::xml_node node, const pugi::xml_document& doc,
std::cout << "fixed part: " << variablePresent; std::cout << "fixed part: " << variablePresent;
std::cout << " variable part: " << variablePresent << std::endl; std::cout << " variable part: " << variablePresent << std::endl;
#endif #endif
numberOfRBlocks = rbNodeSet.size(); if(rbNodeSet.size() > 65535)
if(numberOfRBlocks > 65535)
throw new PacketExceptionFileFormat("Too many number of Rblocks in the packet type."); throw new PacketExceptionFileFormat("Too many number of Rblocks in the packet type.");
numberOfRBlocks = rbNodeSet.size();
rblockFilename = new char*[numberOfRBlocks]; rblockFilename = new char*[numberOfRBlocks];
rBlockVariable = new bool[numberOfRBlocks]; rBlockVariable = new bool[numberOfRBlocks];
maxNumberOfBlock = new word[numberOfRBlocks]; maxNumberOfBlock = new word[numberOfRBlocks];
...@@ -97,9 +97,9 @@ void SDFBlockType::loadType(pugi::xml_node node, const pugi::xml_document& doc, ...@@ -97,9 +97,9 @@ void SDFBlockType::loadType(pugi::xml_node node, const pugi::xml_document& doc,
rBlockVariable[i] = false; rBlockVariable[i] = false;
const char* nblocks = rbNode.attribute("maxnumberofblocks").value(); const char* nblocks = rbNode.attribute("maxnumberofblocks").value();
maxNumberOfBlock[i] = atoi(nblocks); if(atoi(nblocks) > 65535)
if(maxNumberOfBlock[i] > 65535)
throw new PacketExceptionFileFormat("Too many number of blocks in the packet type."); throw new PacketExceptionFileFormat("Too many number of blocks in the packet type.");
maxNumberOfBlock[i] = atoi(nblocks);
if(!idref) if(!idref)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment