1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

PVS studio static analyzer fixes (2)

This commit is contained in:
f4exb 2018-06-22 00:15:23 +02:00
parent b00aea8989
commit 5777875618
12 changed files with 20 additions and 37 deletions

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.0f));
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

@ -13,10 +13,17 @@ struct hdlc_dec
hdlc_dec(int _minframesize, // Including CRC, excluding HDLC flags. hdlc_dec(int _minframesize, // Including CRC, excluding HDLC flags.
int _maxframesize, bool _invert) : int _maxframesize, bool _invert) :
minframesize(_minframesize), maxframesize(_maxframesize), invertmask( minframesize(_minframesize),
_invert ? 0xff : 0), framebuf(new u8[maxframesize]), debug( maxframesize(_maxframesize),
false) invertmask(_invert ? 0xff : 0),
framebuf(new u8[maxframesize]),
debug(false)
{ {
byte_out = 0;
nbits_out = 0;
framesize = 0;
crc16 = 0;
reset(); reset();
} }

View File

@ -9,7 +9,7 @@ namespace leansdr {
template<typename T> template<typename T>
struct complex { struct complex {
T re, im; T re, im;
complex() { } complex() : re(0), im(0) { }
complex(T x) : re(x), im(0) { } complex(T x) : re(x), im(0) { }
complex(T x, T y) : re(x), im(y) { } complex(T x, T y) : re(x), im(y) { }
inline void operator +=(const complex<T> &x) { re+=x.re; im+=x.im; } inline void operator +=(const complex<T> &x) { re+=x.re; im+=x.im; }

View File

@ -637,9 +637,6 @@ int UDPSink::webapiSettingsPutPatch(
if (channelSettingsKeys.contains("amModFactor")) { if (channelSettingsKeys.contains("amModFactor")) {
settings.m_amModFactor = response.getUdpSinkSettings()->getAmModFactor(); settings.m_amModFactor = response.getUdpSinkSettings()->getAmModFactor();
} }
if (channelSettingsKeys.contains("amModFactor")) {
settings.m_amModFactor = response.getUdpSinkSettings()->getAmModFactor();
}
if (channelSettingsKeys.contains("channelMute")) { if (channelSettingsKeys.contains("channelMute")) {
settings.m_channelMute = response.getUdpSinkSettings()->getChannelMute() != 0; settings.m_channelMute = response.getUdpSinkSettings()->getChannelMute() != 0;
} }

View File

@ -654,9 +654,6 @@ int AirspyInput::webapiSettingsPutPatch(
if (deviceSettingsKeys.contains("vgaGain")) { if (deviceSettingsKeys.contains("vgaGain")) {
settings.m_vgaGain = response.getAirspySettings()->getVgaGain(); settings.m_vgaGain = response.getAirspySettings()->getVgaGain();
} }
if (deviceSettingsKeys.contains("vgaGain")) {
settings.m_vgaGain = response.getAirspySettings()->getVgaGain();
}
if (deviceSettingsKeys.contains("lnaAGC")) { if (deviceSettingsKeys.contains("lnaAGC")) {
settings.m_lnaAGC = response.getAirspySettings()->getLnaAgc() != 0; settings.m_lnaAGC = response.getAirspySettings()->getLnaAgc() != 0;
} }

View File

@ -154,13 +154,7 @@ bool AirspyHFInput::start()
if (m_running) { stop(); } if (m_running) { stop(); }
if ((m_airspyHFThread = new AirspyHFThread(m_dev, &m_sampleFifo)) == 0) m_airspyHFThread = new AirspyHFThread(m_dev, &m_sampleFifo);
{
qCritical("AirspyHFInput::start: out of memory");
stop();
return false;
}
int sampleRateIndex = m_settings.m_devSampleRateIndex; int sampleRateIndex = m_settings.m_devSampleRateIndex;
if (m_settings.m_devSampleRateIndex >= m_sampleRates.size()) { if (m_settings.m_devSampleRateIndex >= m_sampleRates.size()) {

View File

@ -1,3 +1,4 @@
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB // // Copyright (C) 2018 Edouard Griffiths, F4EXB //
// // // //
@ -31,6 +32,7 @@ AirspyHFThread::AirspyHFThread(airspyhf_device_t* dev, SampleSinkFifo* sampleFif
m_samplerate(10), m_samplerate(10),
m_log2Decim(0) m_log2Decim(0)
{ {
memset((char*) m_buf, 0, 2*AIRSPYHF_BLOCKSIZE*sizeof(qint16));
m_this = this; m_this = this;
} }

View File

@ -85,8 +85,7 @@ int RTCPSDESInfo::SetPrivateValue(const uint8_t *prefix, std::size_t prefixlen,
int status; int status;
item = new SDESPrivateItem(); item = new SDESPrivateItem();
if (item == 0)
return ERR_RTP_OUTOFMEM;
if ((status = item->SetPrefix(prefix, prefixlen)) < 0) if ((status = item->SetPrefix(prefix, prefixlen)) < 0)
{ {
delete item; delete item;

View File

@ -244,8 +244,6 @@ int RTPInternalSourceData::ProcessBYEPacket(const uint8_t *reason, std::size_t r
byetime = receivetime; byetime = receivetime;
byereason = new uint8_t[reasonlen]; byereason = new uint8_t[reasonlen];
if (byereason == 0)
return ERR_RTP_OUTOFMEM;
memcpy(byereason, reason, reasonlen); memcpy(byereason, reason, reasonlen);
byereasonlen = reasonlen; byereasonlen = reasonlen;
receivedbye = true; receivedbye = true;

View File

@ -308,11 +308,6 @@ int RTPPacket::BuildPacket(
if (buffer == 0) if (buffer == 0)
{ {
packet = new uint8_t[packetlength]; packet = new uint8_t[packetlength];
if (packet == 0)
{
packetlength = 0;
return ERR_RTP_OUTOFMEM;
}
externalbuffer = false; externalbuffer = false;
} }
else else

View File

@ -62,6 +62,7 @@ RTPPacketBuilder::RTPPacketBuilder(RTPRandom &r) :
numcsrcs = 0; numcsrcs = 0;
numpayloadbytes = 0; numpayloadbytes = 0;
numpackets = 0; numpackets = 0;
memset((char *) csrcs, 0, RTP_MAXCSRCS*sizeof(uint32_t));
timeinit.Dummy(); timeinit.Dummy();
//std::cout << (void *)(&rtprnd) << std::endl; //std::cout << (void *)(&rtprnd) << std::endl;
@ -81,8 +82,6 @@ int RTPPacketBuilder::Init(unsigned int max)
maxpacksize = max; maxpacksize = max;
buffer = new uint8_t[max]; buffer = new uint8_t[max];
if (buffer == 0)
return ERR_RTP_OUTOFMEM;
packetlength = 0; packetlength = 0;
numpackets = 0; numpackets = 0;
@ -113,8 +112,6 @@ int RTPPacketBuilder::SetMaximumPacketSize(unsigned int max)
if (max <= 0) if (max <= 0)
return ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE; return ERR_RTP_PACKBUILD_INVALIDMAXPACKETSIZE;
newbuf = new uint8_t[max]; newbuf = new uint8_t[max];
if (newbuf == 0)
return ERR_RTP_OUTOFMEM;
delete[] buffer; delete[] buffer;
buffer = newbuf; buffer = newbuf;

View File

@ -169,8 +169,7 @@ int RTPSources::ProcessRawPacket(RTPRawPacket *rawpack, RTPTransmitter *rtptrans
// First, we'll see if the packet can be parsed // First, we'll see if the packet can be parsed
rtppack = new RTPPacket(*rawpack); rtppack = new RTPPacket(*rawpack);
if (rtppack == 0)
return ERR_RTP_OUTOFMEM;
if ((status = rtppack->GetCreationError()) < 0) if ((status = rtppack->GetCreationError()) < 0)
{ {
if (status == ERR_RTP_PACKET_INVALIDPACKET) if (status == ERR_RTP_PACKET_INVALIDPACKET)
@ -808,8 +807,6 @@ int RTPSources::ObtainSourceDataInstance(uint32_t ssrc, RTPInternalSourceData **
if (sourcelist.GotoElement(ssrc) < 0) // No entry for this source if (sourcelist.GotoElement(ssrc) < 0) // No entry for this source
{ {
srcdat2 = new RTPInternalSourceData(ssrc); srcdat2 = new RTPInternalSourceData(ssrc);
if (srcdat2 == 0)
return ERR_RTP_OUTOFMEM;
if ((status = sourcelist.AddElement(ssrc, srcdat2)) < 0) if ((status = sourcelist.AddElement(ssrc, srcdat2)) < 0)
{ {
delete srcdat2; delete srcdat2;