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 <marc.mutz@kdab.com>
This commit is contained in:
Volker Hilsheimer 2020-05-11 13:53:32 +02:00
parent 902120c621
commit b7b17e719e
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -1985,7 +1985,7 @@ void QTriangulator<T>::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;