PVS-Studio Analysis corrections for serious issues

This commit is contained in:
f4exb 2018-11-18 09:39:22 +01:00
parent bc50bf9afa
commit 059228e39f
12 changed files with 48 additions and 26 deletions

View File

@ -68,7 +68,7 @@ public slots:
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
volatile bool m_running;
CM256 m_cm256;
CM256 *m_cm256p;

View File

@ -65,7 +65,8 @@ public:
ATV_FM3, //!< Classical frequency modulation with phase derivative discriminator
ATV_AM, //!< Classical amplitude modulation
ATV_USB, //!< AM with vestigial lower side band (main signal is in the upper side)
ATV_LSB //!< AM with vestigial upper side band (main signal is in the lower side)
ATV_LSB, //!< AM with vestigial upper side band (main signal is in the lower side)
ATV_NONE //!< No modulation just produces zeros
};
struct ATVConfig

View File

@ -83,7 +83,7 @@ public:
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
volatile bool m_running;
MessageQueue m_inputMessageQueue;
SDRDaemonDataQueue *m_dataQueue;

View File

@ -395,14 +395,10 @@ unsigned int Bladerf1OutputGui::getXb200Index(bool xb_200, bladerf_xb200_path xb
{
return 6;
}
else if (xb200Filter == BLADERF_XB200_222M)
else // xb200Filter == BLADERF_XB200_222M
{
return 7;
}
else
{
return 0;
}
}
}
else

View File

@ -303,6 +303,10 @@ bool BladeRF2Output::start()
m_deviceShared.m_dev->closeTx(i);
}
// was used as temporary storage:
delete[] fifos;
delete[] log2Interps;
needsStart = true;
}
else
@ -450,6 +454,10 @@ void BladeRF2Output::stop()
bladeRF2OutputThread->startWork();
}
// was used as temporary storage:
delete[] fifos;
delete[] log2Interps;
}
else // remove channel from existing thread
{

View File

@ -46,9 +46,13 @@ void UDPSinkFECWorker::startWork()
qDebug("UDPSinkFECWorker::startWork");
m_startWaitMutex.lock();
m_udpSocket = new QUdpSocket(this);
start();
while(!m_running)
while(!m_running) {
m_startWaiter.wait(&m_startWaitMutex, 100);
}
m_startWaitMutex.unlock();
}

View File

@ -135,7 +135,7 @@ private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
volatile bool m_running;
CM256 m_cm256; //!< CM256 library object
bool m_cm256Valid; //!< true if CM256 library is initialized correctly
QUdpSocket *m_udpSocket;

View File

@ -463,14 +463,10 @@ unsigned int Bladerf1InputGui::getXb200Index(bool xb_200, bladerf_xb200_path xb2
{
return 6;
}
else if (xb200Filter == BLADERF_XB200_222M)
else // xb200Filter == BLADERF_XB200_222M
{
return 7;
}
else
{
return 0;
}
}
}
else

View File

@ -329,6 +329,11 @@ bool BladeRF2Input::start()
((DeviceBladeRF2Shared*) (*it)->getBuddySharedPtr())->m_source->setThread(0);
}
// was used as temporary storage:
delete[] fifos;
delete[] log2Decims;
delete[] fcPoss;
needsStart = true;
}
else
@ -470,6 +475,11 @@ void BladeRF2Input::stop()
if (stillActiveFIFO) {
bladerf2InputThread->startWork();
}
// was used as temporary storage:
delete[] fifos;
delete[] log2Decims;
delete[] fcPoss;
}
else // remove channel from existing thread
{

View File

@ -262,13 +262,7 @@ void SDRdaemonSourceUDPHandler::tick()
const SDRDaemonMetaDataFEC& metaData = m_sdrDaemonBuffer.getCurrentMeta();
m_readLength = m_readLengthSamples * (metaData.m_sampleBytes & 0xF) * 2;
if (SDR_RX_SAMP_SZ == metaData.m_sampleBits) // same sample size
{
// read samples directly feeding the SampleFifo (no callback)
m_sampleFifo->write(reinterpret_cast<quint8*>(m_sdrDaemonBuffer.readData(m_readLength)), m_readLength);
m_samplesCount += m_readLengthSamples;
}
else if (metaData.m_sampleBits == 16) // 16 -> 24 bits
if ((metaData.m_sampleBits == 16) && (SDR_RX_SAMP_SZ == 24)) // 16 -> 24 bits
{
if (m_readLengthSamples > m_converterBufferNbSamples)
{
@ -288,7 +282,7 @@ void SDRdaemonSourceUDPHandler::tick()
m_sampleFifo->write(reinterpret_cast<quint8*>(m_converterBuffer), m_readLengthSamples*sizeof(Sample));
}
else if (metaData.m_sampleBits == 24) // 24 -> 16 bits
else if ((metaData.m_sampleBits == 24) && (SDR_RX_SAMP_SZ == 16)) // 24 -> 16 bits
{
if (m_readLengthSamples > m_converterBufferNbSamples)
{
@ -307,7 +301,13 @@ void SDRdaemonSourceUDPHandler::tick()
m_sampleFifo->write(reinterpret_cast<quint8*>(m_converterBuffer), m_readLengthSamples*sizeof(Sample));
}
else
else if ((metaData.m_sampleBits == 16) || (metaData.m_sampleBits == 24)) // same sample size and valid size
{
// read samples directly feeding the SampleFifo (no callback)
m_sampleFifo->write(reinterpret_cast<quint8*>(m_sdrDaemonBuffer.readData(m_readLength)), m_readLength);
m_samplesCount += m_readLengthSamples;
}
else // invalid size
{
qWarning("SDRdaemonSourceUDPHandler::tick: unexpected sample size in stream: %d bits", (int) metaData.m_sampleBits);
}

View File

@ -42,13 +42,20 @@ struct SDRDaemonMetaDataFEC
uint8_t m_sampleBits; //!< 10 number of effective bits per sample (deprecated)
uint8_t m_nbOriginalBlocks; //!< 11 number of blocks with original (protected) data
uint8_t m_nbFECBlocks; //!< 12 number of blocks carrying FEC
uint32_t m_tv_sec; //!< 16 seconds of timestamp at start time of super-frame processing
uint32_t m_tv_usec; //!< 20 microseconds of timestamp at start time of super-frame processing
uint32_t m_crc32; //!< 24 CRC32 of the above
bool operator==(const SDRDaemonMetaDataFEC& rhs)
{
return (memcmp((const void *) this, (const void *) &rhs, 12) == 0); // Only the 12 first bytes are relevant
// Only the first 6 fields are relevant
return (m_centerFrequency == rhs.m_centerFrequency)
&& (m_sampleRate == rhs.m_sampleRate)
&& (m_sampleBytes == rhs.m_sampleBytes)
&& (m_sampleBits == rhs.m_sampleBits)
&& (m_nbOriginalBlocks == rhs.m_nbOriginalBlocks)
&& (m_nbFECBlocks == rhs.m_nbFECBlocks);
}
void init()

View File

@ -295,7 +295,7 @@ void DownChannelizer::freeFilterChain()
void DownChannelizer::debugFilterChain()
{
qDebug("DownChannelizer::debugFilterChain: %lu stages", m_filterStages.size());
qDebug("DownChannelizer::debugFilterChain: %u stages", m_filterStages.size());
for(FilterStages::iterator it = m_filterStages.begin(); it != m_filterStages.end(); ++it)
{