Skip to content

Commit

Permalink
Merge pull request #2410 from Joern-R/staticchecks
Browse files Browse the repository at this point in the history
Fix Static Code Check results
  • Loading branch information
Joern-R committed Mar 25, 2017
2 parents 73d006d + bd95f86 commit 13e78a5
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 62 deletions.
1 change: 0 additions & 1 deletion src/ANT/ANTMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ void ANTMessage::init()
wheelRevolutions = crankRevolutions = 0;
slope = period = torque = 0;
sync = length = type = 0;
pedalPower = 0;
srmOffset = srmSlope = srmSerial = 0;
calibrationID = ctfID = 0;
autoZeroStatus = autoZeroEnable = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Charts/AllPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2775,7 +2775,7 @@ AllPlot::setYMax()
standard->apCurve->isVisible());

setAxisVisible(QwtAxisId(QwtAxis::yLeft, 1), standard->hrCurve->isVisible() || standard->tcoreCurve->isVisible() ||
standard->cadCurve->isVisible() || standard->smo2Curve->isVisible() || standard->hrCurve->isVisible());
standard->cadCurve->isVisible() || standard->smo2Curve->isVisible() || standard->hrvCurve->isVisible());
setAxisVisible(QwtAxisId(QwtAxis::yLeft, 2), false);
setAxisVisible(QwtAxisId(QwtAxis::yLeft, 3), standard->balanceLCurve->isVisible() ||
standard->lteCurve->isVisible() ||
Expand Down
14 changes: 6 additions & 8 deletions src/Charts/CPPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,7 @@ CPPlot::clearCurves()

// rainbow labels
if (allZoneLabels.size()) {
foreach (QwtPlotMarker *label, allZoneLabels)
delete label;
foreach (QwtPlotMarker *label, allZoneLabels) delete label;
allZoneLabels.clear();
}

Expand Down Expand Up @@ -1142,7 +1141,7 @@ CPPlot::plotBests(RideItem *rideItem)
// set samples
if (criticalSeries == CriticalPowerWindow::work) { // this is Energy mode
curve->setSamples(time.data() + low, work.data() + low, high - low + 1);
} if (criticalSeries == CriticalPowerWindow::veloclinicplot) {
} else if (criticalSeries == CriticalPowerWindow::veloclinicplot) {
curve->setSamples(values + low, wprime.data() + low, high - low + 1);
} else {
curve->setSamples(time.data() + low, values + low, high - low + 1);
Expand Down Expand Up @@ -1923,7 +1922,8 @@ CPPlot::refreshReferenceLines(RideItem *rideItem)
}
referenceLines.clear();

if (!rideItem && !rideItem->ride()) return;
if (!rideItem) return;
if (!rideItem->ride()) return;

// horizontal lines at reference points
if (rideSeries == RideFile::aPower || rideSeries == RideFile::xPower || rideSeries == RideFile::NP || rideSeries == RideFile::watts || rideSeries == RideFile::wattsKg || rideSeries == RideFile::aPowerKg) {
Expand Down Expand Up @@ -2057,10 +2057,8 @@ CPPlot::plotCentile(RideItem *rideItem)
count++;
}
if (sum > 0) {
if (sum > 0) {
double avg = sum / count;
ride_centiles[i-1][slice]=avg;
}
double avg = sum / count;
ride_centiles[i-1][slice]=avg;
} else {
ride_centiles[i-1][slice]=ride_centiles[i][slice];
}
Expand Down
4 changes: 2 additions & 2 deletions src/Charts/CriticalPowerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ CriticalPowerWindow::CriticalPowerWindow(Context *context, bool rangemode) :
// controls widget and layout
QTabWidget *settingsTabs = new QTabWidget(this);
HelpWhatsThis *helpTabs = new HelpWhatsThis(settingsTabs);
if (rangemode) settingsTabs->setWhatsThis(help->getWhatsThisText(HelpWhatsThis::ChartTrends_Critical_MM));
if (rangemode) settingsTabs->setWhatsThis(helpTabs->getWhatsThisText(HelpWhatsThis::ChartTrends_Critical_MM));
else settingsTabs->setWhatsThis(helpTabs->getWhatsThisText(HelpWhatsThis::ChartRides_Critical_MM));


Expand Down Expand Up @@ -872,7 +872,7 @@ CriticalPowerWindow::refreshRideSaved(RideItem *item)

if (!rangemode) {
// reset date range for bests and model
if (!rangemode) seasonSelected(cComboSeason->currentIndex());
seasonSelected(cComboSeason->currentIndex());
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Charts/GoldenCheetah.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ GcChartWindow::chartPropertiesFromString(QString contents) {
m.insert("VIEW", view);

// run through the properties
bool hadproperties;
bool hadproperties = false;
if (c->hasField("PROPERTIES") && c->getField("PROPERTIES")->valueType == MVJSON_TYPE_OBJECT) {
MVJSONNode *p = c->getField("PROPERTIES")->objValue;

Expand Down
4 changes: 2 additions & 2 deletions src/Charts/HomeWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ HomeWindow::addChart(GcChartWindow* newone)
if (newwidth < minWidth) newwidth = minWidth;
newone->setFixedWidth(newwidth);
if (newheight < minHeight) newheight = minHeight;
else newone->setFixedHeight(newheight);
newone->setFixedHeight(newheight);
newone->setContentsMargins(0,15*dpiYFactor,0,0);
newone->setResizable(true); // we need to show on tab selection!

Expand Down Expand Up @@ -815,7 +815,7 @@ HomeWindow::resizeEvent(QResizeEvent * /* e */)
if (newwidth < minWidth) newwidth = minWidth;
x->setFixedWidth(newwidth);
if (newheight < minHeight) newheight = minHeight;
else x->setFixedHeight(newheight);
x->setFixedHeight(newheight);
}
break;

Expand Down
5 changes: 0 additions & 5 deletions src/Charts/MUPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,6 @@ MUPlot::setModel(int model)
fastCurve->setPen(pen);
fastCurve->setBrush(brush);

QwtSymbol *sym = new QwtSymbol;
sym->setStyle(QwtSymbol::Ellipse);
sym->setSize(4);
sym->setPen(QPen(Qt::yellow)); // customise ?
sym->setBrush(QBrush(Qt::yellow));
}

if (slowCurve) {
Expand Down
2 changes: 1 addition & 1 deletion src/Charts/ModelPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ ModelDataProvider::ModelDataProvider (ModelPlot &plot, ModelSettings *settings)
xscale = 1;
yscale = (maxbinx-minbinx)/(maxbiny-minbiny);
zscale = (maxbinx-minbinx)/(maxz-minz);
} else if ((maxbiny-minbiny) >= (maxbinx-minbinx) && (maxbiny >= minbiny) >= (maxz-minz)) {
} else if ((maxbiny-minbiny) >= (maxbinx-minbinx) && (maxbiny-minbiny) >= (maxz-minz)) {
// scale is set off the y-axis
xscale = (maxbiny-minbiny)/(maxbinx-minbinx);
yscale = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/Charts/OverviewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ Card::setType(CardType type, RideFile::SeriesType series)

// config axes
QPen axisPen(GColor(CCARDBACKGROUND));
axisPen.setWidth(0.5); // almost invisibke
axisPen.setWidth(1); // almost invisible
chart->createDefaultAxes();
chart->setAxisX(barcategoryaxis, barseries);
barcategoryaxis->setLinePen(axisPen);
Expand Down
6 changes: 5 additions & 1 deletion src/Cloud/CloudDBCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,11 @@ CloudDBHeader::getAllCachedHeader(QList<CommonAPIHeaderV1> *objectHeader, CloudD
reply = nam->get(request);

// wait for reply (synchronously) and process error codes as necessary
if (!CloudDBCommon::replyReceivedAndOk(reply)) return false;
if (!CloudDBCommon::replyReceivedAndOk(reply)) {
delete retrievedHeader;
delete newHeader;
return false;
};

QByteArray result = reply->readAll();
retrievedHeader->clear();
Expand Down
6 changes: 3 additions & 3 deletions src/Cloud/CloudDBStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ CloudDBStatusClient::displayCloudDBStatus() {

StatusAPIGetV1 status = getCurrentStatus();
if (status.Status == CloudDBStatusClient::CloudDBStatus_Ok) {
QMessageBox::information(0, tr("CloudDB Status"), QString(tr("<b><big>Ok</b></big><br><br>All Services should be operational - no problems known.")));
QMessageBox::information(0, tr("CloudDB Status"), QString(tr("<b><big>Ok</big></b><br><br>All Services should be operational - no problems known.")));
} else if (status.Status == CloudDBStatusClient::CloudDBStatus_PartialFailure) {
QString text = getCurrentStatusText(status.Id);
QMessageBox::warning(0, tr("CloudDB Status"), QString(tr("<b><big>Limited Service</b></big><br>Sorry - some CloudDB services are not operational.<br><br><b>More information:</b><br>%1")).arg(text));
QMessageBox::warning(0, tr("CloudDB Status"), QString(tr("<b><big>Limited Service</big></b><br>Sorry - some CloudDB services are not operational.<br><br><b>More information:</b><br>%1")).arg(text));
} else {
QString text = getCurrentStatusText(status.Id);
QMessageBox::critical(0, tr("CloudDB Status"), QString(tr("<b><big>Service outage</b></big><br>Sorry - CloudDB services are not operational.<br><br><b>More information:</b><br>%1")).arg(text));
QMessageBox::critical(0, tr("CloudDB Status"), QString(tr("<b><big>Service outage</big></b><br>Sorry - CloudDB services are not operational.<br><br><b>More information:</b><br>%1")).arg(text));
}


Expand Down
2 changes: 1 addition & 1 deletion src/Core/DataFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2948,5 +2948,5 @@ Result Leaf::eval(DataFilterRuntime *df, Leaf *leaf, float x, RideItem *m, RideF
default: // we don't need to evaluate any lower - they are leaf nodes handled above
break;
}
return Result(false);
return Result(0); // false
}
6 changes: 3 additions & 3 deletions src/Core/UserData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,15 +336,15 @@ UserData::setRideItem(RideItem*m)
{
rideItem = m;

// parse formula
DataFilter parser(this, rideItem->context, formula);

// clear what we got
vector.clear();

// if real ..
if (rideItem) {

// parse formula
DataFilter parser(this, rideItem->context, formula);

// is it cached ?
vector = rideItem->userCache.value(parser.signature(), QVector<double>());

Expand Down
3 changes: 2 additions & 1 deletion src/FileIO/Bin2RideFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ struct Bin2FileReaderState

Bin2FileReaderState(QFile &file, QStringList &errors) :
file(file), errors(errors), rideFile(NULL), secs(0), km(0),
interval(0), last_interval_secs(0.0), interval_offset(0), jouleGPS(true), jouleGPS_GPSPlus(true), stopped(true)
interval(0), last_interval_secs(0.0), interval_offset(0), jouleGPS(true), jouleGPS_GPSPlus(true),
stopped(true), data_version(0)
{

}
Expand Down
3 changes: 3 additions & 0 deletions src/FileIO/FitlogParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ FitlogParser::FitlogParser (RideFile* rideFile, QList<RideFile*> *rides)
: rideFile(rideFile), rides(rides)
{
first = true;
lap = 0;
track_offset = 0;

}

bool
Expand Down
2 changes: 1 addition & 1 deletion src/FileIO/RideFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ RideFile::updateDataTag()
else flags += '-';
if (areDataPresent()->rcontact ||
areDataPresent()->rvert ||
areDataPresent()->rcontact) flags += 'R'; // R is for running dynamics
areDataPresent()->rcad) flags += 'R'; // R is for running dynamics
else flags += '-';
setTag("Data", flags);
}
Expand Down
2 changes: 1 addition & 1 deletion src/FileIO/RideFileCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ void RideFileCache::fastSearch(QVector<int>&input, QVector<int>&ride_bests, QVec
else i += 300;
}
#ifdef Q_CC_MSVC
delete dataseries_i;
delete[] dataseries_i;
#endif

// since we minimise the search space over
Expand Down
4 changes: 4 additions & 0 deletions src/FileIO/SrmRideFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings, QL
// fail early to tell devs whats wrong with file
if( in.status() != QDataStream::Ok ){
errorStrings << QString("failed to read block headers" );
delete[] blockhdrs;
return NULL;
}

Expand All @@ -236,6 +237,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings, QL
// fail early to tell devs whats wrong with file
if( in.status() != QDataStream::Ok ){
errorStrings << QString("failed to read calibration data" );
delete[] blockhdrs;
return NULL;
}

Expand Down Expand Up @@ -353,6 +355,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings, QL

if( result->dataPoints().size() < 1 ){
errorStrings << QString("file contains no data points");
delete[] blockhdrs;
return NULL;
}

Expand All @@ -378,6 +381,7 @@ RideFile *SrmFileReader::openRideFile(QFile &file, QStringList &errorStrings, QL
}

file.close();
delete[] blockhdrs;
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions src/FileIO/TcxParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ TcxParser::endElement( const QString&, const QString&, const QString& qName)
double kph = (swim == Swim) ? speed : prevPoint->kph + (deltaSpeed *weight);
// need to make sure speed goes to zero
kph = kph > 0.35 ? kph : 0;
double cad = prevPoint->cad + (deltaCad * weight);
cad = cad > 0.35 ? cad : 0;
//double cad = prevPoint->cad + (deltaCad * weight);
//cad = cad > 0.35 ? cad : 0;
//double lat = prevPoint->lat + (deltaLat * weight);
//double lon = prevPoint->lon + (deltaLon * weight);

Expand Down
2 changes: 1 addition & 1 deletion src/Gui/AnalysisSidebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ AnalysisSidebar::showIntervalMenu(const QPoint &pos)

// what kind if interval are we looking at ?
RideFileInterval::IntervalType type = trees.key(root, static_cast<RideFileInterval::IntervalType>(-1));
bool isUser = interval->rideInterval != NULL;
//bool isUser = interval->rideInterval != NULL;

activeInterval = interval;
QMenu menu(intervalTree);
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/CompareInterval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
#include <QColor>

CompareInterval::CompareInterval(Context *context, QString name, RideFile *data, QColor color, Context *sourceContext, bool checked) :
context(context), name(name), data(data), color(color), sourceContext(sourceContext), checked(checked), cache(NULL)
context(context), name(name), rideItem(NULL), data(data), color(color), sourceContext(sourceContext), checked(checked), cache(NULL)
{
}

CompareInterval::CompareInterval() : context(NULL), data(NULL), sourceContext(NULL), checked(false), cache(NULL)
CompareInterval::CompareInterval() : context(NULL), rideItem(NULL), data(NULL), sourceContext(NULL), checked(false), cache(NULL)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Gui/Pages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6522,8 +6522,8 @@ AutoImportPage::saveClicked()
void
AutoImportPage::addRuleTypes(QComboBox *p) {

RideAutoImportRule* config = new RideAutoImportRule();
QList<QString> descriptions = config->getRuleDescriptions();
RideAutoImportRule config;
QList<QString> descriptions = config.getRuleDescriptions();

foreach(QString description, descriptions) {
p->addItem(description);
Expand Down
2 changes: 1 addition & 1 deletion src/Metrics/BasicRideMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class TimeCarrying : public RideMetric {

public:

TimeCarrying() : secsCarrying(0.0)
TimeCarrying() : secsCarrying(0.0), prevalt(0.0)
{
setSymbol("time_carrying");
setInternalName("Time Carrying");
Expand Down
2 changes: 1 addition & 1 deletion src/Metrics/ExtendedCriticalPower.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TestModel // : public PDModel
double paa, paa_dec, ecp, etau, ecp_del, tau_del, ecp_dec, ecp_dec_del, paa_pow;

// Parameters dan
double p1, t1, p2, t2, a2;
// double p1, t1, p2, t2, a2;

int pMax, mmp60;
};
Expand Down
17 changes: 11 additions & 6 deletions src/Metrics/PaceZones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <qcolor.h>
#include <assert.h>
#include <cmath>
#include <float.h>


// the infinity endpoints are indicated with extreme date ranges
Expand Down Expand Up @@ -720,16 +721,20 @@ QString PaceZones::summarize(int rnum, QVector<double> &time_in_zone, QColor col
double lo, hi;
zoneInfo(rnum, zone, name, desc, lo, hi);
if (zone % 2 == 0)
summary += "<tr bgcolor='" + color.name() + "'>"; else
summary += "<tr>"; summary += QString("<td align=\"center\">%1</td>").arg(name);
summary += "<tr bgcolor='" + color.name() + "'>";
else
summary += "<tr>";
summary += QString("<td align=\"center\">%1</td>").arg(name);
summary += QString("<td align=\"center\">%1</td>").arg(desc);
summary += QString("<td align=\"center\">%1</td>").arg(this->kphToPaceString(lo, metric));
if (hi == INT_MAX)
summary += "<td align=\"center\">MAX</td>"; else
if (hi == DBL_MAX)
summary += "<td align=\"center\">MAX</td>";
else
summary += QString("<td align=\"center\">%1</td>").arg(this->kphToPaceString(hi, metric));
summary += QString("<td align=\"center\">%1</td>").arg(time_to_string((unsigned) round(time_in_zone[zone])));
summary += QString("<td align=\"center\">%1</td>")
.arg((double)time_in_zone[zone]/duration * 100, 0, 'f', 0);
.arg(time_to_string((unsigned) round(time_in_zone[zone])));
summary += QString("<td align=\"center\">%1</td>")
.arg((double)time_in_zone[zone]/duration * 100, 0, 'f', 0);
summary += "</tr>";
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/Metrics/Zones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,16 +755,20 @@ QString Zones::summarize(int rnum, QVector<double> &time_in_zone, QColor color)
int lo, hi;
zoneInfo(rnum, zone, name, desc, lo, hi);
if (zone % 2 == 0)
summary += "<tr bgcolor='" + color.name() + "'>"; else
summary += "<tr>"; summary += QString("<td align=\"center\">%1</td>").arg(name);
summary += "<tr bgcolor='" + color.name() + "'>";
else
summary += "<tr>";
summary += QString("<td align=\"center\">%1</td>").arg(name);
summary += QString("<td align=\"center\">%1</td>").arg(desc);
summary += QString("<td align=\"center\">%1</td>").arg(lo);
if (hi == INT_MAX)
summary += "<td align=\"center\">MAX</td>"; else
summary += QString("<td align=\"center\">%1</td>").arg(hi); summary += QString("<td align=\"center\">%1</td>")
.arg(time_to_string((unsigned) round(time_in_zone[zone])));
summary += "<td align=\"center\">MAX</td>";
else
summary += QString("<td align=\"center\">%1</td>").arg(hi);
summary += QString("<td align=\"center\">%1</td>")
.arg((double)time_in_zone[zone]/duration * 100, 0, 'f', 0);
.arg(time_to_string((unsigned) round(time_in_zone[zone])));
summary += QString("<td align=\"center\">%1</td>")
.arg((double)time_in_zone[zone]/duration * 100, 0, 'f', 0);
summary += "</tr>";
}
}
Expand Down
Loading

0 comments on commit 13e78a5

Please sign in to comment.