1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 15:51:47 -05:00

PVS studio static analyzer fixes (1)

This commit is contained in:
f4exb 2018-06-21 19:28:11 +02:00
parent 777a1b0123
commit b00aea8989
32 changed files with 35 additions and 91 deletions

View File

@ -38,7 +38,7 @@ BladerfOutputGui::BladerfOutputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_settings(),
m_deviceSampleSink(NULL),
m_sampleRate(0),
m_lastEngineState((DSPDeviceSinkEngine::State)-1)
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted)
{
m_deviceSampleSink = (BladerfOutput*) m_deviceUISet->m_deviceSinkAPI->getSampleSink();

View File

@ -49,7 +49,7 @@ FileSinkGui::FileSinkGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_startingTimeStamp(0),
m_samplesCount(0),
m_tickCount(0),
m_lastEngineState((DSPDeviceSinkEngine::State)-1)
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted)
{
ui->setupUi(this);

View File

@ -40,7 +40,7 @@ HackRFOutputGui::HackRFOutputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_settings(),
m_deviceSampleSink(0),
m_lastEngineState((DSPDeviceSinkEngine::State)-1),
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted),
m_doApplySettings(true)
{
m_deviceSampleSink = (HackRFOutput*) m_deviceUISet->m_deviceSinkAPI->getSampleSink();

View File

@ -32,7 +32,7 @@ LimeSDROutputGUI::LimeSDROutputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
m_deviceUISet(deviceUISet),
m_settings(),
m_sampleRate(0),
m_lastEngineState((DSPDeviceSinkEngine::State)-1),
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted),
m_doApplySettings(true),
m_forceSettings(true),
m_statusCounter(0),

View File

@ -37,7 +37,7 @@ PlutoSDROutputGUI::PlutoSDROutputGUI(DeviceUISet *deviceUISet, QWidget* parent)
m_sampleSink(0),
m_sampleRate(0),
m_deviceCenterFrequency(0),
m_lastEngineState((DSPDeviceSinkEngine::State)-1),
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted),
m_doApplySettings(true),
m_statusCounter(0)
{

View File

@ -50,7 +50,7 @@ SDRdaemonSinkGui::SDRdaemonSinkGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_samplesCount(0),
m_tickCount(0),
m_nbSinceLastFlowCheck(0),
m_lastEngineState((DSPDeviceSinkEngine::State)-1),
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted),
m_doApplySettings(true),
m_forceSettings(true)
{

View File

@ -40,7 +40,8 @@ UDPSinkFEC::UDPSinkFEC() :
m_frameCount(0),
m_sampleIndex(0)
{
memset((char *) m_txBlocks, 0, 4*256);
memset((char *) m_txBlocks, 0, 4*256*sizeof(SuperBlock));
memset((char *) &m_superBlock, 0, sizeof(SuperBlock));
m_currentMetaFEC.init();
m_bufMeta = new uint8_t[m_udpSize];
m_buf = new uint8_t[m_udpSize];

View File

@ -39,7 +39,7 @@ AirspyGui::AirspyGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_settings(),
m_sampleSource(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (AirspyInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -38,7 +38,7 @@ AirspyHFGui::AirspyHFGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_settings(),
m_sampleSource(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (AirspyHFInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -38,7 +38,7 @@ BladerfInputGui::BladerfInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_settings(),
m_sampleSource(NULL),
m_sampleRate(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (BladerfInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -35,7 +35,7 @@ FCDProGui::FCDProGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_settings(),
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (FCDProInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -36,7 +36,7 @@ FCDProPlusGui::FCDProPlusGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_settings(),
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (FCDProPlusInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -51,7 +51,7 @@ FileSourceGui::FileSourceGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_samplesCount(0),
m_tickCount(0),
m_enableNavTime(false),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));

View File

@ -40,7 +40,7 @@ HackRFInputGui::HackRFInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_doApplySettings(true),
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (HackRFInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -35,7 +35,7 @@ LimeSDRInputGUI::LimeSDRInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
m_deviceUISet(deviceUISet),
m_settings(),
m_sampleRate(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_doApplySettings(true),
m_forceSettings(true),
m_statusCounter(0),

View File

@ -36,7 +36,7 @@ PerseusGui::PerseusGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_settings(),
m_sampleSource(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (PerseusInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -37,7 +37,7 @@ PlutoSDRInputGui::PlutoSDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_sampleSource(NULL),
m_sampleRate(0),
m_deviceCenterFrequency(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_doApplySettings(true),
m_statusCounter(0)
{

View File

@ -38,7 +38,7 @@ RTLSDRGui::RTLSDRGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_settings(),
m_sampleSource(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
m_sampleSource = (RTLSDRInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -54,7 +54,7 @@ SDRdaemonSourceGui::SDRdaemonSourceGui(DeviceUISet *deviceUISet, QWidget* parent
m_acquisition(false),
m_streamSampleRate(0),
m_streamCenterFrequency(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_framesDecodingStatus(0),
m_bufferLengthInSecs(0.0),
m_bufferGauge(-50),

View File

@ -44,7 +44,7 @@ TestSourceGui::TestSourceGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_forceSettings(true),
m_sampleSource(0),
m_tickCount(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
qDebug("TestSourceGui::TestSourceGui");
m_sampleSource = m_deviceUISet->m_deviceSourceAPI->getSampleSource();

View File

@ -171,12 +171,6 @@ int RTCPCompoundPacket::ParseData(uint8_t *data, std::size_t datalen)
p = new RTCPUnknownPacket(data, length);
}
if (p == 0)
{
ClearPacketList();
return ERR_RTP_OUTOFMEM;
}
rtcppacklist.push_back(p);
datalen -= length;

View File

@ -192,8 +192,6 @@ int RTCPCompoundPacketBuilder::AddReportBlock(uint32_t ssrc, uint8_t fractionlos
return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT;
uint8_t *buf = new uint8_t[sizeof(RTCPReceiverReport)];
if (buf == 0)
return ERR_RTP_OUTOFMEM;
RTCPReceiverReport *rr = (RTCPReceiverReport *) buf;
uint32_t *packlost = (uint32_t *) &packetslost;
@ -277,8 +275,6 @@ int RTCPCompoundPacketBuilder::AddSDESNormalItem(RTCPSDESPacket::ItemType t, con
std::size_t len;
buf = new uint8_t[sizeof(RTCPSDESHeader) + (std::size_t) itemlength];
if (buf == 0)
return ERR_RTP_OUTOFMEM;
len = sizeof(RTCPSDESHeader) + (std::size_t) itemlength;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *) (buf);
@ -314,8 +310,6 @@ int RTCPCompoundPacketBuilder::AddSDESPrivateItem(const void *prefixdata, uint8_
std::size_t len;
buf = new uint8_t[sizeof(RTCPSDESHeader) + itemlength];
if (buf == 0)
return ERR_RTP_OUTOFMEM;
len = sizeof(RTCPSDESHeader) + (std::size_t) itemlength;
RTCPSDESHeader *sdeshdr = (RTCPSDESHeader *) (buf);
@ -367,8 +361,6 @@ int RTCPCompoundPacketBuilder::AddBYEPacket(uint32_t *ssrcs, uint8_t numssrcs, c
std::size_t numwords;
buf = new uint8_t[packsize];
if (buf == 0)
return ERR_RTP_OUTOFMEM;
RTCPCommonHeader *hdr = (RTCPCommonHeader *) buf;
@ -425,8 +417,6 @@ int RTCPCompoundPacketBuilder::AddAPPPacket(uint8_t subtype, uint32_t ssrc, cons
uint8_t *buf;
buf = new uint8_t[packsize];
if (buf == 0)
return ERR_RTP_OUTOFMEM;
RTCPCommonHeader *hdr = (RTCPCommonHeader *) buf;
@ -469,8 +459,6 @@ int RTCPCompoundPacketBuilder::EndBuild()
if (!external)
{
buf = new uint8_t[len];
if (buf == 0)
return ERR_RTP_OUTOFMEM;
}
else
buf = buffer;
@ -526,13 +514,6 @@ int RTCPCompoundPacketBuilder::EndBuild()
p = new RTCPSRPacket(curbuf, offset);
else
p = new RTCPRRPacket(curbuf, offset);
if (p == 0)
{
if (!external)
delete[] buf;
ClearPacketList();
return ERR_RTP_OUTOFMEM;
}
rtcppacklist.push_back(p);
curbuf += offset;
@ -600,13 +581,6 @@ int RTCPCompoundPacketBuilder::EndBuild()
hdr->length = qToBigEndian((uint16_t) (numwords - 1));
p = new RTCPSDESPacket(curbuf, offset);
if (p == 0)
{
if (!external)
delete[] buf;
ClearPacketList();
return ERR_RTP_OUTOFMEM;
}
rtcppacklist.push_back(p);
curbuf += offset;
@ -625,13 +599,6 @@ int RTCPCompoundPacketBuilder::EndBuild()
memcpy(curbuf, (*it).packetdata, (*it).packetlength);
p = new RTCPAPPPacket(curbuf, (*it).packetlength);
if (p == 0)
{
if (!external)
delete[] buf;
ClearPacketList();
return ERR_RTP_OUTOFMEM;
}
rtcppacklist.push_back(p);
curbuf += (*it).packetlength;
@ -648,13 +615,6 @@ int RTCPCompoundPacketBuilder::EndBuild()
memcpy(curbuf, (*it).packetdata, (*it).packetlength);
p = new RTCPBYEPacket(curbuf, (*it).packetlength);
if (p == 0)
{
if (!external)
delete[] buf;
ClearPacketList();
return ERR_RTP_OUTOFMEM;
}
rtcppacklist.push_back(p);
curbuf += (*it).packetlength;

View File

@ -296,8 +296,6 @@ private:
int AddSSRC(uint32_t ssrc)
{
SDESSource *s = new SDESSource(ssrc);
if (s == 0)
return ERR_RTP_OUTOFMEM;
sdessources.push_back(s);
sdesit = sdessources.end();
sdesit--;

View File

@ -111,8 +111,6 @@ int RTCPPacketBuilder::BuildNextPacket(RTCPCompoundPacket **pack)
*pack = 0;
rtcpcomppack = new RTCPCompoundPacketBuilder();
if (rtcpcomppack == 0)
return ERR_RTP_OUTOFMEM;
if ((status = rtcpcomppack->InitBuild(maxpacketsize)) < 0)
{
@ -640,8 +638,6 @@ int RTCPPacketBuilder::BuildBYEPacket(RTCPCompoundPacket **pack, const void *rea
*pack = 0;
rtcpcomppack = new RTCPCompoundPacketBuilder();
if (rtcpcomppack == 0)
return ERR_RTP_OUTOFMEM;
if ((status = rtcpcomppack->InitBuild(maxpacketsize)) < 0)
{

View File

@ -87,6 +87,11 @@ int RTCPSchedulerParams::SetMinimumTransmissionInterval(const RTPTime &t)
RTCPScheduler::RTCPScheduler(RTPSources &s, RTPRandom &r) :
sources(s), nextrtcptime(0, 0), prevrtcptime(0, 0), rtprand(r)
{
pmembers = 0;
byemembers = 0;
pbyemembers = 0;
avgbyepacketsize = 0;
Reset();
//std::cout << (void *)(&rtprand) << std::endl;

View File

@ -230,8 +230,6 @@ private:
{
len = (len > RTCP_SDES_MAXITEMLENGTH) ? RTCP_SDES_MAXITEMLENGTH : len;
uint8_t *str2 = new uint8_t[len];
if (str2 == 0)
return ERR_RTP_OUTOFMEM;
memcpy(str2, s, len);
*destlen = len;
if (*dest)

View File

@ -297,8 +297,6 @@ inline int RTPKeyHashTable<Key, Element, GetIndex, hashsize>::AddElement(const K
// Okay, the key doesn't exist, so we can add the new element in the hash table
newelem = new HashElement(k, elem, index);
if (newelem == 0)
return ERR_RTP_OUTOFMEM;
e = table[index];
table[index] = newelem;

View File

@ -541,15 +541,11 @@ bool RTPUDPTransmitter::ShouldAcceptData(const RTPAddress& rtpAddress)
std::list<RTPAddress>::iterator findIt = std::find(m_acceptList.begin(), m_acceptList.end(), rtpAddress);
return findIt != m_acceptList.end();
}
else if (m_receivemode == RTPTransmitter::IgnoreSome)
else // this is RTPTransmitter::IgnoreSome
{
std::list<RTPAddress>::iterator findIt = std::find(m_ignoreList.begin(), m_ignoreList.end(), rtpAddress);
return findIt == m_ignoreList.end();
}
else
{
return false;
}
}
} // namespace

View File

@ -266,5 +266,5 @@ bool AudioFifo::create(uint32_t numSamples)
m_fifo = new qint8[numSamples * m_sampleSize];
m_size = numSamples;
return m_fifo != 0;
return true;
}

View File

@ -29,6 +29,7 @@ AudioNetSink::AudioNetSink(QObject *parent) :
m_bufferIndex(0),
m_port(9998)
{
memset(m_data, 0, 65536);
m_udpSocket = new QUdpSocket(parent);
}
@ -38,6 +39,7 @@ AudioNetSink::AudioNetSink(QObject *parent, int sampleRate, bool stereo) :
m_bufferIndex(0),
m_port(9998)
{
memset(m_data, 0, 65536);
m_udpSocket = new QUdpSocket(parent);
m_rtpBufferAudio = new RTPSink(m_udpSocket, sampleRate, stereo);
}
@ -61,17 +63,13 @@ bool AudioNetSink::selectType(SinkType type)
if (type == SinkUDP)
{
m_type = SinkUDP;
return true;
}
else if (type == SinkRTP)
else // this is SinkRTP
{
m_type = SinkRTP;
return true;
}
else
{
return false;
}
return true;
}
void AudioNetSink::setDestination(const QString& address, uint16_t port)

View File

@ -90,7 +90,7 @@ MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parse
m_settings(),
m_masterTabIndex(0),
m_dspEngine(DSPEngine::instance()),
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_inputGUI(0),
m_sampleRate(0),
m_centerFrequency(0),

View File

@ -53,7 +53,7 @@ MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, Q
m_settings(),
m_masterTabIndex(-1),
m_dspEngine(DSPEngine::instance()),
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
m_logger(logger)
{
qDebug() << "MainCore::MainCore: start";