From b7b17e719ea57f2d697bc0f61bffaa0fab910701 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 11 May 2020 13:53:32 +0200 Subject: [PATCH] Fix coverity warnings about uninitialized data members Coverity alerts about uninitialized members. While this might be ok in the code here (ie TreeNode::splitLeft is never used for leaf nodes) it can easily result in undefined behavior and other hard-to-debug issues. Initializing the struct with initializer syntax; compiler explorer indicates that the compile will be able to optimze the calls to avoid duplicate initialization of data members. Change-Id: I0eb5d26e34f466d8c659c1945f02601aef511fbf Fixes: QTBUG-84160 Fixes: QTBUG-84156 Coverity-Id: 218601 Coverity-Id: 11398 Pick-to: 5.15 Reviewed-by: Marc Mutz --- src/gui/painting/qpathclipper.cpp | 2 +- src/gui/painting/qtriangulator.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 1a1b2d76e29..2fbf8bdcba7 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -316,7 +316,7 @@ static inline qreal coordinate(const QPointF &pos, int axis) TreeNode SegmentTree::buildTree(int first, int last, int depth, const RectF &bounds) { if (depth >= 24 || (last - first) <= 10) { - TreeNode node; + TreeNode node = {}; node.leaf = true; node.index.interval.first = first; node.index.interval.last = last; diff --git a/src/gui/painting/qtriangulator.cpp b/src/gui/painting/qtriangulator.cpp index ec3ab8ff8f7..eab06d4d4ce 100644 --- a/src/gui/painting/qtriangulator.cpp +++ b/src/gui/painting/qtriangulator.cpp @@ -1985,7 +1985,7 @@ void QTriangulator::SimpleToMonotone::createDiagonal(int lower, int upper) int prevLower = m_edges.at(lower).previous; int prevUpper = m_edges.at(upper).previous; - Edge e; + Edge e = {}; e.twin = m_edges.size() + 1; e.next = upper;