The primary focus of this commit is to remove stale code exposed by compilers.
This pass I used clang with -Wall.
Fixed some usage cases where the variables can be replaced with other variables.
I happened to notice some macros didn't need to exist and added the appropriate methods.
I did not search for other cases like this.
I only fixed what happened to be in front of me at the time.
int byte_get = 0;
int8_t width_utf = -1;
- int8_t width_current = 0;
int8_t width_count = 0;
byte_dump_cell_t cell = byte_dump_cell_t_initialize;
#endif // _di_control_packet_header_flag_
#ifndef _di_control_packet_header_length_
- uint32_t control_packet_header_length(const bool is_big, const f_char_t buffer[]) {
+ uint32_t control_packet_header_length(const bool is_big, const uint8_t buffer[]) {
#ifdef _is_F_endian_big
if (is_big) {
if (F_status_is_error(status)) return status;
if (length < 5) return F_status_set_error(F_packet_not);
- uint8_t contol = control_packet_header_flag(head);
-
// Only the first two bits of the 8 Control bits are allowed to be set to 1 for this Packet.
if (head[0] & (~(control_packet_flag_binary_d | control_packet_flag_endian_big_d))) {
return F_status_set_error(F_packet_not);
}
if (F_status_is_error(status)) {
- if (append_ids[i] && main->parameters.array[append_ids[i]].result == f_console_result_additional_e || !append_hass[i]) {
+ if ((append_ids[i] && main->parameters.array[append_ids[i]].result == f_console_result_additional_e) || !append_hass[i]) {
fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true);
}
else {
* The 32-bit number representing the length.
*/
#ifndef _di_control_packet_header_length_
- extern uint32_t control_packet_header_length(const bool is_big, const f_char_t buffer[]) F_attribute_visibility_internal_d;
+ extern uint32_t control_packet_header_length(const bool is_big, const uint8_t buffer[]) F_attribute_visibility_internal_d;
#endif // _di_control_packet_header_length_
/**
f_status_t status = F_none;
f_status_t status_lock = F_none;
- f_array_length_t i = 0;
- f_array_length_t j = 0;
-
f_array_length_t at_i = 0;
f_array_length_t at_j = 1;
cache->delimits.used = 0;
f_array_length_t i = 0;
- f_array_length_t j = 0;
f_array_length_t line = 0;
controller_entry_t *entry = is_entry ? &global.setting->entry : &global.setting->exit;
}
f_array_length_t i = 0;
- f_array_length_t j = 0;
for (; i < cache->object_actions.used; ++i) {
f_status_t status = F_none;
f_status_t status_lock = F_none;
- f_string_dynamics_t arguments_none = f_string_dynamics_t_initialize;
-
controller_main_t * const main = (controller_main_t *) process->main_data;
controller_thread_t * const thread = (controller_thread_t *) process->main_thread;
}
pid_t *child = 0;
- f_string_dynamic_t *child_pid_file = 0;
{
f_array_length_t i = 0;
if (F_status_is_error(status)) return status;
f_array_length_t i = 0;
- f_array_length_t j = 0;
f_array_length_t first = 0;
f_string_range_t range = f_string_range_t_initialize;
status = f_string_dynamic_increase_by(action.parameters.array[process->cache.expanded.used].used + controller_common_allocation_large_d, buffer);
// Apply the IKI delimits.
- for (j = 0; j < iki_data->delimits.used && iki_data->delimits.array[j] < iki_data->variable.array[0].start; ++j) {
- action.parameters.array[process->cache.expanded.used].string[iki_data->delimits.array[j]] = f_iki_syntax_placeholder_s.string[0];
+ for (i = 0; i < iki_data->delimits.used && iki_data->delimits.array[i] < iki_data->variable.array[0].start; ++i) {
+ action.parameters.array[process->cache.expanded.used].string[iki_data->delimits.array[i]] = f_iki_syntax_placeholder_s.string[0];
} // for
if (iki_data->variable.used) {
- for (j = 0, first = 0; j < iki_data->variable.used; ++j) {
+ for (i = 0, first = 0; i < iki_data->variable.used; ++i) {
// Copy everything up to the start of the IKI variable.
- if (first < iki_data->variable.array[j].start) {
+ if (first < iki_data->variable.array[i].start) {
range.start = first;
- range.stop = iki_data->variable.array[j].start - 1;
+ range.stop = iki_data->variable.array[i].start - 1;
status = f_string_dynamic_partial_append_nulless(action.parameters.array[process->cache.expanded.used], range, buffer);
if (F_status_is_error(status)) break;
}
- status = controller_rule_expand_iki(process, action.parameters.array[process->cache.expanded.used], iki_data->vocabulary.array[j], iki_data->content.array[j], buffer);
+ status = controller_rule_expand_iki(process, action.parameters.array[process->cache.expanded.used], iki_data->vocabulary.array[i], iki_data->content.array[i], buffer);
if (F_status_is_error(status)) break;
- first = iki_data->variable.array[j].stop + 1;
+ first = iki_data->variable.array[i].stop + 1;
} // for
if (F_status_is_error(status)) break;
}
// Unapply the IKI delimits.
- for (j = 0; j < iki_data->delimits.used && iki_data->delimits.array[j] < iki_data->variable.array[0].start; ++j) {
- action.parameters.array[process->cache.expanded.used].string[iki_data->delimits.array[j]] = f_iki_syntax_slash_s.string[0];
+ for (i = 0; i < iki_data->delimits.used && iki_data->delimits.array[i] < iki_data->variable.array[0].start; ++i) {
+ action.parameters.array[process->cache.expanded.used].string[iki_data->delimits.array[i]] = f_iki_syntax_slash_s.string[0];
} // for
}
else {
{
f_array_length_t j = 0;
- f_array_length_t k = 0;
f_array_length_t id_rule = 0;
f_array_length_t id_dependency = 0;
f_array_length_t j = 0;
controller_rule_item_t *rule_item = 0;
- controller_rule_action_t *rule_action = 0;
// Copy all rule item action statuses from the rule process to the rule.
for (i = 0; i < rule->items.used; ++i) {
return status;
}
- f_array_length_t path_original_length = 0;
f_string_dynamic_t *setting_value = 0;
f_string_dynamics_t *setting_values = 0;
f_string_maps_t *setting_maps = 0;
f_array_length_t i = 0;
f_array_length_t j = 0;
- uint8_t k = 0;
for (i = 0; i < 2; ++i) {
output.id = -1;
output.stream = 0;
- status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &output);
+ status = f_file_stream_open(argv[index], f_string_empty_s, &output);
if (F_status_is_error(status)) {
- fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e);
+ fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e);
}
}
}
else if (main->parameters.array[fss_basic_list_write_parameter_prepend_e].result == f_console_result_additional_e) {
const f_array_length_t index = main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.used - 1];
- if (main->parameters.arguments.array[index].used) {
+ if (argv[index].used) {
f_state_t state = f_state_t_initialize;
- f_string_range_t range = macro_f_string_range_t_initialize2(main->parameters.arguments.array[index].used);
+ f_string_range_t range = macro_f_string_range_t_initialize2(argv[index].used);
- for (; range.start < main->parameters.arguments.array[index].used; ++range.start) {
+ for (; range.start < argv[index].used; ++range.start) {
- status = f_fss_is_space(state, main->parameters.arguments.array[index], range);
+ status = f_fss_is_space(state, argv[index], range);
if (F_status_is_error(status)) break;
if (status == F_false) {
index = main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i];
- status = fss_basic_list_write_process(main, output, quoted, &main->parameters.arguments.array[index], 0, &buffer);
+ status = fss_basic_list_write_process(main, output, quoted, &argv[index], 0, &buffer);
if (F_status_is_error(status)) break;
} // for
}
index = main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i];
- status = fss_basic_list_write_process(main, output, quoted, 0, &main->parameters.arguments.array[index], &buffer);
+ status = fss_basic_list_write_process(main, output, quoted, 0, &argv[index], &buffer);
if (F_status_is_error(status)) break;
} // for
}
index = main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i];
- status = fss_basic_list_write_process(main, output, quoted, &main->parameters.arguments.array[index], &main->parameters.arguments.array[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]], &buffer);
+ status = fss_basic_list_write_process(main, output, quoted, &argv[index], &argv[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]], &buffer);
if (F_status_is_error(status)) break;
} // for
}
input.size_read = 2048;
f_array_length_t total = 0;
- f_array_length_t previous = 0;
f_string_range_t range = f_string_range_t_initialize;
f_string_dynamic_t block = f_string_dynamic_t_initialize;
input.size_read = 2048;
f_array_length_t total = 0;
- f_array_length_t previous = 0;
f_string_range_t range = f_string_range_t_initialize;
f_string_dynamic_t block = f_string_dynamic_t_initialize;
}
// Clear buffers before continuing.
- macro_f_fss_nest_t_delete_simple(data.nest);
+ f_fss_nest_resize(0, &data.nest);
f_string_dynamic_resize(0, &data.buffer);
}
}
// Clear buffers before repeating the loop.
- macro_f_fss_nest_t_delete_simple(data.nest);
+ f_fss_nest_resize(0, &data.nest);
data.buffer.used = 0;
} // for
}
- macro_f_fss_nest_t_delete_simple(data.nest);
+ f_fss_nest_resize(0, &data.nest);
f_string_dynamic_resize(0, &data.buffer);
- macro_fss_embedded_list_read_depths_t_delete_simple(depths);
- macro_f_fss_delimits_t_delete_simple(objects_delimits);
- macro_f_fss_delimits_t_delete_simple(contents_delimits);
- macro_f_fss_comments_t_delete_simple(comments);
+ fss_embedded_list_read_depths_resize(0, &depths);
+ f_array_lengths_resize(0, &objects_delimits);
+ f_array_lengths_resize(0, &contents_delimits);
+ f_string_ranges_resize(0, &comments);
}
else {
fll_print_format("%r%[%QYou failed to specify one or more files.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s);
#ifndef _di_fss_embedded_list_read_data_delete_
f_status_t fss_embedded_list_read_data_delete(fss_embedded_list_read_data_t * const data) {
- macro_f_fss_nest_t_delete_simple(data->nest);
-
+ f_fss_nest_resize(0, &data->nest);
f_string_dynamic_resize(0, &data->buffer);
return F_none;
}
#endif // _di_fss_embedded_list_read_data_delete_
+#ifndef _di_fss_embedded_list_read_data_delete_
+ f_status_t fss_embedded_list_read_depth_delete(fss_embedded_list_read_depth_t * const depth) {
+
+ f_string_dynamic_resize(0, &depth->value_name);
+
+ return F_none;
+ }
+#endif // _di_fss_embedded_list_read_data_delete_
+
+#ifndef _di_fss_embedded_list_read_depths_resize_
+ f_status_t fss_embedded_list_read_depths_resize(const f_array_length_t length, fss_embedded_list_read_depths_t *depths) {
+
+ if (!depths) {
+ return F_status_set_error(F_parameter);
+ }
+
+ for (f_array_length_t i = length; i < depths->size; ++i) {
+ fss_embedded_list_read_depth_delete(&depths->array[i]);
+ } // for
+
+ const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_embedded_list_read_depth_t), (void **) & depths->array);
+ if (F_status_is_error(status)) return status;
+
+ depths->size = length;
+
+ if (depths->used > depths->size) {
+ depths->used = length;
+ }
+
+ return F_none;
+ }
+#endif // _di_fss_embedded_list_read_depths_resize_
+
#ifndef _di_fss_embedded_list_read_print_signal_received_
void fss_embedded_list_read_print_signal_received(fss_embedded_list_read_data_t * const data) {
} fss_embedded_list_read_depths_t;
#define fss_embedded_list_read_depths_t_initialize { 0, 0, 0 }
-
- #define macro_fss_embedded_list_read_depths_t_clear(depths) macro_f_memory_structure_clear(depths)
-
- #define macro_fss_embedded_list_read_depths_t_delete_simple(depths) \
- depths.used = depths.size; \
- while (depths.used > 0) { \
- --depths.used; \
- macro_fss_embedded_list_read_depth_t_delete_simple(depths.array[depths.used]); \
- } \
- if (!depths.used) macro_f_memory_structure_delete_simple(depths, fss_embedded_list_read_depth_t)
-
- #define macro_fss_embedded_list_read_depths_t_resize(status, depths, new_length) \
- status = F_none; \
- if (new_length < depths.size) { \
- f_array_length_t i = depths.size - new_length; \
- for (; i < depths.size; ++i) { \
- macro_fss_embedded_list_read_depth_t_delete_simple(depths.array[i]); \
- } \
- } \
- if (status == F_none) status = f_memory_resize(depths.size, new_length, sizeof(fss_embedded_list_read_depth_t), (void **) & depths.array); \
- if (status == F_none) { \
- depths.size = new_length; \
- if (depths.used > depths.size) depths.used = new_length; \
- }
-
- #define macro_fss_embedded_list_read_depths_t_adjust(status, depths, new_length) \
- status = F_none; \
- if (new_length < depths.size) { \
- f_array_length_t i = depths.size - new_length; \
- for (; i < depths.size; ++i) { \
- macro_fss_embedded_list_read_depth_t_delete_simple(depths.array[i]); \
- } \
- } \
- if (status == F_none) status = f_memory_adjust(depths.size, new_length, sizeof(fss_embedded_list_read_depth_t), (void **) & depths.array); \
- if (status == F_none) { \
- depths.size = new_length; \
- if (depths.used > depths.size) depths.used = new_length; \
- }
#endif // _di_fss_embedded_list_read_depths_t_
/**
#endif // _di_fss_embedded_list_read_data_delete_
/**
+ * Deallocate depth data.
+ *
+ * @param depth
+ * The depth data to delete.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Status codes (with error bit) are returned on any problem.
+ *
+ * @see f_string_dynamic_resize()
+ */
+#ifndef _di_fss_embedded_list_read_depth_delete_
+ extern f_status_t fss_embedded_list_read_depth_delete(fss_embedded_list_read_depth_t * const depth) F_attribute_visibility_internal_d;
+#endif // _di_fss_embedded_list_read_depth_delete_
+
+/**
+ * Resize the depth array.
+ *
+ * @param length
+ * The new size to use.
+ * @param depths
+ * The depth array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_resize().
+ *
+ * Errors (with error bit) from: fss_embedded_list_read_depths_increase().
+ *
+ * @see f_memory_resize()
+ *
+ * @see fss_embedded_list_read_depth_delete_simple()
+ * @see fss_embedded_list_read_depths_increase()
+ */
+#ifndef _di_fss_embedded_list_read_depths_resize_
+ extern f_status_t fss_embedded_list_read_depths_resize(const f_array_length_t length, fss_embedded_list_read_depths_t *depths) F_attribute_visibility_internal_d;
+#endif // _di_fss_embedded_list_read_depths_resize_
+
+/**
* Print a message about a process signal being recieved, such as an interrupt signal.
*
* @param data
i = data->main->parameters.array[fss_embedded_list_read_parameter_depth_e].values.used + 1;
}
- macro_fss_embedded_list_read_depths_t_resize(status, (*depths), i);
+ status = fss_embedded_list_read_depths_resize(i, depths);
if (F_status_is_error(status)) {
fll_error_print(data->main->error, F_status_set_fine(status), "fss_embedded_list_read_main_preprocess_depth", F_true);
status = fll_fss_embedded_list_read(data->buffer, state, &input, &data->nest, objects_delimits, contents_delimits, comments);
if (F_status_is_error_not(status) && (status == F_data_not_stop || status == F_data_not_eos)) {
- macro_f_fss_nest_t_delete_simple(data->nest);
- f_string_dynamic_resize(0, &data->buffer);
+ fss_embedded_list_read_data_delete(data);
if (data->main->parameters.array[fss_embedded_list_read_parameter_total_e].result == f_console_result_found_e) {
fll_print_format("%r%r", data->main->output.to.stream, f_string_ascii_0_s, f_string_eol_s);
}
if (F_status_is_error(status)) {
- macro_f_fss_nest_t_delete_simple(data->nest);
- f_string_dynamic_resize(0, &data->buffer);
+ fss_embedded_list_read_data_delete(data);
return status;
}
input.size_read = 2048;
f_array_length_t total = 0;
- f_array_length_t previous = 0;
f_string_range_t range = f_string_range_t_initialize;
f_string_range_t range_ignore = f_string_range_t_initialize;
input.size_read = 2048;
f_array_length_t total = 0;
- f_array_length_t previous = 0;
f_string_range_t range = f_string_range_t_initialize;
f_string_range_t range_ignore = f_string_range_t_initialize;
f_array_length_t i = 0;
f_array_length_t total = 0;
- f_array_length_t previous = 0;
f_string_range_t range = f_string_range_t_initialize;
f_string_dynamic_t block = f_string_dynamic_t_initialize;
off_t size_block = 0;
off_t size_file = 0;
off_t size_read = 0;
- const f_array_length_t buffer_used = data.buffer.used;
for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) {
input.size_read = 2048;
f_array_length_t total = 0;
- f_array_length_t previous = 0;
f_string_range_t range = f_string_range_t_initialize;
f_string_dynamic_t block = f_string_dynamic_t_initialize;
return F_none;
}
- f_status_t status = F_none;
-
f_array_length_t i = 0;
f_array_length_t j = 0;
return F_none;
}
- f_status_t status = F_none;
-
f_array_length_t i = 0;
f_array_length_t j = 0;