]> Kevux Git Server - fll/commitdiff
Cleanup: use const more, but in a way that works with pointers.
authorKevin Day <thekevinday@gmail.com>
Thu, 10 Dec 2020 01:39:57 +0000 (19:39 -0600)
committerKevin Day <thekevinday@gmail.com>
Thu, 10 Dec 2020 01:44:09 +0000 (19:44 -0600)
The standard practice is to specify const first.
In the case of pointers, anything to the left of such a declaration represents what is being pointed to.
This means const cannot be used in this case unless the pointer is intending to point to a constant.

The const qualifier may instead be put after the pointer symbol '*' to designate that the pointer and not what is being pointed to is to be a constant.

It seems that I tend to forget this behavior.
This makes a pass at existing uses of such pointers, adding const in the appropriate way.

level_1/fl_directory/c/private-directory.c
level_2/fll_file/c/private-file.c
level_3/fake/c/private-build.c
level_3/fake/c/private-fake.c
level_3/fake/c/private-make.c
level_3/init/c/private-init.c

index 286d1578e3091b4c266e60bc48d74d37baf23b5e..e62fadb5ae26999d5c1f8e2dd4375d6a33c6bb2a 100644 (file)
@@ -23,7 +23,7 @@ extern "C" {
     f_string_length_t failures_used = recurse.failures ? recurse.failures->used : 0;
 
     {
-      f_string_dynamics_t *list[] = {
+      f_string_dynamics_t * const list[] = {
         &listing.block,
         &listing.character,
         &listing.regular,
@@ -234,7 +234,7 @@ extern "C" {
     f_string_length_t failures_used = recurse.failures ? recurse.failures->used : 0;
 
     {
-      f_string_dynamics_t *list[] = {
+      f_string_dynamics_t * const list[] = {
         &listing.block,
         &listing.character,
         &listing.regular,
index 2e2a17131f989b800df640284404e5948e682902..d73fca352c63d3b9feacca265eb56c2274532851 100644 (file)
@@ -30,7 +30,7 @@ extern "C" {
     const f_string_length_t path_length = strnlen(path, f_path_max);
 
     {
-      f_string_dynamics_t *list[] = {
+      f_string_dynamics_t * const list[] = {
         &listing.block,
         &listing.character,
         &listing.regular,
@@ -127,7 +127,7 @@ extern "C" {
     const f_string_length_t path_length = strnlen(path, f_path_max);
 
     {
-      f_string_dynamics_t *list[] = {
+      f_string_dynamics_t * const list[] = {
         &listing.block,
         &listing.character,
         &listing.regular,
index 6e98d06e16e34017eeda54e237a91806a09341d3..a2a227a2b34ca9c3d8f39668178135e973b67cf6 100644 (file)
@@ -1417,7 +1417,7 @@ extern "C" {
     if (F_status_is_error_not(*status)) {
       bool failed = F_false;
 
-      f_string_static_t *settings[] = {
+      f_string_static_t * const settings[] = {
         &setting->project_name,
       };
 
@@ -1583,7 +1583,7 @@ extern "C" {
     f_string_dynamics_t version_minor = f_string_dynamics_t_initialize;
     f_string_dynamics_t version_target = f_string_dynamics_t_initialize;
 
-    f_string_dynamics_t *settings_value[] = {
+    f_string_dynamics_t * settings_value[] = {
       &build_compiler,
       &build_indexer,
       &build_language,
@@ -1791,7 +1791,7 @@ extern "C" {
         &version_target,
       };
 
-      bool *settings_single_bool[] = {
+      bool * const settings_single_bool[] = {
         0,
         0,
         0,
@@ -1817,7 +1817,7 @@ extern "C" {
         &setting->search_static,
       };
 
-      f_string_dynamic_t *settings_single_destination[] = {
+      f_string_dynamic_t * const settings_single_destination[] = {
         &setting->build_compiler,
         &setting->build_indexer,
         0,
@@ -1846,13 +1846,13 @@ extern "C" {
         &setting->version_minor,
       };
 
-      uint8_t *settings_single_language[] = {
+      uint8_t * const settings_single_language[] = {
         0,
         0,
         &setting->build_language,
       };
 
-      uint8_t *settings_single_version[] = {
+      uint8_t * const settings_single_version[] = {
         0,
         0,
         0,
@@ -1883,7 +1883,7 @@ extern "C" {
       };
 
       // 1 = "yes" or "no", 2 = path/, 3 = literal, 4 = "bash", "c", or "c++", 5 = "major", "minor", or "micro".
-      uint8_t settings_single_type[] = {
+      const uint8_t settings_single_type[] = {
         3,
         3,
         4,
@@ -2088,19 +2088,19 @@ extern "C" {
     }
 
     {
-      f_string_t sources[] = {
+      const f_string_t sources[] = {
         fake_build_setting_default_version,
         fake_build_setting_default_version,
         fake_build_setting_default_version,
       };
 
-      f_string_length_t lengths[] = {
+      const f_string_length_t lengths[] = {
         fake_build_setting_default_version_length,
         fake_build_setting_default_version_length,
         fake_build_setting_default_version_length,
       };
 
-      f_string_dynamic_t *destinations[] = {
+      f_string_dynamic_t * const destinations[] = {
         &setting->version_major,
         &setting->version_minor,
         &setting->version_micro,
@@ -2279,7 +2279,7 @@ extern "C" {
       fake_build_stage_sources_settings_length,
     };
 
-    f_string_dynamic_t *values[] = {
+    f_string_dynamic_t * const values[] = {
       &stage->file_libraries_script,
       &stage->file_libraries_shared,
       &stage->file_libraries_static,
index 8db25f27503b25c5b23c91c24d7c9a20a72528d9..fb6adf46a8bfe61c24669c2d8282055867394614 100644 (file)
@@ -184,7 +184,7 @@ extern "C" {
         &data->path_sources_script,
       };
 
-      f_string_dynamic_t **parameters_value[] = {
+      f_string_dynamic_t **const parameters_value[] = {
         parameters_value_0,
         parameters_value_1,
         parameters_value_2,
@@ -237,7 +237,7 @@ extern "C" {
         fake_path_part_script_length,
       };
 
-      f_string_dynamic_t *parameters_value[] = {
+      f_string_dynamic_t * const parameters_value[] = {
         &data->path_build_documents,
         &data->path_build_includes,
         &data->path_build_libraries,
@@ -303,7 +303,7 @@ extern "C" {
         &data->file_documents_readme,
       };
 
-      f_string_dynamic_t **parameters_value[] = {
+      f_string_dynamic_t **const parameters_value[] = {
         parameters_value_0,
         parameters_value_1,
         parameters_value_2,
@@ -358,7 +358,7 @@ extern "C" {
         fake_file_readme_length,
       };
 
-      f_string_dynamic_t *parameters_value[] = {
+      f_string_dynamic_t * const parameters_value[] = {
         &data->path_build_libraries_script,
         &data->path_build_libraries_shared,
         &data->path_build_libraries_static,
@@ -384,7 +384,7 @@ extern "C" {
 
     if (data->path_work.used > 0) {
       {
-        f_string_dynamic_t *parameters_value[] = {
+        f_string_dynamic_t * const parameters_value[] = {
           &data->path_work_includes,
           &data->path_work_libraries,
           &data->path_work_programs,
@@ -413,7 +413,7 @@ extern "C" {
           fake_path_part_programs_length,
         };
 
-        f_string_dynamic_t *parameters_value[] = {
+        f_string_dynamic_t * const parameters_value[] = {
           &data->path_work_includes,
           &data->path_work_libraries,
           &data->path_work_programs,
@@ -452,7 +452,7 @@ extern "C" {
           &data->path_work_programs_static,
         };
 
-        f_string_dynamic_t **parameters_value[] = {
+        f_string_dynamic_t **const parameters_value[] = {
           parameters_value_0,
           parameters_value_1,
         };
@@ -486,7 +486,7 @@ extern "C" {
           fake_path_part_static_length,
         };
 
-        f_string_dynamic_t *parameters_value[] = {
+        f_string_dynamic_t * const parameters_value[] = {
           &data->path_work_libraries_script,
           &data->path_work_libraries_shared,
           &data->path_work_libraries_static,
@@ -507,7 +507,7 @@ extern "C" {
     }
 
     {
-      f_string_dynamic_t *parameters_value[] = {
+      f_string_dynamic_t * const parameters_value[] = {
         &data->path_build_documents,
         &data->path_build_includes,
         &data->path_build_libraries,
@@ -604,7 +604,7 @@ extern "C" {
         fake_default_settings_length,
       };
 
-      f_string_dynamic_t *parameters_value[] = {
+      f_string_dynamic_t * const parameters_value[] = {
         &data->fakefile,
         &data->process,
         &data->settings,
@@ -746,7 +746,7 @@ extern "C" {
         fake_default_path_work_length,
       };
 
-      f_string_dynamic_t *parameters_value[] = {
+      f_string_dynamic_t * const parameters_value[] = {
         &data->path_build,
         &data->path_data,
         &data->path_sources,
index 8fbe3be3e9ef13acf4a1db3d4baa101ef09a8c70..716b6c5d2551931bae00c7562e5706b93f191eb8 100644 (file)
@@ -891,7 +891,7 @@ extern "C" {
         &data.mode,
       };
 
-      f_string_dynamics_t *destination[] = {
+      f_string_dynamics_t * const destination[] = {
         &data_make->parameter.define,
         &data_make->parameter.mode,
       };
@@ -984,7 +984,7 @@ extern "C" {
         &data.settings,
       };
 
-      f_string_dynamics_t *destination[] = {
+      f_string_dynamics_t * const destination[] = {
         &data_make->parameter.fakefile,
         &data_make->parameter.build,
         &data_make->parameter.data,
@@ -1235,7 +1235,7 @@ extern "C" {
       fake_make_parameter_variable_work_length,
     };
 
-    f_string_dynamics_t *reserved_value[] = {
+    f_string_dynamics_t * const reserved_value[] = {
       &data_make->parameter.build,
       &data_make->parameter.color,
       &data_make->parameter.data,
index c81074946f1dc75424246a12c858ff3fad2713bd..760ab4f2468046f3fab8ac20e768c793d71a0b55 100644 (file)
@@ -129,7 +129,7 @@ Consider the "*.device" files such that they are also use IKI.
         init_string_verbosity_length,
       };
 
-      f_string_dynamic_t *parameter_value[] = {
+      f_string_dynamic_t * const parameter_value[] = {
         &cache,
         &cache,
         &cache,
@@ -144,7 +144,7 @@ Consider the "*.device" files such that they are also use IKI.
         &cache,
       };
 
-      bool *parameter_value_bool[] = {
+      bool * const parameter_value_bool[] = {
         0,
         &setting_kernel->failsafe,
         0,
@@ -159,7 +159,7 @@ Consider the "*.device" files such that they are also use IKI.
         0,
       };
 
-      uint8_t *parameter_value_uint8[] = {
+      uint8_t * const parameter_value_uint8[] = {
         &setting_kernel->color,
         0,
         &setting_kernel->mode,
@@ -175,7 +175,7 @@ Consider the "*.device" files such that they are also use IKI.
       };
 
       // @todo: create f_metric_t, such that it is an f_number_unsigned_t with an exponent type, such as: Y (yotta), Z (zetta), E (exa), P (peta), T (Tera), G (giga), M (mega), k (kilo), h (hecto), da (deca), (none), d (deci), c (centi), m (milli), μ (micro), n (nano), p (pico), f (femto), a (atto), z (zepto), and y (yocto).
-      f_number_unsigned_t *parameter_value_number_unsigned[] = {
+      f_number_unsigned_t * const parameter_value_number_unsigned[] = {
         0,
         0,
         0,