From: Kevin Day Date: Thu, 15 Feb 2024 03:05:43 +0000 (-0600) Subject: Cleanup: Replace two condition checks with one. X-Git-Tag: 0.6.9~28 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=94968cecd6337261d023d1abbc4a32462702a4c8;p=fll Cleanup: Replace two condition checks with one. If less than or equal to zero or greater than zero is the condition, then the simpler condition would be to just check not equal to one. --- diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 50f3dbe..fddef36 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -94,7 +94,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca length = (local->rule_contents.array[i].array[0].stop - local->rule_contents.array[i].array[0].start) + 1; - if (local->rule_contents.array[i].used <= 0 || local->rule_contents.array[i].used > 1) { + if (local->rule_contents.array[i].used != 1) { invalid = F_true; } else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_contents.array[i].array[0].start, firewall_chain_input_s, length) == F_equal_to) { @@ -126,7 +126,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_objects.array[i].start, firewall_direction_s, length) == F_equal_to) { length = (local->rule_contents.array[i].array[0].stop - local->rule_contents.array[i].array[0].start) + 1; - if (local->rule_contents.array[i].used <= 0 || local->rule_contents.array[i].used > 1) { + if (local->rule_contents.array[i].used != 1) { invalid = F_true; } else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_contents.array[i].array[0].start, firewall_direction_input_s, length) == F_equal_to) { @@ -151,7 +151,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_objects.array[i].start, firewall_device_s, length) == F_equal_to) { length = (local->rule_contents.array[i].array[0].stop - local->rule_contents.array[i].array[0].start) + 1; - if (local->rule_contents.array[i].used <= 0 || local->rule_contents.array[i].used > 1) { + if (local->rule_contents.array[i].used != 1) { invalid = F_true; } else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_contents.array[i].array[0].start, firewall_device_all_s, length) == F_equal_to) { @@ -194,7 +194,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_objects.array[i].start, firewall_action_s, length) == F_equal_to) { length = (local->rule_contents.array[i].array[0].stop - local->rule_contents.array[i].array[0].start) + 1; - if (local->rule_contents.array[i].used <= 0 || local->rule_contents.array[i].used > 1) { + if (local->rule_contents.array[i].used != 1) { invalid = F_true; } else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_contents.array[i].array[0].start, firewall_action_append_s, length) == F_equal_to) { @@ -234,7 +234,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_objects.array[i].start, firewall_protocol_s, length) == F_equal_to) { length = (local->rule_contents.array[i].array[0].stop - local->rule_contents.array[i].array[0].start) + 1; - if (local->rule_contents.array[i].used <= 0 || local->rule_contents.array[i].used > 1) { + if (local->rule_contents.array[i].used != 1) { invalid = F_true; } else { @@ -262,7 +262,7 @@ f_status_t firewall_perform_commands(firewall_data_t * const data, firewall_loca else if (fl_string_dynamic_compare_string(local->buffer.string + local->rule_objects.array[i].start, firewall_tool_s, length) == F_equal_to) { length = (local->rule_contents.array[i].array[0].stop - local->rule_contents.array[i].array[0].start) + 1; - if (local->rule_contents.array[i].used <= 0 || local->rule_contents.array[i].used > 1) { + if (local->rule_contents.array[i].used != 1) { invalid = F_true; } else {