large number of "control reaches end of non-void function" warnings

• Mar 5, 2012 - 17:13
Type
Functional
Severity
S4 - Minor
Status
closed
Project

While this is not a critical issue, it does make building MuseScore more difficult when a problem occurs since it significantly increases the amount of output that needs to be sifted through. Many of these warnings result from code such as this:

{
QScriptValue _q_function = __qtscript_self.property("aliases");
if (!_q_function.isFunction() || QTSCRIPT_IS_GENERATED_FUNCTION(_q_function)
|| (__qtscript_self.propertyFlags("aliases") & QScriptValue::QObjectMember)) {
qFatal("QTextCodecPlugin::aliases() is abstract!");
} else {
return qscriptvalue_cast >(_q_function.call(__qtscript_self));
}
}

Since qFatal function calls the mscoreMessageHandler function with the message type set to QtFatalMsg, the qFatal call will never return. While this means that the end of the non-void function will never be reached, the compiler doesn't know this. It also makes the "else" clause unnecessary. The solution is to simply remove the else clause and let execution encounter the return before the end of the function and the associated warnings go away. Thus:

{
QScriptValue _q_function = __qtscript_self.property("aliases");
if (!_q_function.isFunction() || QTSCRIPT_IS_GENERATED_FUNCTION(_q_function)
|| (__qtscript_self.propertyFlags("aliases") & QScriptValue::QObjectMember)) {
qFatal("QTextCodecPlugin::aliases() is abstract!");
}
return qscriptvalue_cast >(_q_function.call(__qtscript_self));
}


Comments

The warnings are related to the qt bindings for the script interface. This is all generated code included for the convenience of building MuseScore. The current source for the scriptgenerator itself is in http://qt.gitorious.org/qt-labs/qtscriptgenerator.
The real fix would be to use the latest version of this scriptgenerator, fix it (if not already done) and create a new version ot the script interface. I believe its not worth the effort to avoid some compiler warnings.