AmendHub

Download:

jcs

/

subtext

/

amendments

/

536

sysop: Rename old_config_data to cur_config_data

It was confusing me why we were copying new data into an "old"
struct.

jcs made amendment 536 about 1 year ago
--- sysop.c Thu Nov 9 17:25:12 2023 +++ sysop.c Sun Nov 12 11:23:05 2023 @@ -138,9 +138,9 @@ sysop_menu(struct session *s) void sysop_edit_settings(struct session *s) { - struct config *new_config, old_config; + struct config *new_config; const struct struct_field *sf; - char *new_config_data, *old_config_data; + char *new_config_data, *cur_config_data; short ret, n, nsval, osval; unsigned long nlval, olval; unsigned short reinits = 0; @@ -155,19 +155,17 @@ sysop_edit_settings(struct session *s) session_printf(s, "No changes made\r\n"); return; } - - memcpy(&old_config, &db->config, sizeof(db->config)); for (n = 0; n < nconfig_fields; n++) { sf = &config_fields[n]; - old_config_data = (char *)&db->config + sf->off; + cur_config_data = (char *)&db->config + sf->off; new_config_data = (char *)new_config + sf->off; switch (sf->type) { case CONFIG_TYPE_STRING: case CONFIG_TYPE_PASSWORD: - if (memcmp(old_config_data, new_config_data, sf->max) == 0) + if (memcmp(cur_config_data, new_config_data, sf->max) == 0) goto next_field; if (sf->type == CONFIG_TYPE_PASSWORD) @@ -175,12 +173,12 @@ sysop_edit_settings(struct session *s) sf->name); else session_logf(s, "Changed BBS setting \"%s\" from \"%s\" " - "to \"%s\"", sf->name, old_config_data, new_config_data); + "to \"%s\"", sf->name, cur_config_data, new_config_data); - memcpy(old_config_data, new_config_data, sf->max); + memcpy(cur_config_data, new_config_data, sf->max); break; case CONFIG_TYPE_SHORT: - osval = CHARS_TO_SHORT(old_config_data[0], old_config_data[1]); + osval = CHARS_TO_SHORT(cur_config_data[0], cur_config_data[1]); nsval = CHARS_TO_SHORT(new_config_data[0], new_config_data[1]); if (nsval == osval) @@ -189,11 +187,11 @@ sysop_edit_settings(struct session *s) session_logf(s, "Changed BBS setting \"%s\" from %d to %d", sf->name, osval, nsval); - memcpy(old_config_data, new_config_data, sizeof(short)); + memcpy(cur_config_data, new_config_data, sizeof(short)); break; case CONFIG_TYPE_LONG: - olval = CHARS_TO_LONG(old_config_data[0], old_config_data[1], - old_config_data[2], old_config_data[3]); + olval = CHARS_TO_LONG(cur_config_data[0], cur_config_data[1], + cur_config_data[2], cur_config_data[3]); nlval = CHARS_TO_LONG(new_config_data[0], new_config_data[1], new_config_data[2], new_config_data[3]); if (olval == nlval) @@ -202,32 +200,32 @@ sysop_edit_settings(struct session *s) session_logf(s, "Changed BBS setting \"%s\" from %lu to %lu", sf->name, olval, nlval); - memcpy(old_config_data, new_config_data, sizeof(long)); + memcpy(cur_config_data, new_config_data, sizeof(long)); break; case CONFIG_TYPE_BOOLEAN: - if (old_config_data[0] == new_config_data[0]) + if (cur_config_data[0] == new_config_data[0]) goto next_field; session_logf(s, "Changed BBS setting \"%s\" from %s to %s", - sf->name, old_config_data[0] ? "true" : "false", + sf->name, cur_config_data[0] ? "true" : "false", new_config_data[0] ? "true" : "false"); - memcpy(old_config_data, new_config_data, 1); + memcpy(cur_config_data, new_config_data, 1); break; case CONFIG_TYPE_IP: { - char old_ip_str[16], new_ip_str[16]; + char cur_ip_str[16], new_ip_str[16]; - olval = CHARS_TO_LONG(old_config_data[0], old_config_data[1], - old_config_data[2], old_config_data[3]); + olval = CHARS_TO_LONG(cur_config_data[0], cur_config_data[1], + cur_config_data[2], cur_config_data[3]); nlval = CHARS_TO_LONG(new_config_data[0], new_config_data[1], new_config_data[2], new_config_data[3]); if (olval == nlval) goto next_field; if (olval == 0) - snprintf(old_ip_str, sizeof(old_ip_str), "(None)"); + snprintf(cur_ip_str, sizeof(cur_ip_str), "(None)"); else - long2ip(olval, old_ip_str); + long2ip(olval, cur_ip_str); if (nlval == 0) snprintf(new_ip_str, sizeof(new_ip_str), "(None)"); @@ -235,9 +233,9 @@ sysop_edit_settings(struct session *s) long2ip(nlval, new_ip_str); session_logf(s, "Changed BBS setting \"%s\" from %s to %s", - sf->name, old_ip_str, new_ip_str); + sf->name, cur_ip_str, new_ip_str); - memcpy(old_config_data, new_config_data, sizeof(long)); + memcpy(cur_config_data, new_config_data, sizeof(long)); break; } }