From: Kevin Day Date: Wed, 24 Jun 2020 05:16:10 +0000 (-0500) Subject: Update: print formatting, closing file, and returning X-Git-Tag: 0.5.0~135 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=59e22dea7149b4930a7aa1eaa68c63022f31d575;p=fll Update: print formatting, closing file, and returning The print formatting for status should be %llu in the event that the entire status (error bits, etc..) is printed. There were some cases where the file is not being closed. There were some cases where the program is missing the return statement. --- diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 9ea6a7fcb..a251f0c86 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -884,7 +884,7 @@ extern "C" { } fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") occurred for file '"); fl_color_print(f_type_error, context.notable, context.reset, "%s", file_name); fl_color_print_line(f_type_error, context.error, context.reset, "'."); diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index b94837143..c88387244 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -34,7 +34,7 @@ extern "C" { if (fallback && verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") in function "); fl_color_print(f_type_error, context.notable, context.reset, "%s", function); fl_color_print_line(f_type_error, context.error, context.reset, "()."); @@ -50,7 +50,7 @@ extern "C" { if (fake_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s", function); fl_color_print(f_type_error, context.error, context.reset, "() for section '"); @@ -76,7 +76,7 @@ extern "C" { if (fake_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s", function); fl_color_print(f_type_error, context.error, context.reset, "() for section '"); @@ -184,10 +184,7 @@ extern "C" { #ifndef _di_fake_print_error_file_ bool fake_print_error_file(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback) { - f_string file_or_directory = 0; - - if (is_file) file_or_directory = "file"; - else file_or_directory = "directory"; + const f_string file_or_directory = is_file ? "file" : "directory"; if (status == F_file_found_not) { if (verbosity != fake_verbosity_quiet) { @@ -340,7 +337,7 @@ extern "C" { if (fake_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") occurred while trying to %s %s '", operation, file_or_directory); fl_color_print(f_type_error, context.notable, context.reset, "%s", name); fl_color_print_line(f_type_error, context.error, context.reset, "'."); @@ -382,7 +379,7 @@ extern "C" { if (fake_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") in function "); fl_color_print(f_type_error, context.notable, context.reset, "%s", function); fl_color_print_line(f_type_error, context.error, context.reset, "()."); @@ -597,7 +594,7 @@ extern "C" { if (fake_print_error(context, verbosity, status, function, F_false) == F_unknown && fallback && verbosity != fake_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); fl_color_print(f_type_error, context.error, context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, context.notable, context.reset, "%d", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") occurred while trying to %s '", operation); fl_color_print(f_type_error, context.notable, context.reset, "%s", source); diff --git a/level_3/fake/c/private-print.h b/level_3/fake/c/private-print.h index b86896f7b..47053654b 100644 --- a/level_3/fake/c/private-print.h +++ b/level_3/fake/c/private-print.h @@ -151,6 +151,8 @@ extern "C" { /** * Print file/directory error messages. * + * @todo the fll_file_error_print() needs to be reviewed and possibly changed. + * * @param context * The color context. * @param verbosity @@ -162,7 +164,7 @@ extern "C" { * @param name * The name of the file or directory. * @param operation - * The operation that failes, such as 'create' or 'access'. + * The operation that fails, such as 'create' or 'access'. * @param is_file * Set to TRUE if this is a file and FALSE if this is a directory. * @param fallback diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 8db025a8a..b7e2caba4 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -272,7 +272,6 @@ extern "C" { file.id = f_type_descriptor_input; status = f_file_read(file, &data->buffer); - if (F_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "f_file_read", "-", F_status_set_fine(status)); @@ -282,7 +281,6 @@ extern "C" { } status = fss_basic_list_read_main_process_file(arguments, data, "-", depths); - if (F_status_is_error(status)) { macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); @@ -305,6 +303,7 @@ extern "C" { if (F_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "f_file_open", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); return status; @@ -312,11 +311,14 @@ extern "C" { if (data->quantity.total == 0) { status = f_file_size_by_id(file.id, &data->quantity.total); - if (F_status_is_error(status)) { fss_basic_list_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + + f_file_close(&file.id); + macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); + return status; } // Skip past empty files. @@ -338,7 +340,6 @@ extern "C" { } status = fss_basic_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], depths); - if (F_status_is_error(status)) { macro_fss_basic_list_read_depths_delete_simple(depths); fss_basic_list_read_delete_data(data); diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index 78ac249c8..358d32998 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -10,7 +10,7 @@ extern "C" { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print_line(f_type_error, context.error, context.reset, "."); @@ -70,7 +70,7 @@ extern "C" { } else { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '"); diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 4acf36d7c..2bf722ce9 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -282,7 +282,6 @@ extern "C" { } status = fss_basic_read_main_process_file(arguments, data, "-", depths); - if (F_status_is_error(status)) { macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); @@ -316,8 +315,12 @@ extern "C" { if (F_status_is_error(status)) { fss_basic_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + + f_file_close(&file.id); + macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); + return status; } // Skip past empty files. @@ -340,7 +343,6 @@ extern "C" { } status = fss_basic_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], depths); - if (F_status_is_error(status)) { macro_fss_basic_read_depths_delete_simple(depths); fss_basic_read_delete_data(data); diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index 82f191bb4..60c631265 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -10,7 +10,7 @@ extern "C" { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print_line(f_type_error, context.error, context.reset, "."); @@ -70,7 +70,7 @@ extern "C" { } else { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '"); diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index 003182b74..b37c0a10b 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -257,7 +257,6 @@ extern "C" { file.id = f_type_descriptor_input; status = f_file_read(file, &data->buffer); - if (F_status_is_error(status)) { fss_extended_list_read_print_file_error(data->context, "f_file_read", "-", F_status_set_fine(status)); @@ -267,7 +266,6 @@ extern "C" { } status = fss_extended_list_read_main_process_file(arguments, data, "-", depths); - if (F_status_is_error(status)) { macro_fss_extended_list_read_depths_delete_simple(depths); fss_extended_list_read_delete_data(data); @@ -297,11 +295,14 @@ extern "C" { if (data->quantity.total == 0) { status = f_file_size_by_id(file.id, &data->quantity.total); - if (F_status_is_error(status)) { fss_extended_list_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + + f_file_close(&file.id); + macro_fss_extended_list_read_depths_delete_simple(depths); fss_extended_list_read_delete_data(data); + return status; } // Skip past empty files. diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index 53e4fc669..08bdcabcc 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -10,7 +10,7 @@ extern "C" { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print_line(f_type_error, context.error, context.reset, "."); @@ -70,7 +70,7 @@ extern "C" { } else { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '"); diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 947edb12a..3d4bcda2a 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -272,7 +272,6 @@ extern "C" { file.id = f_type_descriptor_input; status = f_file_read(file, &data->buffer); - if (F_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "f_file_read", "-", F_status_set_fine(status)); @@ -282,7 +281,6 @@ extern "C" { } status = fss_extended_read_main_process_file(arguments, data, "-", depths); - if (F_status_is_error(status)) { macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); @@ -316,8 +314,12 @@ extern "C" { if (F_status_is_error(status)) { fss_extended_read_print_file_error(data->context, "f_file_size_by_id", arguments.argv[data->remaining.array[counter]], F_status_set_fine(status)); + + f_file_close(&file.id); + macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); + return status; } // Skip past empty files. @@ -340,7 +342,6 @@ extern "C" { } status = fss_extended_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[counter]], depths); - if (F_status_is_error(status)) { macro_fss_extended_read_depths_delete_simple(depths); fss_extended_read_delete_data(data); diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index 6d4cdd835..acb0a1fe4 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -10,7 +10,7 @@ extern "C" { if (fll_file_error_print(f_type_error, context, function_name, file_name, status) == F_false) { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print_line(f_type_error, context.error, context.reset, "."); @@ -70,7 +70,7 @@ extern "C" { } else { fl_color_print(f_type_error, context.error, context.reset, "INTERNAL ERROR: An unhandled error ("); - fl_color_print(f_type_error, context.notable, context.reset, "%u", status); + fl_color_print(f_type_error, context.notable, context.reset, "%llu", status); fl_color_print(f_type_error, context.error, context.reset, ") has occurred while calling "); fl_color_print(f_type_error, context.notable, context.reset, "%s()", function_name); fl_color_print(f_type_error, context.error, context.reset, "' for the parameter '");