From: Kevin Day Date: Tue, 30 May 2023 22:41:19 +0000 (-0500) Subject: Regression: Incorrect parameter location used, breaking parameter processing. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=ccd39b9b10b5fa05f511adcc8cee5e942a6f596d;p=fll Regression: Incorrect parameter location used, breaking parameter processing. The regression is introduced in commit 4c0ca86048e431de2025c39a3f5078b7248192eb. I completely forgot that "location" is for the parameter location and is not the last value location. Some part of me wanted a last value location. Revert back to using "values.used - 1" instead of "location". --- diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index b017991..fa06937 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -184,7 +184,7 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_width_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[byte_dump_parameter_width_e].values.array[main->parameters.array[byte_dump_parameter_width_e].location]; + const f_array_length_t index = main->parameters.array[byte_dump_parameter_width_e].values.array[main->parameters.array[byte_dump_parameter_width_e].values.used - 1]; f_number_unsigned_t number = 0; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); @@ -223,7 +223,7 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_first_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[byte_dump_parameter_first_e].values.array[main->parameters.array[byte_dump_parameter_first_e].location]; + const f_array_length_t index = main->parameters.array[byte_dump_parameter_first_e].values.array[main->parameters.array[byte_dump_parameter_first_e].values.used - 1]; f_number_unsigned_t number = 0; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); @@ -262,7 +262,7 @@ extern "C" { } if (main->parameters.array[byte_dump_parameter_last_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[byte_dump_parameter_last_e].values.array[main->parameters.array[byte_dump_parameter_last_e].location]; + const f_array_length_t index = main->parameters.array[byte_dump_parameter_last_e].values.array[main->parameters.array[byte_dump_parameter_last_e].values.used - 1]; f_number_unsigned_t number = 0; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &number); diff --git a/level_3/control/c/control.c b/level_3/control/c/control.c index 87b5db1..b8d8e4d 100644 --- a/level_3/control/c/control.c +++ b/level_3/control/c/control.c @@ -110,7 +110,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[ids[i]].result & f_console_result_value_e) { - index = main->parameters.array[ids[i]].values.array[main->parameters.array[ids[i]].location]; + index = main->parameters.array[ids[i]].values.array[main->parameters.array[ids[i]].values.used - 1]; if (!main->parameters.arguments.array[index].used) { control_print_error_parameter_value_empty(main, names[i]); diff --git a/level_3/control/c/private-control.c b/level_3/control/c/private-control.c index afbbd50..df063c0 100644 --- a/level_3/control/c/private-control.c +++ b/level_3/control/c/private-control.c @@ -615,7 +615,7 @@ extern "C" { data->cache.small.used = 0; if (main->parameters.array[control_parameter_settings_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[control_parameter_settings_e].values.array[main->parameters.array[control_parameter_settings_e].location]; + const f_array_length_t index = main->parameters.array[control_parameter_settings_e].values.array[main->parameters.array[control_parameter_settings_e].values.used - 1]; status = f_string_dynamic_append(data->argv[index], &data->cache.small); } @@ -707,7 +707,7 @@ extern "C" { data->cache.small.used = 0; if (main->parameters.array[control_parameter_socket_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[control_parameter_socket_e].values.array[main->parameters.array[control_parameter_socket_e].location]; + const f_array_length_t index = main->parameters.array[control_parameter_socket_e].values.array[main->parameters.array[control_parameter_socket_e].values.used - 1]; status = f_string_dynamic_append(data->argv[index], &data->cache.small); } @@ -772,7 +772,7 @@ extern "C" { for (uint8_t i = 0; i < 3; ++i) { if (append_ids[i] && main->parameters.array[append_ids[i]].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[append_ids[i]].values.array[main->parameters.array[append_ids[i]].location]; + const f_array_length_t index = main->parameters.array[append_ids[i]].values.array[main->parameters.array[append_ids[i]].values.used - 1]; status = f_string_dynamic_append(data->argv[index], &data->cache.small); } diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index 4b87622..85f2fd3 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -144,7 +144,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[controller_parameter_settings_e].locations.used) { - const f_array_length_t index = main->parameters.array[controller_parameter_settings_e].values.array[main->parameters.array[controller_parameter_settings_e].location]; + const f_array_length_t index = main->parameters.array[controller_parameter_settings_e].values.array[main->parameters.array[controller_parameter_settings_e].values.used - 1]; status = controller_path_canonical_relative(&setting, argv[index], &setting.path_setting); @@ -185,7 +185,7 @@ extern "C" { else if (main->parameters.array[controller_parameter_pid_e].locations.used) { setting.path_pid.used = 0; - const f_array_length_t index = main->parameters.array[controller_parameter_pid_e].values.array[main->parameters.array[controller_parameter_pid_e].location]; + const f_array_length_t index = main->parameters.array[controller_parameter_pid_e].values.array[main->parameters.array[controller_parameter_pid_e].values.used - 1]; if (argv[index].used) { status = controller_path_canonical_relative(&setting, argv[index], &setting.path_pid); @@ -241,7 +241,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[controller_parameter_cgroup_e].locations.used) { - const f_array_length_t index = main->parameters.array[controller_parameter_cgroup_e].values.array[main->parameters.array[controller_parameter_cgroup_e].location]; + const f_array_length_t index = main->parameters.array[controller_parameter_cgroup_e].values.array[main->parameters.array[controller_parameter_cgroup_e].values.used - 1]; if (argv[index].used) { status = controller_path_canonical_relative(&setting, argv[index], &setting.path_cgroup); diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 9b9b94f..dabdae7 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -2218,7 +2218,7 @@ extern "C" { if (f_compare_dynamic_partial_string(options[i].string, source, options[i].used, content) == F_equal_to) { if (values[i]) { if (parameters->array[codes[i]].result & f_console_result_value_e) { - const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].location]; + const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].values.used - 1]; status = f_string_dynamic_increase_by(symbols[i].used + expands[i].used + f_string_ascii_space_s.used + argv[index].used + 1, destination); if (F_status_is_error(status)) return status; @@ -2290,7 +2290,7 @@ extern "C" { if (f_compare_dynamic_partial_string(buffer.string, source, buffer.used, content) == F_equal_to) { if (parameters->array[codes[i]].result & f_console_result_value_e) { - const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].location]; + const f_array_length_t index = parameters->array[codes[i]].values.array[parameters->array[codes[i]].values.used - 1]; status = f_string_dynamic_append(argv[index], destination); if (F_status_is_error(status)) return status; diff --git a/level_3/fake/c/main/common.c b/level_3/fake/c/main/common.c index 55ae3d9..5be6e32 100644 --- a/level_3/fake/c/main/common.c +++ b/level_3/fake/c/main/common.c @@ -248,7 +248,7 @@ extern "C" { } if (main->program.parameters.array[parameters[i]].result & f_console_result_value_e) { - index = main->program.parameters.array[parameters[i]].values.array[main->program.parameters.array[parameters[i]].location; + index = main->program.parameters.array[parameters[i]].values.array[main->program.parameters.array[parameters[i]].values.used - 1]; if (main->program.parameters.arguments.array[index].used) { if (parameters[i] == fake_parameter_process_e) { diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index c594875..5eaa402 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -274,7 +274,7 @@ extern "C" { f_status_t fss_basic_list_read_load_number(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index 492df15..b69d1da 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -259,7 +259,7 @@ extern "C" { f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index 5264b1b..b6bd4fb 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -299,7 +299,7 @@ extern "C" { f_number_unsigned_t select = 0; if (data->main->parameters.array[fss_embedded_list_read_parameter_select_e].result & f_console_result_value_e) { - const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_select_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_select_e].location]; + const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_select_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_select_e].values.used - 1]; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->main->parameters.arguments.array[index], &select); @@ -319,7 +319,7 @@ extern "C" { f_array_length_t line = 0; if (data->main->parameters.array[fss_embedded_list_read_parameter_line_e].result & f_console_result_value_e) { - const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_line_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_line_e].location]; + const f_array_length_t index = data->main->parameters.array[fss_embedded_list_read_parameter_line_e].values.array[data->main->parameters.array[fss_embedded_list_read_parameter_line_e].values.used - 1]; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->main->parameters.arguments.array[index], &line); diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index 1e52bf3..be48d0d 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -281,7 +281,7 @@ extern "C" { f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 6bc276f..7e62094 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -103,7 +103,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_identify_parameter_line_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[fss_identify_parameter_line_e].values.array[main->parameters.array[fss_identify_parameter_line_e].location]; + const f_array_length_t index = main->parameters.array[fss_identify_parameter_line_e].values.array[main->parameters.array[fss_identify_parameter_line_e].values.used - 1]; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data.argv[index], &data.line); @@ -143,7 +143,7 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_identify_parameter_name_e].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[fss_identify_parameter_name_e].values.array[main->parameters.array[fss_identify_parameter_name_e].location]; + const f_array_length_t index = main->parameters.array[fss_identify_parameter_name_e].values.array[main->parameters.array[fss_identify_parameter_name_e].values.used - 1]; const f_array_length_t length = data.argv[index].used; const f_string_range_t range = macro_f_string_range_t_initialize_2(length); diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index d52f087..14d0888 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -300,7 +300,7 @@ extern "C" { f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { if (main->parameters.array[parameter].result & f_console_result_value_e) { - const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].location]; + const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; const f_status_t status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, data->argv[index], number); diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index 7e2e8c5..6b2b4c8 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -486,7 +486,7 @@ extern "C" { const f_string_static_t *prepend = 0; if (main->setting.flag & fss_write_main_flag_prepend_e) { - const f_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].location]; + const f_array_length_t index = main->program.parameters.array[fss_write_parameter_prepend_e].values.array[main->program.parameters.array[fss_write_parameter_prepend_e].values.used - 1]; prepend = &main->program.parameters.arguments.array[index]; } diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index 1beaa74..29aa088 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -129,7 +129,7 @@ extern "C" { return; } - const f_array_length_t index = main->program.parameters.array[iki_read_parameter_at_e].values.array[main->program.parameters.array[iki_read_parameter_at_e].location]; + const f_array_length_t index = main->program.parameters.array[iki_read_parameter_at_e].values.array[main->program.parameters.array[iki_read_parameter_at_e].values.used - 1]; main->setting.at = 0; @@ -162,7 +162,7 @@ extern "C" { } if (main->program.parameters.array[iki_read_parameter_line_e].result & f_console_result_value_e) { - const f_array_length_t index = main->program.parameters.array[iki_read_parameter_line_e].values.array[main->program.parameters.array[iki_read_parameter_line_e].location]; + const f_array_length_t index = main->program.parameters.array[iki_read_parameter_line_e].values.array[main->program.parameters.array[iki_read_parameter_line_e].values.used - 1]; main->setting.line = 0;