From 5723c53708559d6e016ddcba53d9f5302493675c Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Mon, 9 Jan 2017 10:44:00 +0100 Subject: moc: Don't test _id if there are no methods or properties This is unnecessary (as the fallback behavior is return _id anyway), and it makes coverity unhappy. Coverity-Id: 173293 Change-Id: I91c016f3ed363319c6413ab3c2688698faf4f10f Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/tools/moc/generator.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 016ac97228..674398e783 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -918,8 +918,6 @@ void Generator::generateMetacall() fprintf(out, " _id = %s::qt_metacall(_c, _id, _a);\n", superClass.constData()); } - fprintf(out, " if (_id < 0)\n return _id;\n"); - fprintf(out, " "); bool needElse = false; QVector methodList; @@ -927,6 +925,15 @@ void Generator::generateMetacall() methodList += cdef->slotList; methodList += cdef->methodList; + // If there are no methods or properties, we will return _id anyway, so + // don't emit this comparison -- it is unnecessary, and it makes coverity + // unhappy. + if (methodList.size() || cdef->propertyList.size()) { + fprintf(out, " if (_id < 0)\n return _id;\n"); + } + + fprintf(out, " "); + if (methodList.size()) { needElse = true; fprintf(out, "if (_c == QMetaObject::InvokeMetaMethod) {\n"); -- cgit v1.2.3