mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 18:08:05 +02: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.
This commit is contained in:
parent
bbd32fba15
commit
911b550140
1 changed files with 2 additions and 2 deletions
|
|
@ -493,6 +493,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,
|
||||
|
|
@ -565,8 +567,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