mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 07:50:16 +01:00
nm-cloud-setup: simplify clearing variables in retry loop
The label "try_again" is only reached by one goto. So it was correct
and sufficient to reset the state only there.
It is still error prone. The slighlty clearer approach is to clear
the state at each begin of the "try_again" step.
There should be no change in behavior.
I didn't confirm, but an optimizing compiler should (could) be able
to see that the cleanup is only necessary on retry, and generate the
same code as before. In any case, we should write code that is easier
to read, not optimize for something that a compiler should be able to
optimize itself.
(cherry picked from commit 911b550140)
This commit is contained in:
parent
467c028ac1
commit
5608070764
1 changed files with 2 additions and 2 deletions
|
|
@ -494,6 +494,8 @@ _config_one(GCancellable *sigterm_cancellable,
|
|||
try_count = 0;
|
||||
|
||||
try_again:
|
||||
g_clear_object(&applied_connection);
|
||||
g_clear_error(&error);
|
||||
|
||||
applied_connection = nmcs_device_get_applied_connection(device,
|
||||
sigterm_cancellable,
|
||||
|
|
@ -567,8 +569,6 @@ try_again:
|
|||
&error)) {
|
||||
if (version_id_changed && try_count < 5) {
|
||||
_LOGD("config device %s: applied connection changed in the meantime. Retry...", hwaddr);
|
||||
g_clear_object(&applied_connection);
|
||||
g_clear_error(&error);
|
||||
try_count++;
|
||||
goto try_again;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue