PVS-Studio static analysis corrections (4)

This commit is contained in:
f4exb 2018-04-04 23:39:31 +02:00
parent 9fd33a4101
commit 8dfdc1086c
17 changed files with 93 additions and 97 deletions

View File

@ -933,15 +933,15 @@ void RDSParser::decode_optional_content(int no_groups, unsigned long int *free_f
for (int i = no_groups; i == 0; i--) for (int i = no_groups; i == 0; i--)
{ {
ff_pointer = 12 + 16; ff_pointer = 12 + 16 - 4;
while(ff_pointer > 0) while(ff_pointer > 0)
{ {
ff_pointer -= 4;
m_g8_label_index = (free_format[i] & (0xf << ff_pointer)); m_g8_label_index = (free_format[i] & (0xf << ff_pointer));
content_length = optional_content_lengths[m_g8_label_index]; content_length = optional_content_lengths[m_g8_label_index];
ff_pointer -= content_length; ff_pointer -= content_length;
m_g8_content = (free_format[i] & (int(std::pow(2, content_length) - 1) << ff_pointer)); m_g8_content = (free_format[i] & (int(std::pow(2, content_length) - 1) << ff_pointer));
ff_pointer -= 4;
/* /*
qDebug() << "RDSParser::decode_optional_content: TMC optional content (" << label_descriptions[m_g8_label_index].c_str() qDebug() << "RDSParser::decode_optional_content: TMC optional content (" << label_descriptions[m_g8_label_index].c_str()

View File

@ -61,7 +61,7 @@ template<typename T> struct datvconstellation: runnable
while (in.readable() >= pixels_per_frame) while (in.readable() >= pixels_per_frame)
{ {
if (!phase) if ((!phase) && m_objDATVScreen)
{ {
m_objDATVScreen->resetImage(); m_objDATVScreen->resetImage();

View File

@ -765,7 +765,6 @@ void DATVDemod::InitDATVFramework()
void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst __attribute__((unused))) void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst __attribute__((unused)))
{ {
qint16 * ptrBufferToRelease=NULL;
float fltI; float fltI;
float fltQ; float fltQ;
leansdr::cf32 objIQ; leansdr::cf32 objIQ;
@ -859,18 +858,7 @@ void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVect
} }
} }
//********** demodulation **********
} }
if(ptrBufferToRelease!=NULL)
{
delete ptrBufferToRelease;
}
} }
void DATVDemod::start() void DATVDemod::start()

View File

@ -137,10 +137,10 @@ struct deconvol_poly2
++pin; \ ++pin; \
} }
// Don't shift by more than the operand width // Don't shift by more than the operand width
switch (sizeof(Thist) * 8) switch (sizeof(Thist) /* 8*/)
{ {
#if 0 // Not needed yet - avoid compiler warnings #if 0 // Not needed yet - avoid compiler warnings
case 64: case 8:
LOOP(63); LOOP(62); LOOP(61); LOOP(60); LOOP(63); LOOP(62); LOOP(61); LOOP(60);
LOOP(59); LOOP(58); LOOP(57); LOOP(56); LOOP(59); LOOP(58); LOOP(57); LOOP(56);
LOOP(55); LOOP(54); LOOP(53); LOOP(52); LOOP(55); LOOP(54); LOOP(53); LOOP(52);
@ -151,7 +151,7 @@ struct deconvol_poly2
LOOP(35); LOOP(34); LOOP(33); LOOP(32); LOOP(35); LOOP(34); LOOP(33); LOOP(32);
// Fall-through // Fall-through
#endif #endif
case 32: case 4:
LOOP(31) LOOP(31)
; ;
LOOP(30) LOOP(30)
@ -185,7 +185,7 @@ struct deconvol_poly2
LOOP(16) LOOP(16)
; ;
// Fall-through // Fall-through
case 16: case 2:
LOOP(15) LOOP(15)
; ;
LOOP(14) LOOP(14)
@ -203,7 +203,7 @@ struct deconvol_poly2
LOOP(8) LOOP(8)
; ;
// Fall-through // Fall-through
case 8: case 1:
LOOP(7) LOOP(7)
; ;
LOOP(6) LOOP(6)
@ -227,24 +227,24 @@ struct deconvol_poly2
} }
#undef LOOP #undef LOOP
#endif #endif
switch (sizeof(Thist) * 8) switch (sizeof(Thist) /* 8*/)
{ {
#if 0 // Not needed yet - avoid compiler warnings #if 0 // Not needed yet - avoid compiler warnings
case 64: case 8:
*pout++ = wd >> 56; *pout++ = wd >> 56;
*pout++ = wd >> 48; *pout++ = wd >> 48;
*pout++ = wd >> 40; *pout++ = wd >> 40;
*pout++ = wd >> 32; *pout++ = wd >> 32;
// Fall-through // Fall-through
#endif #endif
case 32: case 4:
*pout++ = wd >> 24; *pout++ = wd >> 24;
*pout++ = wd >> 16; *pout++ = wd >> 16;
// Fall-through // Fall-through
case 16: case 2:
*pout++ = wd >> 8; *pout++ = wd >> 8;
// Fall-through // Fall-through
case 8: case 1:
*pout++ = wd; *pout++ = wd;
break; break;
default: default:

View File

@ -334,7 +334,7 @@ private:
{ {
for (unsigned int i = 0; i < ncoeffs; ++i) for (unsigned int i = 0; i < ncoeffs; ++i)
{ {
float a = 2 * M_PI * f * (i - ncoeffs / 2); float a = 2 * M_PI * f * (i - (ncoeffs / 2));
float c = cosf(a), s = sinf(a); float c = cosf(a), s = sinf(a);
// TBD Support T=complex // TBD Support T=complex
shifted_coeffs[i].re = coeffs[i] * c; shifted_coeffs[i].re = coeffs[i] * c;

View File

@ -106,8 +106,8 @@ inline cstln_lut<256> * make_dvbs2_constellation(cstln_lut<256>::predef c,
} }
// EN 300 421, section 4.4.3, table 2 Punctured code, G1=0171, G2=0133 // EN 300 421, section 4.4.3, table 2 Punctured code, G1=0171, G2=0133
static const int DVBS_G1 = 0171; static const int DVBS_G1 = 121;
static const int DVBS_G2 = 0133; static const int DVBS_G2 = 91;
// G1 = 0b1111001 // G1 = 0b1111001
// G2 = 0b1011011 // G2 = 0b1011011
@ -1286,7 +1286,7 @@ struct randomizer: runnable
{ {
// EN 300 421, section 4.4.1 Transport multiplex adaptation // EN 300 421, section 4.4.1 Transport multiplex adaptation
pattern[0] = 0xff; // Invert one in eight sync bytes pattern[0] = 0xff; // Invert one in eight sync bytes
unsigned short st = 000251; // 0b 000 000 010 101 001 (Fig 2 reversed) unsigned short st = 169; // 0b 000 000 010 101 001 (Fig 2 reversed)
for (int i = 1; i < 188 * 8; ++i) for (int i = 1; i < 188 * 8; ++i)
{ {
u8 out = 0; u8 out = 0;
@ -1338,7 +1338,7 @@ struct derandomizer: runnable
{ {
// EN 300 421, section 4.4.1 Transport multiplex adaptation // EN 300 421, section 4.4.1 Transport multiplex adaptation
pattern[0] = 0xff; // Restore the inverted sync byte pattern[0] = 0xff; // Restore the inverted sync byte
unsigned short st = 000251; // 0b 000 000 010 101 001 (Fig 2 reversed) unsigned short st = 169; // 0b 000 000 010 101 001 (Fig 2 reversed)
for (int i = 1; i < 188 * 8; ++i) for (int i = 1; i < 188 * 8; ++i)
{ {
u8 out = 0; u8 out = 0;

View File

@ -603,7 +603,7 @@ private:
{ // Average power in first quadrant with unit grid { // Average power in first quadrant with unit grid
int q = m / 2; int q = m / 2;
float avgpower = 2 float avgpower = 2
* (q * 0.25 + (q - 1) * q / 2 * (q * 0.25 + (q - 1) * (q / 2)
+ (q - 1) * q * (2 * q - 1) / 6) / q; + (q - 1) * q * (2 * q - 1) / 6) / q;
scale = 1.0 / sqrtf(avgpower); scale = 1.0 / sqrtf(avgpower);
} }

View File

@ -392,7 +392,7 @@ void DSDDemod::applyAudioSampleRate(int sampleRate)
{ {
qDebug("DSDDemod::applyAudioSampleRate: %d", sampleRate); qDebug("DSDDemod::applyAudioSampleRate: %d", sampleRate);
if ((sampleRate != 48000) || (sampleRate != 8000)) { if ((sampleRate != 48000) && (sampleRate != 8000)) {
qWarning("DSDDemod::applyAudioSampleRate: audio does not work properly with sample rates other than 48 or 8 kS/s"); qWarning("DSDDemod::applyAudioSampleRate: audio does not work properly with sample rates other than 48 or 8 kS/s");
} }

View File

@ -40,6 +40,7 @@ UDPSinkFEC::UDPSinkFEC() :
m_frameCount(0), m_frameCount(0),
m_sampleIndex(0) m_sampleIndex(0)
{ {
memset((char *) m_txBlocks, 0, 4*256);
m_currentMetaFEC.init(); m_currentMetaFEC.init();
m_bufMeta = new uint8_t[m_udpSize]; m_bufMeta = new uint8_t[m_udpSize];
m_buf = new uint8_t[m_udpSize]; m_buf = new uint8_t[m_udpSize];
@ -115,11 +116,11 @@ void UDPSinkFEC::write(const SampleVector::iterator& begin, uint32_t sampleChunk
metaData.m_crc32 = crc32.checksum(); metaData.m_crc32 = crc32.checksum();
memset((void *) &m_superBlock, 0, sizeof(m_superBlock)); memset((char *) &m_superBlock, 0, sizeof(m_superBlock));
m_superBlock.header.frameIndex = m_frameCount; m_superBlock.header.frameIndex = m_frameCount;
m_superBlock.header.blockIndex = m_txBlockIndex; m_superBlock.header.blockIndex = m_txBlockIndex;
memcpy((void *) &m_superBlock.protectedBlock, (const void *) &metaData, sizeof(MetaDataFEC)); memcpy((char *) &m_superBlock.protectedBlock, (const char *) &metaData, sizeof(MetaDataFEC));
if (!(metaData == m_currentMetaFEC)) if (!(metaData == m_currentMetaFEC))
{ {
@ -143,16 +144,16 @@ void UDPSinkFEC::write(const SampleVector::iterator& begin, uint32_t sampleChunk
if (m_sampleIndex + inRemainingSamples < samplesPerBlock) // there is still room in the current super block if (m_sampleIndex + inRemainingSamples < samplesPerBlock) // there is still room in the current super block
{ {
memcpy((void *) &m_superBlock.protectedBlock.m_samples[m_sampleIndex], memcpy((char *) &m_superBlock.protectedBlock.m_samples[m_sampleIndex],
(const void *) &(*it), (const char *) &(*it),
inRemainingSamples * sizeof(Sample)); inRemainingSamples * sizeof(Sample));
m_sampleIndex += inRemainingSamples; m_sampleIndex += inRemainingSamples;
it = end; // all input samples are consumed it = end; // all input samples are consumed
} }
else // complete super block and initiate the next if not end of frame else // complete super block and initiate the next if not end of frame
{ {
memcpy((void *) &m_superBlock.protectedBlock.m_samples[m_sampleIndex], memcpy((char *) &m_superBlock.protectedBlock.m_samples[m_sampleIndex],
(const void *) &(*it), (const char *) &(*it),
(samplesPerBlock - m_sampleIndex) * sizeof(Sample)); (samplesPerBlock - m_sampleIndex) * sizeof(Sample));
it += samplesPerBlock - m_sampleIndex; it += samplesPerBlock - m_sampleIndex;
m_sampleIndex = 0; m_sampleIndex = 0;
@ -283,7 +284,7 @@ void UDPSinkFECWorker::encodeAndTransmit(UDPSinkFEC::SuperBlock *txBlockx, uint1
for (int i = 0; i < cm256Params.OriginalCount + cm256Params.RecoveryCount; ++i) for (int i = 0; i < cm256Params.OriginalCount + cm256Params.RecoveryCount; ++i)
{ {
if (i >= cm256Params.OriginalCount) { if (i >= cm256Params.OriginalCount) {
memset((void *) &txBlockx[i].protectedBlock, 0, sizeof(UDPSinkFEC::ProtectedBlock)); memset((char *) &txBlockx[i].protectedBlock, 0, sizeof(UDPSinkFEC::ProtectedBlock));
} }
txBlockx[i].header.frameIndex = frameIndex; txBlockx[i].header.frameIndex = frameIndex;

View File

@ -57,12 +57,12 @@ public:
bool operator==(const MetaDataFEC& rhs) bool operator==(const MetaDataFEC& rhs)
{ {
return (memcmp((const void *) this, (const void *) &rhs, 12) == 0); // Only the 12 first bytes are relevant return (memcmp((const char *) this, (const char *) &rhs, 12) == 0); // Only the 12 first bytes are relevant
} }
void init() void init()
{ {
memset((void *) this, 0, sizeof(MetaDataFEC)); memset((char *) this, 0, sizeof(MetaDataFEC));
m_nbFECBlocks = -1; m_nbFECBlocks = -1;
} }
}; };

View File

@ -46,12 +46,12 @@ public:
bool operator==(const MetaDataFEC& rhs) bool operator==(const MetaDataFEC& rhs)
{ {
return (memcmp((const void *) this, (const void *) &rhs, 12) == 0); // Only the 12 first bytes are relevant return (memcmp((const char *) this, (const char *) &rhs, 12) == 0); // Only the 12 first bytes are relevant
} }
void init() void init()
{ {
memset((void *) this, 0, sizeof(MetaDataFEC)); memset((char *) this, 0, sizeof(MetaDataFEC));
} }
}; };

View File

@ -84,28 +84,28 @@ RTPSession::~RTPSession()
delete rtprnd; delete rtprnd;
} }
int RTPSession::Create(const RTPSessionParams &sessparams, const RTPTransmissionParams *transparams /* = 0 */, RTPTransmitter::TransmissionProtocol protocol) //int RTPSession::Create(const RTPSessionParams &sessparams, const RTPTransmissionParams *transparams /* = 0 */, RTPTransmitter::TransmissionProtocol protocol)
{ //{
int status; // int status;
//
if (created) // if (created)
return ERR_RTP_SESSION_ALREADYCREATED; // return ERR_RTP_SESSION_ALREADYCREATED;
//
usingpollthread = sessparams.IsUsingPollThread(); // usingpollthread = sessparams.IsUsingPollThread();
//
useSR_BYEifpossible = sessparams.GetSenderReportForBYE(); // useSR_BYEifpossible = sessparams.GetSenderReportForBYE();
sentpackets = false; // sentpackets = false;
//
// Check max packet size // // Check max packet size
//
if ((maxpacksize = sessparams.GetMaximumPacketSize()) < RTP_MINPACKETSIZE) // if ((maxpacksize = sessparams.GetMaximumPacketSize()) < RTP_MINPACKETSIZE)
return ERR_RTP_SESSION_MAXPACKETSIZETOOSMALL; // return ERR_RTP_SESSION_MAXPACKETSIZETOOSMALL;
//
// Initialize the transmission component // // Initialize the transmission component
//
rtptrans = 0; // rtptrans = 0;
switch (protocol) // switch (protocol)
{ // {
// TODO: see if we keep this Create method or use the one with the transmitter specified // TODO: see if we keep this Create method or use the one with the transmitter specified
// case RTPTransmitter::IPv4UDPProto: // case RTPTransmitter::IPv4UDPProto:
// rtptrans = new RTPUDPv4Transmitter(); // rtptrans = new RTPUDPv4Transmitter();
@ -121,26 +121,27 @@ int RTPSession::Create(const RTPSessionParams &sessparams, const RTPTransmission
// case RTPTransmitter::TCPProto: // case RTPTransmitter::TCPProto:
// rtptrans = new RTPTCPTransmitter(); // rtptrans = new RTPTCPTransmitter();
// break; // break;
default:
return ERR_RTP_SESSION_UNSUPPORTEDTRANSMISSIONPROTOCOL;
}
if (rtptrans == 0) // default:
return ERR_RTP_OUTOFMEM; // return ERR_RTP_SESSION_UNSUPPORTEDTRANSMISSIONPROTOCOL;
if ((status = rtptrans->Init()) < 0) // }
{ //
delete rtptrans; // if (rtptrans == 0)
return status; // return ERR_RTP_OUTOFMEM;
} // if ((status = rtptrans->Init()) < 0)
if ((status = rtptrans->Create(maxpacksize, transparams)) < 0) // {
{ // delete rtptrans;
delete rtptrans; // return status;
return status; // }
} // if ((status = rtptrans->Create(maxpacksize, transparams)) < 0)
// {
deletetransmitter = true; // delete rtptrans;
return InternalCreate(sessparams); // return status;
} // }
//
// deletetransmitter = true;
// return InternalCreate(sessparams);
//}
int RTPSession::Create(const RTPSessionParams &sessparams, RTPTransmitter *transmitter) int RTPSession::Create(const RTPSessionParams &sessparams, RTPTransmitter *transmitter)
{ {

View File

@ -94,7 +94,7 @@ public:
* proto is of type RTPTransmitter::UserDefinedProto, the NewUserDefinedTransmitter function must * proto is of type RTPTransmitter::UserDefinedProto, the NewUserDefinedTransmitter function must
* be implemented. * be implemented.
*/ */
int Create(const RTPSessionParams &sessparams, const RTPTransmissionParams *transparams = 0, RTPTransmitter::TransmissionProtocol proto = RTPTransmitter::IPv4UDPProto); //int Create(const RTPSessionParams &sessparams, const RTPTransmissionParams *transparams = 0, RTPTransmitter::TransmissionProtocol proto = RTPTransmitter::IPv4UDPProto);
/** Creates an RTP session using \c transmitter as transmission component. /** Creates an RTP session using \c transmitter as transmission component.
* This function creates an RTP session with parameters \c sessparams, which will use the * This function creates an RTP session with parameters \c sessparams, which will use the

View File

@ -53,6 +53,9 @@ RTPUDPTransmitter::RTPUDPTransmitter() :
m_rtcpPort = 0; m_rtcpPort = 0;
m_rtpPort = 0; m_rtpPort = 0;
m_receivemode = RTPTransmitter::AcceptAll; m_receivemode = RTPTransmitter::AcceptAll;
m_maxpacksize = 0;
memset(m_rtpBuffer, 0, m_absoluteMaxPackSize);
memset(m_rtcpBuffer, 0, m_absoluteMaxPackSize);
} }
RTPUDPTransmitter::~RTPUDPTransmitter() RTPUDPTransmitter::~RTPUDPTransmitter()

View File

@ -20190,7 +20190,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2018-03-31T18:20:57.874+02:00 Generated 2018-04-04T22:16:33.651+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -20190,7 +20190,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2018-03-31T18:20:57.874+02:00 Generated 2018-04-04T22:16:33.651+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -388,16 +388,19 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
SWGObject *SWGobject = reinterpret_cast<SWGObject *>(value); SWGObject *SWGobject = reinterpret_cast<SWGObject *>(value);
if(SWGobject != nullptr) { if(SWGobject != nullptr) {
QJsonObject* o = (*SWGobject).asJsonObject(); QJsonObject* o = (*SWGobject).asJsonObject();
if(name != nullptr) { if (o != nullptr)
output->insert(name, *o); {
if(o != nullptr) delete o; if(name != nullptr) {
} output->insert(name, *o);
else { if(o != nullptr) delete o;
output->empty(); }
for(QString key : o->keys()) { else {
output->insert(key, o->value(key)); output->empty();
} for(QString key : o->keys()) {
} output->insert(key, o->value(key));
}
}
}
} }
} }
else if(QStringLiteral("QString").compare(type) == 0) { else if(QStringLiteral("QString").compare(type) == 0) {