From 6d7416152f741c07ad4292ff8ae04f9724f0af48 Mon Sep 17 00:00:00 2001 From: Andrea Zoli Date: Mon, 3 Mar 2014 18:57:44 +0100 Subject: [PATCH] Remove some warning. --- include/SourceDataField.h | 3 +++ src/Packet.cpp | 4 ++-- src/PartOfPacket.cpp | 4 ++-- src/SDFBlockFixed.cpp | 4 ++-- src/SDFBlockVariable.cpp | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/SourceDataField.h b/include/SourceDataField.h index 6897d37..1d224ba 100644 --- a/include/SourceDataField.h +++ b/include/SourceDataField.h @@ -32,6 +32,9 @@ public: SourceDataField(const char* sdfName = 0); virtual ~SourceDataField(); + + /// Sets the stream of byte. This method assigns the value of stream for each field of part of packet + virtual bool setByteStream(ByteStreamPtr s, bool onlySections = false) { PartOfPacket::setByteStream(s); return true; }; /// Gets the total max dimension in bytes of source data field virtual dword getMaxDimension() = 0; diff --git a/src/Packet.cpp b/src/Packet.cpp index 5daf0bf..21b34c7 100644 --- a/src/Packet.cpp +++ b/src/Packet.cpp @@ -402,7 +402,7 @@ bool Packet::verifyPacketValue(ByteStreamPtr prefix, ByteStreamPtr packetHeader, for(unsigned i = 0; i< number_of_identifier; i++) { PacketIdentifier* pi = identifiers[i]; - Field* f; + Field* f = NULL; switch(pi->type) { case 0: @@ -416,7 +416,7 @@ bool Packet::verifyPacketValue(ByteStreamPtr prefix, ByteStreamPtr packetHeader, f = dataField->sourceDataField->getFields(pi->fieldNumber); break; } - if(f->value != pi->value) + if(f == NULL || f->value != pi->value) { verified = false; break; diff --git a/src/PartOfPacket.cpp b/src/PartOfPacket.cpp index a2476ed..afe072b 100644 --- a/src/PartOfPacket.cpp +++ b/src/PartOfPacket.cpp @@ -50,7 +50,7 @@ PartOfPacket::~PartOfPacket() string* PartOfPacket::printStructure() { bool first = true; - char *s; + char *s = NULL; for(unsigned i=0; i< numberOfFields; i++) { @@ -268,7 +268,7 @@ bool PartOfPacket::setByteStream(ByteStreamPtr s) /* cout << i << ": " << ftemp->value << endl; cout << i << ": " << (ftemp->value << currentDimBit) << endl; cout << i << ": " << wordtemp << endl;*/ - ftemp->value = (ftemp->value) | wordtemp & pattern[dimbit]; + ftemp->value = ftemp->value | (wordtemp & pattern[dimbit]); /* cout << i << ": " << ftemp->value << endl; cout << i << ": " << (wordtemp & pattern[dimbit]) << endl;*/ } diff --git a/src/SDFBlockFixed.cpp b/src/SDFBlockFixed.cpp index 02c0462..8c691af 100644 --- a/src/SDFBlockFixed.cpp +++ b/src/SDFBlockFixed.cpp @@ -264,12 +264,12 @@ dword SDFBlockFixed::getDimension(word nblock) dword SDFBlockFixed::getMaxDimension() { /// Event dimension - dword dimOfEventBlock; + dword dimOfEventBlock = 0; if(block != NULL) dimOfEventBlock = block[0].getDimension(); else { - ; //TODO lanciare una eccezione + throw PacketException("Error on SDFBlockFixed::getMaxDimension: block is NULL"); } return dimOfEventBlock * maxNumberOfBlock[0]; } diff --git a/src/SDFBlockVariable.cpp b/src/SDFBlockVariable.cpp index b166fc2..b4e7cdd 100644 --- a/src/SDFBlockVariable.cpp +++ b/src/SDFBlockVariable.cpp @@ -29,12 +29,12 @@ bool SDFBlockVariable::loadFields(InputText& fp) throw(PacketException*) { try { - char* line, *linesection; + char* line, *linesection = NULL; word indexOfNElement; unsigned addToNElements; word maxNumberOfElement; bool first1 = true, first2 = true; - MemoryBuffer* buffer1, *buffer2; + MemoryBuffer* buffer1, *buffer2 = NULL; line = fp.getLine(); if(strcmp(line, "fixed") == 0) -- GitLab