From 76d94eda235fe0883d88982ad55cef0c0cf9014b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 2 Jan 2021 21:53:17 +0100 Subject: statistics: silence two Coverity warnings Two warnings concerning division by zero and non-initialization of a member variable, respectively. Both are false positives. However, Coverity is excused because it probably doesn't understand std::vector<> and also can't know whether the object in question is generated in a different source file. Signed-off-by: Berthold Stoeger --- stats/legend.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'stats/legend.cpp') diff --git a/stats/legend.cpp b/stats/legend.cpp index 7418df9df..927e972c8 100644 --- a/stats/legend.cpp +++ b/stats/legend.cpp @@ -32,7 +32,9 @@ Legend::Legend(QGraphicsWidget *chart, const std::vector &names) : e.width = fontHeight + 2.0 * legendBoxBorderSize + fm.size(Qt::TextSingleLine, e.text->text()).width(); } else { - fontHeight = 0.0; + // Set to an arbitrary non-zero value, because Coverity doesn't understand + // that we don't use the value as divisor below if entries is empty. + fontHeight = 10.0; } setPen(QPen(legendBorderColor, legendBorderSize)); setBrush(QBrush(legendColor)); @@ -42,7 +44,8 @@ Legend::Legend(QGraphicsWidget *chart, const std::vector &names) : Legend::Entry::Entry(const QString &name, int idx, int numBins, QGraphicsItem *parent) : rect(new QGraphicsRectItem(parent)), - text(new QGraphicsSimpleTextItem(name, parent)) + text(new QGraphicsSimpleTextItem(name, parent)), + width(0) { rect->setZValue(ZValues::legend); rect->setPen(QPen(legendBorderColor, legendBoxBorderSize)); -- cgit v1.2.3-70-g09d2