From 026ce292fb242a1e084ec60c9b1a1bcc69b0452c Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Wed, 7 Jan 2026 21:51:19 -0300 Subject: [PATCH] Switch: Fix config defaults saving --- src/config.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/config.c b/src/config.c index a6087e555..4455f4ae4 100644 --- a/src/config.c +++ b/src/config.c @@ -886,18 +886,15 @@ load_network(void) } else strcpy(nc->host_dev_name, "none"); - sprintf(temp, "net_%02i_switch_group", c + 1); - net_cards_conf[c].switch_group = ini_section_get_int(cat, temp, 0); + sprintf(temp, "net_%02i_switch_group", c + 1); + nc->switch_group = ini_section_get_int(cat, temp, 0); - sprintf(temp, "net_%02i_promisc", c + 1); - net_cards_conf[c].promisc_mode = ini_section_get_int(cat, temp, 0); + sprintf(temp, "net_%02i_promisc", c + 1); + nc->promisc_mode = ini_section_get_int(cat, temp, 0); - sprintf(temp, "net_%02i_nrs_host", c + 1); - p = ini_section_get_string(cat, temp, NULL); - if (p != NULL) - strncpy(net_cards_conf[c].nrs_hostname, p, sizeof(net_cards_conf[c].nrs_hostname) - 1); - else - strncpy(net_cards_conf[c].nrs_hostname, "", sizeof(net_cards_conf[c].nrs_hostname) - 1); + sprintf(temp, "net_%02i_nrs_host", c + 1); + p = ini_section_get_string(cat, temp, NULL); + strncpy(nc->nrs_hostname, p ? p : "", sizeof(nc->nrs_hostname) - 1); sprintf(temp, "net_%02i_link", c + 1); nc->link_state = ini_section_get_int(cat, temp, @@ -2989,26 +2986,22 @@ save_network(void) ini_section_set_int(cat, temp, nc->link_state); sprintf(temp, "net_%02i_switch_group", c + 1); - if (nc->device_num == 0) + if (nc->switch_group == 0) ini_section_delete_var(cat, temp); else - ini_section_set_int(cat, temp, net_cards_conf[c].switch_group); + ini_section_set_int(cat, temp, nc->switch_group); sprintf(temp, "net_%02i_promisc", c + 1); - if (nc->device_num == 0) + if (nc->promisc_mode == 0) ini_section_delete_var(cat, temp); else - ini_section_set_int(cat, temp, net_cards_conf[c].promisc_mode); + ini_section_set_int(cat, temp, nc->promisc_mode); sprintf(temp, "net_%02i_nrs_host", c + 1); - if (nc->device_num == 0) + if (nc->nrs_hostname[0] == '\0') ini_section_delete_var(cat, temp); - else { - if (nc->nrs_hostname[0] != '\0') - ini_section_set_string(cat, temp, net_cards_conf[c].nrs_hostname); - else - ini_section_delete_var(cat, temp); - } + else + ini_section_set_string(cat, temp, net_cards_conf[c].nrs_hostname); } ini_delete_section_if_empty(config, cat);