mirror of
https://github.com/sheumann/hush.git
synced 2024-12-28 07:30:23 +00:00
ifupdown: small optimization (avoid doing useless work if we are
not going to update state file)
This commit is contained in:
parent
3c82e48923
commit
f92df58d3d
@ -1239,8 +1239,10 @@ int ifupdown_main(int argc, char **argv)
|
|||||||
if (!okay && !FORCE) {
|
if (!okay && !FORCE) {
|
||||||
bb_error_msg("ignoring unknown interface %s", liface);
|
bb_error_msg("ignoring unknown interface %s", liface);
|
||||||
any_failures = 1;
|
any_failures = 1;
|
||||||
} else {
|
} else if (!NO_ACT) {
|
||||||
/* update the state file */
|
/* update the state file */
|
||||||
|
FILE *state_fp;
|
||||||
|
llist_t *state;
|
||||||
llist_t *state_list = read_iface_state();
|
llist_t *state_list = read_iface_state();
|
||||||
llist_t *iface_state = find_iface_state(state_list, iface);
|
llist_t *iface_state = find_iface_state(state_list, iface);
|
||||||
|
|
||||||
@ -1259,9 +1261,8 @@ int ifupdown_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Actually write the new state */
|
/* Actually write the new state */
|
||||||
if (!NO_ACT) {
|
state_fp = xfopen("/var/run/ifstate", "w");
|
||||||
FILE *state_fp = xfopen("/var/run/ifstate", "w");
|
state = state_list;
|
||||||
llist_t *state = state_list;
|
|
||||||
while (state) {
|
while (state) {
|
||||||
if (state->data) {
|
if (state->data) {
|
||||||
fprintf(state_fp, "%s\n", state->data);
|
fprintf(state_fp, "%s\n", state->data);
|
||||||
@ -1269,7 +1270,6 @@ int ifupdown_main(int argc, char **argv)
|
|||||||
state = state->link;
|
state = state->link;
|
||||||
}
|
}
|
||||||
fclose(state_fp);
|
fclose(state_fp);
|
||||||
}
|
|
||||||
llist_free(state_list, free);
|
llist_free(state_list, free);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user