]> Kevux Git Server - fll/commitdiff
Bugfix: The fll_program_standard_signal_received() needs a private implementation.
authorKevin Day <thekevinday@gmail.com>
Tue, 23 Aug 2022 01:10:36 +0000 (20:10 -0500)
committerKevin Day <thekevinday@gmail.com>
Tue, 23 Aug 2022 01:10:36 +0000 (20:10 -0500)
The function fll_program_standard_signal_received() is being called by fll_program_standard_signal_state().
This is not supposed to be allowed and breaks the functional-modular design.

A private function now exists that is called.

build/level_2/settings
build/monolithic/settings
level_2/fll_program/c/private-program.c [new file with mode: 0644]
level_2/fll_program/c/private-program.h [new file with mode: 0644]
level_2/fll_program/c/program.c
level_2/fll_program/c/program.h
level_2/fll_program/data/build/settings

index 0f5da27b26aae7bcebc93fa3ea7c4536f25172d8..2e42edb0266a9696f023bd1932db59c7479f3afc 100644 (file)
@@ -30,7 +30,7 @@ build_sources_library fss_status_string.c
 build_sources_library iki.c private-iki.c
 build_sources_library path.c
 build_sources_library print.c
-build_sources_library program.c program/common.c
+build_sources_library program.c program/common.c private-program.c
 build_sources_library status_string.c
 
 build_sources_headers control_group.h
index 42067e4b4d603929e15e1537531bdb17972fcc20..7b92e697c00070f8461951ab67bfc10f2972c978 100644 (file)
@@ -67,7 +67,7 @@ build_sources_library level_2/fss_status_string.c
 build_sources_library level_2/iki.c level_2/private-iki.c
 build_sources_library level_2/path.c
 build_sources_library level_2/print.c
-build_sources_library level_2/program.c level_2/program/common.c
+build_sources_library level_2/program.c level_2/program/common.c level_2/private-program.c
 build_sources_library level_2/status_string.c
 
 build_sources_library-monolithic level_0/thread.c level_0/private-thread.c level_0/thread/attribute.c level_0/thread/barrier.c level_0/thread/barrier_attribute.c level_0/thread/condition.c level_0/thread/condition_attribute.c level_0/thread/id.c level_0/thread/key.c level_0/thread/lock.c level_0/thread/lock_attribute.c level_0/thread/mutex.c level_0/thread/mutex_attribute.c level_0/thread/once.c level_0/thread/semaphore.c level_0/thread/set.c level_0/thread/spin.c
diff --git a/level_2/fll_program/c/private-program.c b/level_2/fll_program/c/private-program.c
new file mode 100644 (file)
index 0000000..46c7174
--- /dev/null
@@ -0,0 +1,37 @@
+#include "program.h"
+#include "private-program.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_state_)
+  f_status_t private_fll_program_standard_signal_received(fll_program_data_t * const main) {
+
+    if (main->signal.id == -1) return 0;
+
+    struct signalfd_siginfo information;
+
+    memset(&information, 0, sizeof(struct signalfd_siginfo));
+
+    if (f_signal_read(main->signal, 0, &information) == F_signal) {
+      switch (information.ssi_signo) {
+        case F_signal_abort:
+        case F_signal_broken_pipe:
+        case F_signal_hangup:
+        case F_signal_interrupt:
+        case F_signal_quit:
+        case F_signal_termination:
+          main->signal_received = information.ssi_signo;
+
+          return information.ssi_signo;
+      }
+    }
+
+    return 0;
+  }
+#endif // !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_state_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/level_2/fll_program/c/private-program.h b/level_2/fll_program/c/private-program.h
new file mode 100644 (file)
index 0000000..a9bb238
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * FLL - Level 2
+ *
+ * Project: Program
+ * API Version: 0.6
+ * Licenses: lgpl-2.1-or-later
+ *
+ * These are provided for internal reduction in redundant code.
+ * These should not be exposed/used outside of this project.
+ */
+#ifndef _PRIVATE_FLL_program_h
+#define _PRIVATE_FLL_program_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Private implementation of fll_program_standard_signal_received().
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param main
+ *   The main program data.
+ *
+ * @return
+ *   A positive number representing a valid signal on signal received.
+ *   0 on no signal received or when main is NULL.
+ *
+ * @see f_signal_read()
+ *
+ * @see fll_program_standard_signal_received()
+ * @see fll_program_standard_signal_state()
+ */
+#if !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_state_)
+  f_status_t private_fll_program_standard_signal_received(fll_program_data_t * const main) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fll_program_standard_signal_received_) || !defined(_di_fll_program_standard_signal_state_)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_FLL_program_h
index 54575535c2840696db1f98196b552a87ad90b411..9c49aeb5be92942c9a6d1f69cc460fc14ea9ad2c 100644 (file)
@@ -1,4 +1,5 @@
 #include "program.h"
+#include "private-program.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -362,48 +363,24 @@ extern "C" {
 #ifndef _di_fll_program_standard_signal_received_
   f_status_t fll_program_standard_signal_received(fll_program_data_t * const main) {
 
-    if (!main || main->signal.id == -1) {
-      return F_false;
-    }
-
-    struct signalfd_siginfo information;
-
-    memset(&information, 0, sizeof(struct signalfd_siginfo));
+    if (!main) return 0;
 
-    if (f_signal_read(main->signal, 0, &information) == F_signal) {
-      switch (information.ssi_signo) {
-        case F_signal_abort:
-        case F_signal_broken_pipe:
-        case F_signal_hangup:
-        case F_signal_interrupt:
-        case F_signal_quit:
-        case F_signal_termination:
-          main->signal_received = information.ssi_signo;
-
-          return information.ssi_signo;
-      }
-    }
-
-    return F_false;
+    return private_fll_program_standard_signal_received(main);
   }
 #endif // _di_fss_basic_read_signal_received_
 
 #ifndef _di_fll_program_standard_signal_state_
   f_status_t fll_program_standard_signal_state(void * const state, void * const internal) {
 
-    if (!state) {
-      return F_interrupt_not;
-    }
+    if (!state) return F_interrupt_not;
 
     f_state_t *state_ptr = (f_state_t *) state;
 
-    if (!state_ptr->custom) {
-      return F_interrupt_not;
-    }
+    if (!state_ptr->custom) return F_interrupt_not;
 
     fll_program_data_t *custom = (fll_program_data_t *) state_ptr->custom;
 
-    custom->signal_received = fll_program_standard_signal_received(custom);
+    custom->signal_received = private_fll_program_standard_signal_received(custom);
 
     if (custom->signal_received == F_signal_abort || custom->signal_received == F_signal_broken_pipe || custom->signal_received == F_signal_hangup || custom->signal_received == F_signal_interrupt || custom->signal_received == F_signal_quit || custom->signal_received == F_signal_termination) {
       return F_status_set_error(F_interrupt);
index bdea76a7b83b83036ea6015416f0cd96675ca197..7db8b03a225c459bfef9d5fab6427fbc70b96f54 100644 (file)
@@ -441,7 +441,7 @@ extern "C" {
  *
  * @return
  *   A positive number representing a valid signal on signal received.
- *   F_false on no signal received or when main is NULL.
+ *   0 on no signal received or when main is NULL.
  *
  * @see f_signal_read()
  */
index b9365d0352593541acaaa68bb7d3325f9d1d9e7d..45cc4513a023e2608c50cc84e732e401c59a7992 100644 (file)
@@ -20,7 +20,7 @@ build_language c
 build_libraries -lc
 build_libraries-individual -lfl_print -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_print -lf_signal -lf_string -lf_type_array -lf_utf
 
-build_sources_library program.c program/common.c
+build_sources_library program.c program/common.c private-program.c
 
 build_sources_headers program.h program/common.h