GNOME Bugzilla – Bug 778302
Unreachable code warnings on returning async results
Last modified: 2017-02-14 06:54:54 UTC
Created attachment 345135 [details] reproducer When Vala generates the _co() function finishing the async operation and giving the GAsyncResult the result, it somehow generates repeated code, for the example attachment: static gboolean foo_bar_co (FooBarData* _data_) { ... if (_data_->_state_ == 0) { g_simple_async_result_complete_in_idle (_data_->_async_result); } else { g_simple_async_result_complete (_data_->_async_result); } g_object_unref (_data_->_async_result); return FALSE; if (_data_->_state_ == 0) { g_simple_async_result_complete_in_idle (_data_->_async_result); } else { g_simple_async_result_complete (_data_->_async_result); } g_object_unref (_data_->_async_result); return FALSE; } (FWIW, it's the same with --target-glib=2.36 and GTask). The repeated code is unneeded and unreachable. This happens to trigger numerous "Structurally dead code" warnings for Tracker in Coverity. The CIDs are: 1388725, 1388720, 1388503, 1388498, 1388496, 1388495, 1388494, 1388493, 1388724, 1388513, 1388507, 1388506, 1388505, 1388502, 1388501, 1388499, 1388497, 1388491, 1388490, 1388489, 1388488, 1388487, 1388486, 1388485.
Created attachment 345646 [details] [review] codegen: Don't create duplicated complete-async code Treat methods with non-void return-type special while they require a return statement. This does not account for a trailing superfluous "return" which will still trigger this code-duplication.