Skip to content
  • James McCoy's avatar
    nm-online: return from quit_if_connected after setting retval · dbd365c3
    James McCoy authored and Thomas Haller's avatar Thomas Haller committed
    c5f17a97 changed nm-online to determine
    the status asynchronously, however this introduced a regression with
    "nm-online -x -q" when there is connectivity.
    
            if (   state == NM_STATE_CONNECTED_LOCAL
                || state == NM_STATE_CONNECTED_SITE
                || state == NM_STATE_CONNECTED_GLOBAL) {
                data->retval = 0;
                g_main_loop_quit (data->loop);
            }
        }
        if (data->exit_no_nm && (state != NM_STATE_CONNECTING)) {
            data->retval = 1;
            g_main_loop_quit (data->loop);
        }
    
    After setting data->retval = 0 in the "state is connected" branch, the
    function falls through to the "exit_no_nm and !connecting" branch,
    overwriting data->retval.  This causes "nm-online -x -q" to incorrectly
    report an offline state.
    
    Adding an explicit "return;" after any state where data->retval is set
    ensures that the value isn't overwritten before main() uses it.
    
    Fixes: c5f17a97
    
    https://mail.gnome.org/archives/networkmanager-list/2017-January/msg00058.html
    dbd365c3