From 46b3ef2d8bdb6c07e64fdc4fba0a454ead07a009 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 2 May 2021 21:31:20 -0500 Subject: [PATCH] Cleanup: Remove unused variables and other minor changes. Thanks to GCC's -Wall, I was able to find and remove several unused variables. Also perform some minor cleanups of things that I happened to notice while removing the unused variables. --- level_0/f_account/c/account.c | 8 -------- level_0/f_color/c/color.c | 4 ---- level_0/f_directory/c/directory.c | 2 -- level_0/f_file/c/private-file.c | 2 -- level_0/f_fss/c/fss.c | 4 ---- level_0/f_serialize/c/private-serialize.c | 1 - level_0/f_utf/c/private-utf.c | 7 ++----- level_1/fl_directory/c/private-directory.c | 2 -- level_1/fl_fss/c/fss_basic_list.c | 4 ---- level_1/fl_fss/c/fss_embedded_list.c | 6 ------ level_1/fl_fss/c/fss_extended_list.c | 4 ---- level_1/fl_fss/c/private-fss.c | 1 - level_1/fl_utf_file/c/private-utf_file.c | 28 ++++++++++++++-------------- level_2/fll_fss/c/fss.c | 1 - 14 files changed, 16 insertions(+), 58 deletions(-) diff --git a/level_0/f_account/c/account.c b/level_0/f_account/c/account.c index 8704d38..8c15854 100644 --- a/level_0/f_account/c/account.c +++ b/level_0/f_account/c/account.c @@ -19,8 +19,6 @@ extern "C" { account->password.used = 0; account->shell.used = 0; - f_status_t status = F_none; - const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX); // note: pointer seems pointless except that it is used to determine if the name was found. @@ -102,8 +100,6 @@ extern "C" { account->password.used = 0; account->shell.used = 0; - f_status_t status = F_none; - const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX); // note: pointer seems pointless except that it is used to determine if the name was found. @@ -177,8 +173,6 @@ extern "C" { if (!id) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - f_status_t status = F_none; - const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX); // note: pointer seems pointless except that it is used to determine if the name was found. @@ -256,8 +250,6 @@ extern "C" { if (!id) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - f_status_t status = F_none; - const size_t length_max = sysconf(_SC_GETPW_R_SIZE_MAX); // note: pointer seems pointless except that it is used to determine if the name was found. diff --git a/level_0/f_color/c/color.c b/level_0/f_color/c/color.c index 1589a6c..7411c79 100644 --- a/level_0/f_color/c/color.c +++ b/level_0/f_color/c/color.c @@ -169,8 +169,6 @@ extern "C" { if (!string) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - f_status_t status = F_none; - if (set.before) { fprintf(stream, "%s", set.before->string); } @@ -261,8 +259,6 @@ extern "C" { if (!string) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - f_status_t status = F_none; - if (set.before) { dprintf(id, "%s", set.before->string); } diff --git a/level_0/f_directory/c/directory.c b/level_0/f_directory/c/directory.c index 6d659fd..1681e8c 100644 --- a/level_0/f_directory/c/directory.c +++ b/level_0/f_directory/c/directory.c @@ -380,7 +380,6 @@ extern "C" { if (!path) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - f_status_t status = F_none; struct stat file_stat; memset(&file_stat, 0, sizeof(struct stat)); @@ -427,7 +426,6 @@ extern "C" { if (!path) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - f_status_t status = F_none; struct stat file_stat; memset(&file_stat, 0, sizeof(struct stat)); diff --git a/level_0/f_file/c/private-file.c b/level_0/f_file/c/private-file.c index 0179afb..5c10515 100644 --- a/level_0/f_file/c/private-file.c +++ b/level_0/f_file/c/private-file.c @@ -784,7 +784,6 @@ extern "C" { *written = 0; - f_status_t status = F_none; f_array_length_t write_amount = 1; f_array_length_t write_size = file.size_write; f_array_length_t write_max = total; @@ -835,7 +834,6 @@ extern "C" { *written = 0; - f_status_t status = F_none; f_array_length_t write_size = file.size_write; f_array_length_t write_max = total; diff --git a/level_0/f_fss/c/fss.c b/level_0/f_fss/c/fss.c index 58b4f0f..1b1fcd2 100644 --- a/level_0/f_fss/c/fss.c +++ b/level_0/f_fss/c/fss.c @@ -202,7 +202,6 @@ extern "C" { f_array_length_t distance = 0; uint8_t utf_width = 0; - uint8_t i = 0; position = range.start; @@ -390,7 +389,6 @@ extern "C" { f_array_length_t width_max = (range->stop - range->start) + 1; f_array_length_t next = 0; - f_array_length_t next_width_max = 0; if (width_max > buffer.used - range->start) { width_max = buffer.used - range->start; @@ -410,11 +408,9 @@ extern "C" { status = f_utf_is_zero_width(buffer.string + range->start, width_max); if (status == F_true) { - next_width_max = 0; next = range->start + 1; for (; next < buffer.used && next <= range->stop; next += macro_f_utf_byte_width_is(buffer.string[next])) { - next_width_max = (range->stop - next) + 1; status = f_utf_is_graph(buffer.string + next, width_max); diff --git a/level_0/f_serialize/c/private-serialize.c b/level_0/f_serialize/c/private-serialize.c index 81dd50b..d755175 100644 --- a/level_0/f_serialize/c/private-serialize.c +++ b/level_0/f_serialize/c/private-serialize.c @@ -7,7 +7,6 @@ extern "C" { #if !defined(_di_f_serialize_un_simple_find_) || !defined(_di_f_serialize_un_simple_get_) f_status_t private_f_serialize_un_simple_find(const f_string_static_t serialize, const f_array_length_t index, f_string_range_t *location) { - f_status_t status = F_none; f_array_length_t i = 0; f_array_length_t start = 0; diff --git a/level_0/f_utf/c/private-utf.c b/level_0/f_utf/c/private-utf.c index 11e6352..031ad85 100644 --- a/level_0/f_utf/c/private-utf.c +++ b/level_0/f_utf/c/private-utf.c @@ -635,9 +635,6 @@ extern "C" { #if !defined(_di_f_utf_character_is_emoji_) || !defined(_di_f_utf_is_emoji_) f_status_t private_f_utf_character_is_emoji(const f_utf_character_t character, const uint8_t width) { - // reduce the number of checks by grouping checks by first byte. - const uint8_t byte_first = macro_f_utf_character_t_to_char_1(character); - if (width == 2) { // Latin-1 Supplement: U+00A9, U+00AE. @@ -1903,7 +1900,7 @@ extern "C" { f_status_t private_f_utf_character_is_symbol(const f_utf_character_t character, const uint8_t width) { // reduce the number of checks by grouping checks by first byte. - const uint8_t byte_first = macro_f_utf_character_t_to_char_1(character); + //const uint8_t byte_first = macro_f_utf_character_t_to_char_1(character); // @todo: handle all Unicode "symbol". @@ -1915,7 +1912,7 @@ extern "C" { f_status_t private_f_utf_character_is_unassigned(const f_utf_character_t character, const uint8_t width) { // reduce the number of checks by grouping checks by first byte. - const uint8_t byte_first = macro_f_utf_character_t_to_char_1(character); + //const uint8_t byte_first = macro_f_utf_character_t_to_char_1(character); // @todo: Basic Multilingual Plane // @todo: handle all unassigned UTF-8 spaces. diff --git a/level_1/fl_directory/c/private-directory.c b/level_1/fl_directory/c/private-directory.c index 4a85946..b8d25b4 100644 --- a/level_1/fl_directory/c/private-directory.c +++ b/level_1/fl_directory/c/private-directory.c @@ -20,7 +20,6 @@ extern "C" { status = F_none; - int directory_fd = 0; f_array_length_t failures_used = recurse.failures ? recurse.failures->used : 0; { @@ -239,7 +238,6 @@ extern "C" { status = F_none; - int directory_fd = 0; f_array_length_t failures_used = recurse.failures ? recurse.failures->used : 0; { diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index b31d8d0..301d1c2 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -499,14 +499,11 @@ extern "C" { status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination); if (F_status_is_error(status)) return status; - const f_array_length_t input_start = range->start; const f_array_length_t used_start = destination->used; f_array_length_t i = 0; f_array_length_t slash_count = 0; - f_string_range_t range_next = f_string_range_t_initialize; - uint8_t width = 0; // find the first graph character. @@ -688,7 +685,6 @@ extern "C" { status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 2, destination); if (F_status_is_error(status)) return status; - const f_array_length_t input_start = range->start; const f_array_length_t used_start = destination->used; bool is_comment = F_false; diff --git a/level_1/fl_fss/c/fss_embedded_list.c b/level_1/fl_fss/c/fss_embedded_list.c index 48023e8..90906fb 100644 --- a/level_1/fl_fss/c/fss_embedded_list.c +++ b/level_1/fl_fss/c/fss_embedded_list.c @@ -259,8 +259,6 @@ extern "C" { if (!comments) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - const f_array_length_t found_used = found->used; - f_status_t status = f_fss_skip_past_delimit(buffer, range); if (F_status_is_error(status)) return status; @@ -861,14 +859,11 @@ extern "C" { status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination); if (F_status_is_error(status)) return status; - const f_array_length_t input_start = range->start; const f_array_length_t used_start = destination->used; f_array_length_t i = 0; f_array_length_t slash_count = 0; - f_string_range_t range_next = f_string_range_t_initialize; - bool ends_on_space = F_false; uint8_t width = 0; @@ -1069,7 +1064,6 @@ extern "C" { status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination); if (F_status_is_error(status)) return status; - const f_array_length_t input_start = range->start; const f_array_length_t used_start = destination->used; bool is_comment = F_false; diff --git a/level_1/fl_fss/c/fss_extended_list.c b/level_1/fl_fss/c/fss_extended_list.c index 6825fd8..077d26d 100644 --- a/level_1/fl_fss/c/fss_extended_list.c +++ b/level_1/fl_fss/c/fss_extended_list.c @@ -453,14 +453,11 @@ extern "C" { status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination); if (F_status_is_error(status)) return status; - const f_array_length_t input_start = range->start; const f_array_length_t used_start = destination->used; f_array_length_t i = 0; f_array_length_t slash_count = 0; - f_string_range_t range_next = f_string_range_t_initialize; - bool ends_on_space = F_false; uint8_t width = 0; @@ -660,7 +657,6 @@ extern "C" { status = f_string_dynamic_increase_by(destination->used + (range->stop - range->start) + 3, destination); if (F_status_is_error(status)) return status; - const f_array_length_t input_start = range->start; const f_array_length_t used_start = destination->used; bool is_comment = F_false; diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 1380e58..ce89a8b 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -715,7 +715,6 @@ extern "C" { f_array_length_t item_first = 0; f_array_length_t item_total = 0; - f_array_length_t quote_start = 0; f_array_length_t i = 0; // use placeholders for potential quote and potential delimited quote to avoid doing things such as memmove(). diff --git a/level_1/fl_utf_file/c/private-utf_file.c b/level_1/fl_utf_file/c/private-utf_file.c index 1626ddb..275082a 100644 --- a/level_1/fl_utf_file/c/private-utf_file.c +++ b/level_1/fl_utf_file/c/private-utf_file.c @@ -8,10 +8,10 @@ extern "C" { #if !defined(_di_fl_utf_file_read_) || !defined(_di_fl_utf_file_read_until_) || !defined(_di_fl_utf_file_read_range_) void private_fl_utf_file_process_read_buffer(const char *buffer_read, const ssize_t size_read, f_utf_string_dynamic_t *buffer, char buffer_char[], uint8_t *width, int8_t *width_last) { - f_utf_character_t character = 0; uint8_t increment_by = 0; for (f_array_length_t i = 0; i < size_read; i += increment_by) { + increment_by = 0; if (!*width) { @@ -22,27 +22,27 @@ extern "C" { if (*width_last < *width) { buffer_char[0] = buffer_read[i]; *width_last = 1; - increment_by++; + ++increment_by; } if (*width > 1 && i + 1 < size_read) { if (*width_last < *width) { buffer_char[1] = buffer_read[i]; *width_last = 2; - increment_by++; + ++increment_by; } if (*width > 2 && i + 2 < size_read) { if (*width_last < *width) { buffer_char[2] = buffer_read[i]; *width_last = 3; - increment_by++; + ++increment_by; } if (*width > 3 && i + 3 < size_read) { buffer_char[3] = buffer_read[i]; *width_last = 4; - increment_by++; + ++increment_by; } } } @@ -62,7 +62,7 @@ extern "C" { } } - buffer->used++; + ++buffer->used; *width = 0; } } // for @@ -71,9 +71,9 @@ extern "C" { #if !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(fl_utf_file_write_range) f_status_t private_fl_utf_file_write_until(const f_file_t file, const f_utf_string_t string, const f_array_length_t total, f_array_length_t *written) { + *written = 0; - f_status_t status = F_none; f_array_length_t write_size = file.size_write > 4 ? file.size_write : 4; f_array_length_t write_max = total; f_array_length_t i = 0; @@ -95,25 +95,25 @@ extern "C" { do { memset(buffer_write, 0, write_size); - for (i = 0, used = 0; used < write_size && *written + i < write_max; i++, used += width) { + for (i = 0, used = 0; used < write_size && *written + i < write_max; ++i, used += width) { if (width_written < width) { if (width_written < 2) { buffer_write[used] = macro_f_utf_character_t_to_char_2(string[*written + i]); - width_written++; - used++; + ++width_written; + ++used; } if (width > 2 && width_written < 3) { buffer_write[used + 1] = macro_f_utf_character_t_to_char_3(string[*written + i]); - width_written++; - used++; + ++width_written; + ++used; } if (width == 4 && width_written < 4) { buffer_write[used + 2] = macro_f_utf_character_t_to_char_4(string[*written + i]); - width_written++; - used++; + ++width_written; + ++used; } width = 0; diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index 591f20e..6186ff1 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -63,7 +63,6 @@ extern "C" { f_array_length_t i = 0; f_array_length_t j = 0; - f_array_length_t k = 0; bool matched[size]; -- 1.8.3.1