1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-18 21:58:37 -04:00

PVS-Studio static analysis corrections (3) issue #137

This commit is contained in:
f4exb
2018-02-24 10:29:27 +01:00
parent 9c3986ecbb
commit 2e5cfcafee
52 changed files with 187 additions and 229 deletions
+2 -8
View File
@@ -161,15 +161,9 @@ bool AirspyInput::start()
return false;
}
if (m_running) stop();
if((m_airspyThread = new AirspyThread(m_dev, &m_sampleFifo)) == 0)
{
qCritical("AirspyInput::start: out of memory");
stop();
return false;
}
if (m_running) { stop(); }
m_airspyThread = new AirspyThread(m_dev, &m_sampleFifo);
m_airspyThread->setSamplerate(m_sampleRates[m_settings.m_devSampleRateIndex]);
m_airspyThread->setLog2Decimation(m_settings.m_log2Decim);
m_airspyThread->setFcPos((int) m_settings.m_fcPos);
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <errno.h>
#include <algorithm>
#include "airspythread.h"
@@ -34,6 +35,7 @@ AirspyThread::AirspyThread(struct airspy_device* dev, SampleSinkFifo* sampleFifo
m_fcPos(0)
{
m_this = this;
std::fill(m_buf, m_buf + 2*AIRSPY_BLOCKSIZE, 0);
}
AirspyThread::~AirspyThread()
@@ -146,12 +146,7 @@ bool BladerfInput::start()
if (m_running) stop();
if((m_bladerfThread = new BladerfInputThread(m_dev, &m_sampleFifo)) == 0) {
qCritical("BladerfInput::start: out of memory");
stop();
return false;
}
m_bladerfThread = new BladerfInputThread(m_dev, &m_sampleFifo);
m_bladerfThread->setLog2Decimation(m_settings.m_log2Decim);
m_bladerfThread->setFcPos((int) m_settings.m_fcPos);
@@ -59,23 +59,23 @@ PluginInterface::SamplingDevices BlderfInputPlugin::enumSampleSources()
int count = bladerf_get_device_list(&devinfo);
for(int i = 0; i < count; i++)
{
QString displayedName(QString("BladeRF[%1] %2").arg(devinfo[i].instance).arg(devinfo[i].serial));
if (devinfo)
{
for(int i = 0; i < count; i++)
{
QString displayedName(QString("BladeRF[%1] %2").arg(devinfo[i].instance).arg(devinfo[i].serial));
result.append(SamplingDevice(displayedName,
m_hardwareID,
m_deviceTypeID,
QString(devinfo[i].serial),
i,
PluginInterface::SamplingDevice::PhysicalDevice,
true,
1,
0));
}
result.append(SamplingDevice(displayedName,
m_hardwareID,
m_deviceTypeID,
QString(devinfo[i].serial),
i,
PluginInterface::SamplingDevice::PhysicalDevice,
true,
1,
0));
}
if (devinfo)
{
bladerf_free_device_list(devinfo); // Valgrind memcheck
}
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <errno.h>
#include <algorithm>
#include "dsp/samplesinkfifo.h"
@@ -31,6 +32,7 @@ BladerfInputThread::BladerfInputThread(struct bladerf* dev, SampleSinkFifo* samp
m_log2Decim(0),
m_fcPos(0)
{
std::fill(m_buf, m_buf + 2*BLADERF_BLOCKSIZE, 0);
}
BladerfInputThread::~BladerfInputThread()
+1 -6
View File
@@ -121,12 +121,7 @@ bool FCDProInput::start()
return false;
}
if ((m_FCDThread = new FCDProThread(&m_sampleFifo)) == NULL)
{
qCritical("out of memory");
return false;
}
m_FCDThread = new FCDProThread(&m_sampleFifo);
m_FCDThread->startWork();
// mutexLocker.unlock();
@@ -115,12 +115,7 @@ bool FCDProPlusInput::start()
return false;
}
if ((m_FCDThread = new FCDProPlusThread(&m_sampleFifo)) == NULL)
{
qCritical("out of memory");
return false;
}
m_FCDThread = new FCDProPlusThread(&m_sampleFifo);
m_FCDThread->startWork();
// mutexLocker.unlock();
@@ -145,12 +145,7 @@ bool FileSourceInput::start()
//openFileStream();
if((m_fileSourceThread = new FileSourceThread(&m_ifstream, &m_sampleFifo)) == NULL) {
qCritical("out of memory");
stop();
return false;
}
m_fileSourceThread = new FileSourceThread(&m_ifstream, &m_sampleFifo);
m_fileSourceThread->setSampleRateAndSize(m_sampleRate, m_sampleSize);
m_fileSourceThread->connectTimer(m_masterTimer);
m_fileSourceThread->startWork();
@@ -132,12 +132,7 @@ bool HackRFInput::start()
if (m_running) stop();
if ((m_hackRFThread = new HackRFInputThread(m_dev, &m_sampleFifo)) == 0)
{
qCritical("HackRFInput::start: out of memory");
stop();
return false;
}
m_hackRFThread = new HackRFInputThread(m_dev, &m_sampleFifo);
// mutexLocker.unlock();
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <algorithm>
#include "dsp/samplesinkfifo.h"
@@ -32,6 +33,7 @@ HackRFInputThread::HackRFInputThread(hackrf_device* dev, SampleSinkFifo* sampleF
m_log2Decim(0),
m_fcPos(0)
{
std::fill(m_buf, m_buf + 2*HACKRF_BLOCKSIZE, 0);
}
HackRFInputThread::~HackRFInputThread()
@@ -129,9 +129,6 @@ bool LimeSDRInput::openDevice()
// check if the requested channel is busy and abort if so (should not happen if device management is working correctly)
char *busyChannels = new char[deviceParams->m_nbRxChannels];
memset(busyChannels, 0, deviceParams->m_nbRxChannels);
for (unsigned int i = 0; i < m_deviceAPI->getSourceBuddies().size(); i++)
{
DeviceSourceAPI *buddy = m_deviceAPI->getSourceBuddies()[i];
@@ -140,13 +137,11 @@ bool LimeSDRInput::openDevice()
if (buddyShared->m_channel == requestedChannel)
{
qCritical("LimeSDRInput::openDevice: cannot open busy channel %u", requestedChannel);
delete[] busyChannels;
return false;
}
}
m_deviceShared.m_channel = requestedChannel; // acknowledge the requested channel
delete[] busyChannels;
}
// look for Tx buddies and get reference to common parameters
// take the first Rx channel
@@ -389,20 +384,12 @@ bool LimeSDRInput::start()
return false;
}
applySettings(m_settings, true);
// start / stop streaming is done in the thread.
if ((m_limeSDRInputThread = new LimeSDRInputThread(&m_streamId, &m_sampleFifo)) == 0)
{
qCritical("LimeSDRInput::start: cannot create thread");
stop();
return false;
}
else
{
qDebug("LimeSDRInput::start: thread created");
}
m_limeSDRInputThread = new LimeSDRInputThread(&m_streamId, &m_sampleFifo);
qDebug("LimeSDRInput::start: thread created");
applySettings(m_settings, true);
m_limeSDRInputThread->setLog2Decimation(m_settings.m_log2SoftDecim);
@@ -15,6 +15,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <errno.h>
#include <algorithm>
#include "limesdrinputsettings.h"
#include "limesdrinputthread.h"
@@ -27,6 +28,7 @@ LimeSDRInputThread::LimeSDRInputThread(lms_stream_t* stream, SampleSinkFifo* sam
m_sampleFifo(sampleFifo),
m_log2Decim(0)
{
std::fill(m_buf, m_buf + 2*LIMESDR_BLOCKSIZE, 0);
}
LimeSDRInputThread::~LimeSDRInputThread()
+4 -12
View File
@@ -68,20 +68,12 @@ bool PerseusInput::start()
{
if (m_running) stop();
applySettings(m_settings, true);
// start / stop streaming is done in the thread.
if ((m_perseusThread = new PerseusThread(m_perseusDescriptor, &m_sampleFifo)) == 0)
{
qCritical("PerseusInput::start: cannot create thread");
stop();
return false;
}
else
{
qDebug("PerseusInput::start: thread created");
}
m_perseusThread = new PerseusThread(m_perseusDescriptor, &m_sampleFifo);
qDebug("PerseusInput::start: thread created");
applySettings(m_settings, true);
m_perseusThread->setLog2Decimation(m_settings.m_log2Decim);
m_perseusThread->startWork();
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
@@ -15,6 +15,7 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QtGlobal>
#include <algorithm>
#include "perseusthread.h"
PerseusThread *PerseusThread::m_this = 0;
@@ -28,6 +29,7 @@ PerseusThread::PerseusThread(perseus_descr* dev, SampleSinkFifo* sampleFifo, QOb
m_log2Decim(0)
{
m_this = this;
std::fill(m_buf, m_buf + 2*PERSEUS_NBSAMPLES, 0);
}
PerseusThread::~PerseusThread()
+1 -1
View File
@@ -42,7 +42,7 @@ public:
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
volatile bool m_running;
perseus_descr* m_dev;
qint32 m_buf[2*PERSEUS_NBSAMPLES];
@@ -44,6 +44,13 @@ PlutoSDRInput::PlutoSDRInput(DeviceSourceAPI *deviceAPI) :
m_plutoRxBuffer(0),
m_plutoSDRInputThread(0)
{
m_deviceSampleRates.m_addaConnvRate = 0;
m_deviceSampleRates.m_bbRateHz = 0;
m_deviceSampleRates.m_firRate = 0;
m_deviceSampleRates.m_hb1Rate = 0;
m_deviceSampleRates.m_hb2Rate = 0;
m_deviceSampleRates.m_hb3Rate = 0;
suspendBuddies();
openDevice();
resumeBuddies();
@@ -81,20 +88,12 @@ bool PlutoSDRInput::start()
if (m_running) stop();
applySettings(m_settings, true);
// start / stop streaming is done in the thread.
if ((m_plutoSDRInputThread = new PlutoSDRInputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleFifo)) == 0)
{
qCritical("PlutoSDRInput::start: cannot create thread");
stop();
return false;
}
else
{
qDebug("PlutoSDRInput::start: thread created");
}
m_plutoSDRInputThread = new PlutoSDRInputThread(PLUTOSDR_BLOCKSIZE_SAMPLES, m_deviceShared.m_deviceParams->getBox(), &m_sampleFifo);
qDebug("PlutoSDRInput::start: thread created");
applySettings(m_settings, true);
m_plutoSDRInputThread->setLog2Decimation(m_settings.m_log2Decim);
m_plutoSDRInputThread->startWork();
@@ -287,11 +286,9 @@ bool PlutoSDRInput::openDevice()
m_deviceAPI->setBuddySharedPtr(&m_deviceShared); // propagate common parameters to API
// acquire the channel
suspendBuddies();
DevicePlutoSDRBox *plutoBox = m_deviceShared.m_deviceParams->getBox();
plutoBox->openRx();
m_plutoRxBuffer = plutoBox->createRxBuffer(PLUTOSDR_BLOCKSIZE_SAMPLES, false);
resumeBuddies();
return true;
}
+1 -7
View File
@@ -187,13 +187,7 @@ bool RTLSDRInput::start()
if (m_running) stop();
if ((m_rtlSDRThread = new RTLSDRThread(m_dev, &m_sampleFifo)) == NULL)
{
qCritical("RTLSDRInput::start: out of memory");
stop();
return false;
}
m_rtlSDRThread = new RTLSDRThread(m_dev, &m_sampleFifo);
m_rtlSDRThread->setSamplerate(m_settings.m_devSampleRate);
m_rtlSDRThread->setLog2Decimation(m_settings.m_log2Decim);
m_rtlSDRThread->setFcPos((int) m_settings.m_fcPos);
@@ -18,6 +18,7 @@
#include <cassert>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <boost/crc.hpp>
#include <boost/cstdint.hpp>
#include "sdrdaemonsourcebuffer.h"
@@ -62,6 +63,9 @@ SDRdaemonSourceBuffer::SDRdaemonSourceBuffer(uint32_t throttlems) :
} else {
m_cm256_OK = true;
}
std::fill(m_decoderSlots, m_decoderSlots + nbDecoderSlots, DecoderSlot());
std::fill(m_frames, m_frames + nbDecoderSlots, BufferFrame());
}
SDRdaemonSourceBuffer::~SDRdaemonSourceBuffer()
@@ -31,6 +31,7 @@ SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo,
m_masterTimer(deviceAPI->getMasterTimer()),
m_masterTimerConnected(false),
m_running(false),
m_rateDivider(1000/SDRDAEMONSOURCE_THROTTLE_MS),
m_sdrDaemonBuffer(m_rateDivider),
m_dataSocket(0),
m_dataAddress(QHostAddress::LocalHost),
@@ -54,7 +55,6 @@ SDRdaemonSourceUDPHandler::SDRdaemonSourceUDPHandler(SampleSinkFifo *sampleFifo,
m_converterBuffer(0),
m_converterBufferNbSamples(0),
m_throttleToggle(false),
m_rateDivider(1000/SDRDAEMONSOURCE_THROTTLE_MS),
m_autoCorrBuffer(true)
{
m_udpBuf = new char[SDRdaemonSourceBuffer::m_udpPayloadSize];
@@ -55,6 +55,7 @@ private:
const QTimer& m_masterTimer;
bool m_masterTimerConnected;
bool m_running;
uint32_t m_rateDivider;
SDRdaemonSourceBuffer m_sdrDaemonBuffer;
QUdpSocket *m_dataSocket;
QHostAddress m_dataAddress;
@@ -80,7 +81,6 @@ private:
int32_t *m_converterBuffer;
uint32_t m_converterBufferNbSamples;
bool m_throttleToggle;
uint32_t m_rateDivider;
bool m_autoCorrBuffer;
void connectTimer();
@@ -168,12 +168,7 @@ bool SDRPlayInput::start()
return false;
}
if((m_sdrPlayThread = new SDRPlayThread(m_dev, &m_sampleFifo)) == 0)
{
qCritical("SDRPlayInput::start: failed to create thread");
return false;
}
m_sdrPlayThread = new SDRPlayThread(m_dev, &m_sampleFifo);
m_sdrPlayThread->setLog2Decimation(m_settings.m_log2Decim);
m_sdrPlayThread->setFcPos((int) m_settings.m_fcPos);
@@ -74,13 +74,7 @@ bool TestSourceInput::start()
if (m_running) stop();
if ((m_testSourceThread = new TestSourceThread(&m_sampleFifo)) == 0)
{
qCritical("TestSourceInput::start: out of memory");
stop();
return false;
}
m_testSourceThread = new TestSourceThread(&m_sampleFifo);
m_testSourceThread->setSamplerate(m_settings.m_sampleRate);
m_testSourceThread->connectTimer(m_masterTimer);
m_testSourceThread->startWork();