summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenis Vlasenko2007-05-02 22:22:23 +0000
committerDenis Vlasenko2007-05-02 22:22:23 +0000
commitf92df58d3d97bb75d7b12437d53dd97acfd01095 (patch)
treedc1e2cf0f99773cae06fc7b0dd81b711a08f50f0 /networking
parent3c82e48923b4b4343cbca2fb0981bc2a8a4ac009 (diff)
downloadbusybox-f92df58d3d97bb75d7b12437d53dd97acfd01095.zip
busybox-f92df58d3d97bb75d7b12437d53dd97acfd01095.tar.gz
ifupdown: small optimization (avoid doing useless work if we are
not going to update state file)
Diffstat (limited to 'networking')
-rw-r--r--networking/ifupdown.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 0c822e2..5b22517 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1239,8 +1239,10 @@ int ifupdown_main(int argc, char **argv)
if (!okay && !FORCE) {
bb_error_msg("ignoring unknown interface %s", liface);
any_failures = 1;
- } else {
+ } else if (!NO_ACT) {
/* update the state file */
+ FILE *state_fp;
+ llist_t *state;
llist_t *state_list = read_iface_state();
llist_t *iface_state = find_iface_state(state_list, iface);
@@ -1259,17 +1261,15 @@ int ifupdown_main(int argc, char **argv)
}
/* Actually write the new state */
- if (!NO_ACT) {
- FILE *state_fp = xfopen("/var/run/ifstate", "w");
- llist_t *state = state_list;
- while (state) {
- if (state->data) {
- fprintf(state_fp, "%s\n", state->data);
- }
- state = state->link;
+ state_fp = xfopen("/var/run/ifstate", "w");
+ state = state_list;
+ while (state) {
+ if (state->data) {
+ fprintf(state_fp, "%s\n", state->data);
}
- fclose(state_fp);
+ state = state->link;
}
+ fclose(state_fp);
llist_free(state_list, free);
}
}