]> Kevux Git Server - fll/commitdiff
Update: print formatting, closing file, and returning
authorKevin Day <thekevinday@gmail.com>
Wed, 24 Jun 2020 05:16:10 +0000 (00:16 -0500)
committerKevin Day <thekevinday@gmail.com>
Wed, 24 Jun 2020 05:18:19 +0000 (00:18 -0500)
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.

level_3/byte_dump/c/private-byte_dump.c
level_3/fake/c/private-print.c
level_3/fake/c/private-print.h
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_list_read/c/private-fss_basic_list_read.c
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/private-fss_basic_read.c
level_3/fss_extended_list_read/c/fss_extended_list_read.c
level_3/fss_extended_list_read/c/private-fss_extended_list_read.c
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_read/c/private-fss_extended_read.c

index 9ea6a7fcb972d63637ed4ecd515d005841d7fa84..a251f0c86d0e158f56ec1f2e6762ab7dfaefae2a 100644 (file)
@@ -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, "'.");
index b94837143ab4b382ad60a947c959d5abb557cda2..c883872444966bbfe1c56f56a6a560d3ab52607b 100644 (file)
@@ -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);
 
index b86896f7b39ff7b89ea9556a9b932f3650209465..47053654b830795b6e506ecfddfb1c9d88acf6a6 100644 (file)
@@ -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
index 8db025a8a85118d974e57486ae3e96f06fb1c7b6..b7e2caba4da1dc46fae3f2f60bdaa7a0a5a7b4ce 100644 (file)
@@ -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);
index 78ac249c8a55bd7012d7026f77c5094f38f29a67..358d329984ad01f9eb9304d0836d1a8e748ea827 100644 (file)
@@ -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 '");
index 4acf36d7c27cdb6d5f5cccc8d10fb57aef16fc2e..2bf722ce9b9ca0fab2d83fd8522f7c3f973c3f9b 100644 (file)
@@ -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);
index 82f191bb49d52fd9f38549408307e5b8d0e5e7f3..60c631265a7edec75c98db595e17d314c8d7f41f 100644 (file)
@@ -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 '");
index 003182b74d53e86b9809ef916a82df6202336d4b..b37c0a10b341945471424b79c5d5533e8e1b3901 100644 (file)
@@ -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.
index 53e4fc66992e837a32fada104460bc31fcce0b0e..08bdcabcccda3c6b1bc9abaa9da17a41ccddb1a7 100644 (file)
@@ -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 '");
index 947edb12a50ed79450b4ac292b47fa447442bc5a..3d4bcda2a813fca1c64097c61c3e2a76c5caf0d6 100644 (file)
@@ -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);
index 6d4cdd835423bf11d5b29ebc4625be9fcb2815e8..acb0a1fe446141ea4891285c6fe69f70ff497cce 100644 (file)
@@ -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 '");