After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 778302 - Unreachable code warnings on returning async results
Unreachable code warnings on returning async results
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Code Generator: GAsync
0.35.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2017-02-07 19:02 UTC by Carlos Garnacho
Modified: 2017-02-14 06:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
reproducer (336 bytes, text/plain)
2017-02-07 19:02 UTC, Carlos Garnacho
  Details
codegen: Don't create duplicated complete-async code (1.08 KB, patch)
2017-02-13 16:35 UTC, Rico Tzschichholz
committed Details | Review

Description Carlos Garnacho 2017-02-07 19:02:05 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.
Comment 1 Rico Tzschichholz 2017-02-13 16:35:20 UTC
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.