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

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

This commit is contained in:
f4exb 2018-02-21 18:54:59 +01:00
parent 0ce9035e0a
commit f01b90094b
19 changed files with 36 additions and 190 deletions

View File

@ -621,7 +621,7 @@ void DevicePlutoSDRBox::setLOPPMTenths(int ppmTenths)
char buff[100];
std::vector<std::string> params;
int64_t newXO = m_xoInitial + ((m_xoInitial*ppmTenths) / 10000000L);
snprintf(buff, sizeof(buff), "xo_correction=%ld", newXO);
snprintf(buff, sizeof(buff), "xo_correction=%ld", (long int) newXO);
params.push_back(std::string(buff));
set_params(DEVICE_PHY, params);
m_LOppmTenths = ppmTenths;

View File

@ -93,9 +93,9 @@ void HttpConnectionHandlerPool::cleanup()
{
if (++idleCounter > maxIdleHandlers)
{
delete handler;
pool.removeOne(handler);
qDebug("HttpConnectionHandlerPool: Removed connection handler (%p), pool size is now %i",handler,pool.size());
delete handler;
break; // remove only one handler in each interval
}
}

View File

@ -12,6 +12,7 @@ HttpCookie::HttpCookie()
version=1;
maxAge=0;
secure=false;
httpOnly=false;
}
HttpCookie::HttpCookie(const QByteArray name, const QByteArray value, const int maxAge, const QByteArray path, const QByteArray comment, const QByteArray domain, const bool secure, const bool httpOnly)

View File

@ -488,13 +488,16 @@ void HttpRequest::parseMultiPartFile()
#ifdef SUPERVERBOSE
qDebug("HttpRequest::parseMultiPartFile: finishing writing to uploaded file");
#endif
uploadedFile->resize(uploadedFile->size()-2);
uploadedFile->flush();
uploadedFile->seek(0);
parameters.insert(fieldName,fileName);
qDebug("HttpRequest::parseMultiPartFile: set parameter %s=%s",fieldName.data(),fileName.data());
uploadedFiles.insert(fieldName,uploadedFile);
qDebug("HttpRequest::parseMultiPartFile: uploaded file size is %i",(int) uploadedFile->size());
if (uploadedFile)
{
uploadedFile->resize(uploadedFile->size()-2);
uploadedFile->flush();
uploadedFile->seek(0);
qDebug("HttpRequest::parseMultiPartFile: set parameter %s=%s",fieldName.data(),fileName.data());
uploadedFiles.insert(fieldName,uploadedFile);
qDebug("HttpRequest::parseMultiPartFile: uploaded file size is %i",(int) uploadedFile->size());
}
}
if (line.contains(boundary+"--"))
{

View File

@ -451,7 +451,7 @@ void ATVMod::pullVideo(Real& sample)
if (camera.m_videoFPSCount < camera.m_videoFPSManualEnable ? camera.m_videoFPSManual : camera.m_videoFPS)
{
camera.m_videoPrevFPSCount = (int) camera.m_videoFPSCount;
camera.m_videoFPSCount += camera.m_videoFPSManualEnable ? camera.m_videoFPSqManual : camera.m_videoFPSq;
camera.m_videoFPSCount += (camera.m_videoFPSManualEnable ? camera.m_videoFPSqManual : camera.m_videoFPSq);
}
else
{

View File

@ -129,8 +129,12 @@ bool ATVModGUI::handleMessage(const Message& message)
}
else if (status == 2) // camera FPS scan is finished
{
m_camBusyFPSMessageBox->close();
if (m_camBusyFPSMessageBox) delete m_camBusyFPSMessageBox;
if (m_camBusyFPSMessageBox)
{
m_camBusyFPSMessageBox->close();
delete m_camBusyFPSMessageBox;
}
m_camBusyFPSMessageBox = 0;
}

View File

@ -55,7 +55,7 @@ public:
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
volatile bool m_running;
std::ofstream* m_ofstream;
std::size_t m_bufsize;

View File

@ -112,7 +112,7 @@ void FileSourceInput::seekFileStream(int seekPercentage)
{
QMutexLocker mutexLocker(&m_mutex);
if ((m_ifstream.is_open()) && !m_fileSourceThread->isRunning())
if ((m_ifstream.is_open()) && m_fileSourceThread && !m_fileSourceThread->isRunning())
{
int seekPoint = ((m_recordLength * seekPercentage) / 100) * m_sampleRate;
m_fileSourceThread->setSamplesCount(seekPoint);

View File

@ -52,7 +52,7 @@ public:
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
volatile bool m_running;
std::ifstream* m_ifstream;
quint8 *m_fileBuf;

View File

@ -61,7 +61,7 @@ public:
private:
QMutex m_startWaitMutex;
QWaitCondition m_startWaiter;
bool m_running;
volatile bool m_running;
qint16 *m_buf;
quint32 m_bufsize;

View File

@ -14,6 +14,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <algorithm>
#include <assert.h>
#include "samplesourcefifo.h"
@ -40,7 +41,8 @@ void SampleSourceFifo::resize(uint32_t size)
void SampleSourceFifo::init()
{
memset(&m_data[0], 0, sizeof(2*m_size*sizeof(Sample)));
static Sample zero = {0,0};
std::fill(m_data.begin(), m_data.end(), zero);
m_ir = 0;
m_iw = m_size/2;
m_init = true;

View File

@ -36,7 +36,6 @@ set(sdrgui_SOURCES
gui/rollupwidget.cpp
gui/samplingdevicecontrol.cpp
gui/samplingdevicedialog.cpp
gui/scale.cpp
gui/scaleengine.cpp
gui/tickedslider.cpp
gui/transverterbutton.cpp
@ -92,7 +91,6 @@ set(sdrgui_HEADERS
gui/rollupwidget.h
gui/samplingdevicecontrol.h
gui/samplingdevicedialog.h
gui/scale.h
gui/scaleengine.h
gui/tickedslider.h
gui/transverterbutton.h

View File

@ -542,7 +542,10 @@ bool ScopeVisMulti::handleMessage(const Message& message)
if (m_preTriggerDelay != triggerPre)
{
m_preTriggerDelay = triggerPre;
m_glScope->setTriggerPre(m_preTriggerDelay);
if (m_glScope) {
m_glScope->setTriggerPre(m_preTriggerDelay);
}
}
if (freeRun != m_freeRun)

View File

@ -595,7 +595,10 @@ bool ScopeVisNG::handleMessage(const Message& message)
if (m_preTriggerDelay != triggerPre)
{
m_preTriggerDelay = triggerPre;
m_glScope->setTriggerPre(m_preTriggerDelay);
if (m_glScope) {
m_glScope->setTriggerPre(m_preTriggerDelay);
}
}
if (freeRun != m_freeRun)

View File

@ -224,7 +224,7 @@ bool GLScopeMultiGUI::deserialize(const QByteArray& data)
ui->verticalXY->setEnabled(false);
ui->polar->setEnabled(false);
ui->traceMode->setCurrentIndex(intValue);
ui->traceMode->setCurrentIndex(0);
d.readS32(1, &intValue, (int) GLScopeMulti::DisplayX);
m_glScope->setDisplayMode((GLScopeMulti::DisplayMode) intValue);

View File

@ -220,7 +220,7 @@ bool GLScopeNGGUI::deserialize(const QByteArray& data)
ui->verticalXY->setEnabled(false);
ui->polar->setEnabled(false);
ui->traceMode->setCurrentIndex(intValue);
ui->traceMode->setCurrentIndex(0);
d.readS32(1, &intValue, (int) GLScopeNG::DisplayX);
m_glScope->setDisplayMode((GLScopeNG::DisplayMode) intValue);

View File

@ -1,129 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QPainter>
#include "gui/scale.h"
Scale::Scale(QWidget* parent) :
QWidget(parent)
{
}
void Scale::setOrientation(Qt::Orientation orientation)
{
m_orientation = orientation;
m_scaleEngine.setOrientation(orientation);
m_scaleEngine.setFont(font());
QFontMetrics fm(font());
switch(m_orientation) {
case Qt::Horizontal:
m_scaleEngine.setSize(width());
setMinimumWidth(0);
setMaximumWidth(QWIDGETSIZE_MAX);
setMinimumHeight(3 + fontMetrics().ascent());
setMaximumHeight(3 + fontMetrics().ascent());
break;
case Qt::Vertical:
m_scaleEngine.setSize(height());
setMinimumWidth(30);
setMaximumWidth(30);
setMinimumHeight(0);
setMaximumHeight(QWIDGETSIZE_MAX);
break;
}
}
void Scale::setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax)
{
m_scaleEngine.setRange(physicalUnit, rangeMin, rangeMax);
update();
}
void Scale::paintEvent(QPaintEvent*)
{
QPainter painter(this);
const ScaleEngine::TickList& tickList = m_scaleEngine.getTickList();
QFontMetricsF fontMetrics(font());
const ScaleEngine::Tick* tick;
int i;
float bottomLine;
switch(m_orientation) {
case Qt::Horizontal: {
painter.setPen(Qt::black);
// Zwischenlinien für x-Achse zeichnen
for(i = 0; i < tickList.count(); i++) {
tick = &tickList[i];
if(!tick->major)
painter.drawLine(QLineF(tick->pos, 0, tick->pos, 1));
}
// Skala am Rand zeichnen
painter.drawLine(QLineF(0, 0, width() - 1, 0));
// Hauptlinien und Beschriftung für x-Achse zeichnen
for(i = 0; i < tickList.count(); i++) {
tick = &tickList[i];
if(tick->major) {
painter.drawLine(QLineF(tick->pos - 1, 0, tick->pos - 1, 3));
if(tick->textSize > 0) {
painter.drawText(QPointF(tick->textPos, 3 + fontMetrics.ascent()), tick->text);
}
}
}
break;
}
case Qt::Vertical: {
bottomLine = height() - 1;
painter.setPen(Qt::black);
// Zwischenlinien für y-Achse zeichnen
for(i = 0; i < tickList.count(); i++) {
tick = &tickList[i];
if(!tick->major)
painter.drawLine(QLineF(width() - 2, bottomLine - tick->pos, width() - 1, bottomLine - tick->pos));
}
// Skala am Rand zeichnen
painter.drawLine(QLineF(width() - 1, 0, width() - 1, height() - 1));
// Hauptlinien und Beschriftung für y-Achse zeichnen
for(i = 0; i < tickList.count(); i++) {
tick = &tickList[i];
if(tick->major) {
painter.drawLine(QLineF(width() - 4, bottomLine - tick->pos, width() - 1, bottomLine - tick->pos));
if(tick->textSize > 0)
painter.drawText(QPointF(width() - 4 - tick->textSize, bottomLine - tick->textPos), tick->text);
}
}
}
}
}
void Scale::resizeEvent(QResizeEvent*)
{
switch(m_orientation) {
case Qt::Horizontal:
m_scaleEngine.setSize(width());
break;
case Qt::Vertical:
m_scaleEngine.setSize(height());
break;
}
}

View File

@ -1,37 +0,0 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
// written by Christian Daniel //
// //
// 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 //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QWidget>
#include "gui/scaleengine.h"
#include "util/export.h"
class SDRANGEL_API Scale : public QWidget {
Q_OBJECT
public:
Scale(QWidget* parent = NULL);
void setOrientation(Qt::Orientation orientation);
void setRange(Unit::Physical physicalUnit, float rangeMin, float rangeMax);
private:
Qt::Orientation m_orientation;
ScaleEngine m_scaleEngine;
void paintEvent(QPaintEvent*);
void resizeEvent(QResizeEvent*);
};

View File

@ -75,7 +75,6 @@ SOURCES += mainwindow.cpp\
gui/samplingdevicecontrol.cpp\
gui/samplingdevicedialog.cpp\
gui/mypositiondialog.cpp\
gui/scale.cpp\
gui/scaleengine.cpp\
gui/transverterbutton.cpp\
gui/transverterdialog.cpp\
@ -126,7 +125,6 @@ HEADERS += mainwindow.h\
gui/samplingdevicecontrol.h\
gui/samplingdevicedialog.h\
gui/mypositiondialog.h\
gui/scale.h\
gui/scaleengine.h\
gui/tickedslider.h\
gui/transverterbutton.h\