cli: remove redundant return value from NMCCommand funcs

Many func implementations are asynchronous, that means, they
cannot return right away. Instead, they record the return value
in nmc->result_value.

The return value from the command functions was thus redundant.
In the best case, the return value agrees with the cached result
in nmc->result_value, in which it was unnecessary. In the worst case,
they disagree, and overwrite each other.

nmc->result_value is state. Tracking state is hard, and there should
be fewer places where the state gets mutated. Also, the rules how that
happened should be clearer. Drop the redundant, conflicting mechanism.
This commit is contained in:
Thomas Haller
2020-04-05 15:36:30 +02:00
parent c5d45848dd
commit aede8fa554
6 changed files with 308 additions and 313 deletions

View File

@@ -1264,7 +1264,7 @@ call_cmd (NmCli *nmc, GTask *task, const NMCCommand *cmd, int argc, const char *
g_task_return_new_error (task, NMCLI_ERROR, NMC_RESULT_ERROR_NM_NOT_RUNNING,
_("Error: NetworkManager is not running."));
} else {
nmc->return_value = cmd->func (cmd, nmc, argc, argv);
cmd->func (cmd, nmc, argc, argv);
g_task_return_boolean (task, TRUE);
}