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

Fix -Wextra warnings.

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