From: Kevin Day Date: Thu, 9 Mar 2023 02:55:09 +0000 (-0600) Subject: Cleanup: Remove dead code in controller program. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=457784b895337ddaf948c05e7fa0cf1291792291;p=fll Cleanup: Remove dead code in controller program. The process variable is not used. Remove all of the dead code. --- diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index 47be22d..d1e8c92 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -850,7 +850,6 @@ extern "C" { controller_entry_t *entry = is_entry ? &global->setting->entry : &global->setting->exit; controller_entry_action_t *entry_action = 0; controller_entry_actions_t *entry_actions = 0; - controller_process_t *process = 0; // An empty stack is used here because each rule here is the first rule run in the rule's scope. const f_array_lengths_t stack = f_array_lengths_t_initialize; @@ -1017,7 +1016,7 @@ extern "C" { } if (!(global->main->parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) { - status = controller_rule_wait_all(*global, is_entry, F_false, process); + status = controller_rule_wait_all(*global, is_entry, F_false); if (F_status_is_error(status)) return status; } } @@ -1325,7 +1324,7 @@ extern "C" { if (global->main->parameters.array[controller_parameter_simulate_e].result & f_console_result_found_e) return F_execute; - controller_thread_process_cancel(*global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e, process); + controller_thread_process_cancel(*global, is_entry, is_entry ? controller_thread_cancel_execute_e : controller_thread_cancel_exit_execute_e); int result = 0; int option = FL_execute_parameter_option_path_d; @@ -1487,7 +1486,7 @@ extern "C" { // Check to see if any required processes failed, but do not do this if already operating in failsafe. if (F_status_is_error_not(status) && !failsafe && !(global->main->parameters.array[controller_parameter_validate_e].result & f_console_result_found_e)) { - const f_status_t status_wait = controller_rule_wait_all(*global, is_entry, F_true, 0); + const f_status_t status_wait = controller_rule_wait_all(*global, is_entry, F_true); if (F_status_is_error(status_wait)) return status_wait; if (status_wait == F_require) return F_status_set_error(F_require); } diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index 04481f5..8c54cb9 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -6177,16 +6177,9 @@ extern "C" { #endif // _di_controller_rule_validate_ #ifndef _di_controller_rule_wait_all_ - f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required, controller_process_t * const caller) { + f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required) { - f_status_t status_lock = F_none; - - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.process); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process); - } + f_status_t status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process); if (F_status_is_error(status_lock)) { controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_true, global.thread); @@ -6220,21 +6213,10 @@ extern "C" { for (i = 0; i < process_total; ++i) { - if (caller) { - if (!controller_thread_is_enabled_process(caller, global.thread)) break; - } - else { - if (!controller_thread_is_enabled(is_normal, global.thread)) break; - } + if (!controller_thread_is_enabled(is_normal, global.thread)) break; // Re-establish global process read lock to wait for or protect from the cleanup thread while checking the read process. - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.process); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process); - } - + status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.process); if (F_status_is_error(status_lock)) break; if (!process_list[i]) { @@ -6243,12 +6225,7 @@ extern "C" { continue; } - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->active); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active); - } + status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active); if (F_status_is_error(status_lock)) { f_thread_unlock(&global.thread->lock.process); @@ -6259,60 +6236,7 @@ extern "C" { // Once the active lock is obtained, then the main process read lock can be safely released. f_thread_unlock(&global.thread->lock.process); - if (caller) { - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &global.thread->lock.rule); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &global.thread->lock.rule); - } - - if (F_status_is_error(status_lock)) { - f_thread_unlock(&process_list[i]->active); - - break; - } - - if (fl_string_dynamic_compare(caller->rule.alias, process_list[i]->rule.alias) == F_equal_to) { - f_thread_unlock(&global.thread->lock.rule); - f_thread_unlock(&process_list[i]->active); - - continue; - } - - skip = F_false; - - for (j = 0; j < caller->stack.used; ++j) { - - if (caller) { - if (!controller_thread_is_enabled_process(caller, global.thread)) break; - } - else { - if (!controller_thread_is_enabled(is_normal, global.thread)) break; - } - - if (global.thread->processs.array[caller->stack.array[j]] && fl_string_dynamic_compare(process_list[i]->rule.alias, global.thread->processs.array[caller->stack.array[j]]->rule.alias) == F_equal_to) { - skip = F_true; - } - - if (skip) break; - } // for - - f_thread_unlock(&global.thread->lock.rule); - - if (skip) { - f_thread_unlock(&process_list[i]->active); - - continue; - } - } - - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock); - } + status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock); if (F_status_is_error(status_lock)) { f_thread_unlock(&process_list[i]->active); @@ -6334,12 +6258,7 @@ extern "C" { if (process_list[i]->state == controller_process_state_done_e) { f_thread_unlock(&process_list[i]->lock); - if (caller) { - status_lock = controller_lock_write_process(process_list[i], global.thread, &process_list[i]->lock); - } - else { - status_lock = controller_lock_write(is_normal, global.thread, &process_list[i]->lock); - } + status_lock = controller_lock_write(is_normal, global.thread, &process_list[i]->lock); if (F_status_is_error(status_lock)) { controller_lock_print_error_critical(global.main->error, F_status_set_fine(status_lock), F_false, global.thread); @@ -6365,12 +6284,7 @@ extern "C" { f_thread_mutex_unlock(&process_list[i]->wait_lock); } - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->active); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active); - } + status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->active); if (F_status_is_error(status_lock)) { f_thread_unlock(&process_list[i]->lock); @@ -6381,13 +6295,7 @@ extern "C" { f_thread_unlock(&process_list[i]->lock); - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock); - } - + status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock); if (F_status_is_error(status_lock)) break; } @@ -6424,12 +6332,7 @@ extern "C" { break; } - if (caller) { - status_lock = controller_lock_read_process(caller, global.thread, &process_list[i]->lock); - } - else { - status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock); - } + status_lock = controller_lock_read(is_normal, global.thread, &process_list[i]->lock); if (F_status_is_error(status_lock)) { f_thread_unlock(&process_list[i]->active); @@ -6467,15 +6370,8 @@ extern "C" { return status_lock; } - if (caller) { - if (!controller_thread_is_enabled_process(caller, global.thread)) { - return F_status_set_error(F_interrupt); - } - } - else { - if (!controller_thread_is_enabled(is_normal, global.thread)) { - return F_status_set_error(F_interrupt); - } + if (!controller_thread_is_enabled(is_normal, global.thread)) { + return F_status_set_error(F_interrupt); } if (F_status_set_fine(status) == F_require) { @@ -6491,9 +6387,9 @@ extern "C" { #endif // _di_controller_rule_wait_all_ #ifndef _di_controller_rule_wait_all_process_type_ - f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required, controller_process_t * const caller) { + f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required) { - return controller_rule_wait_all(global, type != controller_process_type_exit_e, required, caller); + return controller_rule_wait_all(global, type != controller_process_type_exit_e, required); } #endif // _di_controller_rule_wait_all_process_type_ diff --git a/level_3/controller/c/rule/private-rule.h b/level_3/controller/c/rule/private-rule.h index 83c6191..f47e311 100644 --- a/level_3/controller/c/rule/private-rule.h +++ b/level_3/controller/c/rule/private-rule.h @@ -759,10 +759,6 @@ extern "C" { * @param required * If TRUE, then only process required rules and if a required rule has failed, return. * If FALSE, process all waits, returning normally (required rules still result in failure). - * @param caller - * The process representing the caller so that the process never waits on itself. - * (optional) set to 0 when calling from a thread that is not running/executing any process. - * Failure to set this to the process on a thread running/executing a process will likely result in a deadlock. * * @return * F_none on success. @@ -773,7 +769,7 @@ extern "C" { * F_require (with error bit set) if a required process is in failed status when required is TRUE. */ #ifndef _di_controller_rule_wait_all_ - extern f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required, controller_process_t * const caller) F_attribute_visibility_internal_d; + extern f_status_t controller_rule_wait_all(const controller_global_t global, const bool is_normal, const bool required) F_attribute_visibility_internal_d; #endif // _di_controller_rule_wait_all_ /** @@ -786,10 +782,6 @@ extern "C" { * @param required * If TRUE, then only process required rules and if a required rule has failed, return. * If FALSE, process all waits, returning normally. - * @param caller - * The process representing the caller so that the process never waits on itself. - * (optional) set to 0 when calling from a thread that is not running/executing any process. - * Failure to set this to the process on a thread running/executing a process will likely result in a deadlock. * * @return * Success from controller_rule_wait_all(). @@ -799,7 +791,7 @@ extern "C" { * @see controller_rule_wait_all() */ #ifndef _di_controller_rule_wait_all_process_type_ - extern f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required, controller_process_t * const caller) F_attribute_visibility_internal_d; + extern f_status_t controller_rule_wait_all_process_type(const controller_global_t global, const uint8_t type, const bool required) F_attribute_visibility_internal_d; #endif // _di_controller_rule_wait_all_process_type_ #ifdef __cplusplus diff --git a/level_3/controller/c/thread/private-thread.c b/level_3/controller/c/thread/private-thread.c index 552718a..da90885 100644 --- a/level_3/controller/c/thread/private-thread.c +++ b/level_3/controller/c/thread/private-thread.c @@ -292,11 +292,11 @@ extern "C" { controller_thread_join(&thread.id_signal); } else if (setting->mode == controller_setting_mode_program_e) { - status = controller_rule_wait_all(global, F_true, F_false, 0); + status = controller_rule_wait_all(global, F_true, F_false); } } - controller_thread_process_cancel(global, F_true, controller_thread_cancel_call_e, 0); + controller_thread_process_cancel(global, F_true, controller_thread_cancel_call_e); controller_thread_process_exit(&global); diff --git a/level_3/controller/c/thread/private-thread_process.c b/level_3/controller/c/thread/private-thread_process.c index 9f4c1f3..f59f02b 100644 --- a/level_3/controller/c/thread/private-thread_process.c +++ b/level_3/controller/c/thread/private-thread_process.c @@ -43,7 +43,7 @@ extern "C" { #endif // _di_controller_thread_process_ #ifndef _di_controller_thread_process_cancel_ - void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by, controller_process_t * const caller) { + void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by) { f_thread_mutex_lock(&global.thread->lock.cancel); @@ -126,7 +126,6 @@ extern "C" { for (; i < global.thread->processs.used; ++i) { if (!global.thread->processs.array[i]) continue; - if (caller && i == caller->id) continue; process = global.thread->processs.array[i]; @@ -160,7 +159,6 @@ extern "C" { for (i = 0; i < global.thread->processs.used && lapsed < entry->timeout_exit; ++i) { if (!global.thread->processs.array[i]) continue; - if (caller && i == caller->id) continue; process = global.thread->processs.array[i]; @@ -222,7 +220,6 @@ extern "C" { for (i = 0; i < global.thread->processs.size; ++i) { if (!global.thread->processs.array[i]) continue; - if (caller && i == caller->id) continue; process = global.thread->processs.array[i]; @@ -393,7 +390,7 @@ extern "C" { global->thread->id_signal = 0; } - controller_thread_process_cancel(*global, F_false, controller_thread_cancel_exit_e, 0); + controller_thread_process_cancel(*global, F_false, controller_thread_cancel_exit_e); } else { if (F_status_is_error_not(f_thread_mutex_lock(&global->thread->lock.alert))) { diff --git a/level_3/controller/c/thread/private-thread_process.h b/level_3/controller/c/thread/private-thread_process.h index 0030bbe..674637b 100644 --- a/level_3/controller/c/thread/private-thread_process.h +++ b/level_3/controller/c/thread/private-thread_process.h @@ -41,12 +41,9 @@ extern "C" { * If controller_thread_cancel_signal_e, then this was called from within the signal handling thread, so do not cancel the signal thread. * If controller_thread_cancel_call_e, then this was not called from within the signal handling thread, so cancel the signal thread. * If controller_thread_cancel_execute_e, then this was called from within the Entry/Exit for executing a process, so cancel the signal thread but not the Entry thread. - * @param caller - * (optional) The process that is calling the cancel so that this process itself does not get cancelled. - * Set to NULL to not use. */ #ifndef _di_controller_thread_process_cancel_ - extern void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by, controller_process_t * const caller) F_attribute_visibility_internal_d; + extern void controller_thread_process_cancel(const controller_global_t global, const bool is_normal, const uint8_t by) F_attribute_visibility_internal_d; #endif // _di_controller_thread_process_cancel_ /** diff --git a/level_3/controller/c/thread/private-thread_signal.c b/level_3/controller/c/thread/private-thread_signal.c index 75cbc29..398b41a 100644 --- a/level_3/controller/c/thread/private-thread_signal.c +++ b/level_3/controller/c/thread/private-thread_signal.c @@ -33,7 +33,7 @@ extern "C" { if (information.si_signo == F_signal_interrupt || information.si_signo == F_signal_abort || information.si_signo == F_signal_quit || information.si_signo == F_signal_termination) { global->thread->signal = information.si_signo; - controller_thread_process_cancel(*global, is_normal, controller_thread_cancel_signal_e, 0); + controller_thread_process_cancel(*global, is_normal, controller_thread_cancel_signal_e); break; }