From 82a34be0609c2dff10878c1f8eb1b0434fb2471d Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 30 Nov 2025 20:04:56 -0600 Subject: [PATCH] Update: Remove todo regarding delete and destroy functions for f_thread_once_t along with unused tests. The tests are not used and there are no functions to test. Remove the `@todo` regarding adding delete and destroy functions for `f_thread_once_t`. Document the reasons for this in the documentation comments. --- level_0/f_thread/c/thread/once.h | 2 + level_0/f_thread/c/thread/onces.h | 4 +- level_0/f_thread/c/thread/oncess.h | 4 +- .../unit/c/test-thread-onces_delete_callback.c | 55 ------------------- .../unit/c/test-thread-onces_delete_callback.h | 27 ---------- .../unit/c/test-thread-onces_destroy_callback.c | 55 ------------------- .../unit/c/test-thread-onces_destroy_callback.h | 27 ---------- .../unit/c/test-thread-oncess_delete_callback.c | 61 ---------------------- .../unit/c/test-thread-oncess_delete_callback.h | 27 ---------- .../unit/c/test-thread-oncess_destroy_callback.c | 61 ---------------------- .../unit/c/test-thread-oncess_destroy_callback.h | 27 ---------- 11 files changed, 6 insertions(+), 344 deletions(-) delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.h diff --git a/level_0/f_thread/c/thread/once.h b/level_0/f_thread/c/thread/once.h index 0919009..eb84ae7 100644 --- a/level_0/f_thread/c/thread/once.h +++ b/level_0/f_thread/c/thread/once.h @@ -20,6 +20,8 @@ extern "C" { * A typedef representing pthread_once_t. * * There are no delete functions and therefore no delete macros. + * + * This does not provide a clear macro because pthread_once_t requires special functions to perform a clear. */ #ifndef _di_f_thread_once_t_ typedef pthread_once_t f_thread_once_t; diff --git a/level_0/f_thread/c/thread/onces.h b/level_0/f_thread/c/thread/onces.h index 958e5de..9ad68a3 100644 --- a/level_0/f_thread/c/thread/onces.h +++ b/level_0/f_thread/c/thread/onces.h @@ -19,6 +19,8 @@ extern "C" { /** * An array of thread onces. * + * There are no delete or destroy callbacks because pthread_once_t does not support deletions. + * * Properties: * - array: The array of f_thread_once_t. * - used: Total number of allocated spaces used. @@ -44,8 +46,6 @@ extern "C" { } #endif // _di_f_thread_onces_t_ -// @todo add delete & destroy callbacks. - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/oncess.h b/level_0/f_thread/c/thread/oncess.h index 47700aa..cb3935c 100644 --- a/level_0/f_thread/c/thread/oncess.h +++ b/level_0/f_thread/c/thread/oncess.h @@ -19,6 +19,8 @@ extern "C" { /** * An array of an array of thread onces. * + * There are no delete or destroy callbacks because pthread_once_t does not support deletions. + * * Properties: * - array: The array of f_thread_onces_t. * - used: Total number of allocated spaces used. @@ -44,8 +46,6 @@ extern "C" { } #endif // _di_f_thread_oncess_t_ -// @todo add delete & destroy callbacks. - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.c b/level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.c deleted file mode 100644 index 52e916e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_delete_callback.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_delete_callback__fails(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datass_array[] = { datas }; - - int errnos[] = { - 1, - mock_errno_generic, - }; - - f_status_t statuss[] = { - F_status_set_error(F_failure), - F_status_set_error(F_failure), - }; - - for (uint8_t i = 0; i < 2; ++i) { - - will_return(__wrap_pthread_attr_destroy, true); - will_return(__wrap_pthread_attr_destroy, errnos[i]); - - const f_status_t status = f_thread_onces_delete_callback(0, 1, (void *) datass_array); - - assert_int_equal(status, statuss[i]); - } // for -} - -void test__f_thread_onces_delete_callback__works(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datass_array[] = { datas }; - const f_number_unsigned_t length = 1; - - { - will_return(__wrap_pthread_attr_destroy, false); - - const f_status_t status = f_thread_onces_delete_callback(0, length, (void *) datass_array); - - assert_int_equal(status, F_okay); - } -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.h b/level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.h deleted file mode 100644 index 8f08b0e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_delete_callback.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_thread__onces_delete_callback -#define _TEST__F_thread__onces_delete_callback - -/** - * Test that the function fails. - * - * @see f_thread_onces_delete_callback_() - */ -extern void test__f_thread_onces_delete_callback__fails(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_delete_callback_() - */ -extern void test__f_thread_onces_delete_callback__works(void **state); - -#endif // _TEST__F_thread__onces_delete_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.c b/level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.c deleted file mode 100644 index 8f8aea6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.c +++ /dev/null @@ -1,55 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_destroy_callback.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_destroy_callback__fails(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datass_array[] = { datas }; - - int errnos[] = { - 1, - mock_errno_generic, - }; - - f_status_t statuss[] = { - F_status_set_error(F_failure), - F_status_set_error(F_failure), - }; - - for (uint8_t i = 0; i < 2; ++i) { - - will_return(__wrap_pthread_attr_destroy, true); - will_return(__wrap_pthread_attr_destroy, errnos[i]); - - const f_status_t status = f_thread_onces_destroy_callback(0, 1, (void *) datass_array); - - assert_int_equal(status, statuss[i]); - } // for -} - -void test__f_thread_onces_destroy_callback__works(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datass_array[] = { datas }; - const f_number_unsigned_t length = 1; - - { - will_return(__wrap_pthread_attr_destroy, false); - - const f_status_t status = f_thread_onces_destroy_callback(0, length, (void *) datass_array); - - assert_int_equal(status, F_okay); - } -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.h b/level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.h deleted file mode 100644 index 6976595..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_destroy_callback.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_thread__onces_destroy_callback -#define _TEST__F_thread__onces_destroy_callback - -/** - * Test that the function fails. - * - * @see f_thread_onces_destroy_callback_() - */ -extern void test__f_thread_onces_destroy_callback__fails(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_destroy_callback_() - */ -extern void test__f_thread_onces_destroy_callback__works(void **state); - -#endif // _TEST__F_thread__onces_destroy_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.c b/level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.c deleted file mode 100644 index 8381886..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "test-thread.h" -#include "test-thread-oncess_delete_callback.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_oncess_delete_callback__fails(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datas_array[] = { datas }; - f_thread_oncess_t datass = { .array = datas_array, .used = 1, .size = 1 }; - f_thread_oncess_t datass_array[] = { datass }; - - int errnos[] = { - 1, - mock_errno_generic, - }; - - f_status_t statuss[] = { - F_status_set_error(F_failure), - F_status_set_error(F_failure), - }; - - for (uint8_t i = 0; i < 2; ++i) { - - will_return(__wrap_pthread_attr_destroy, true); - will_return(__wrap_pthread_attr_destroy, errnos[i]); - - const f_status_t status = f_thread_oncess_delete_callback(0, 1, (void *) datass_array); - - assert_int_equal(status, statuss[i]); - } // for -} - -void test__f_thread_oncess_delete_callback__works(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datas_array[] = { datas }; - f_thread_oncess_t datass = { .array = datas_array, .used = 1, .size = 1 }; - f_thread_oncess_t datass_array[] = { datass }; - const f_number_unsigned_t length = 1; - - { - will_return(__wrap_pthread_attr_destroy, false); - will_return(__wrap_f_memory_array_resize, false); - will_return(__wrap_f_memory_array_resize, F_okay); - - const f_status_t status = f_thread_oncess_delete_callback(0, length, (void *) datass_array); - - assert_int_equal(status, F_okay); - } -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.h b/level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.h deleted file mode 100644 index bd86a1e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-oncess_delete_callback.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_thread__oncess_delete_callback -#define _TEST__F_thread__oncess_delete_callback - -/** - * Test that the function fails. - * - * @see f_thread_oncess_delete_callback_() - */ -extern void test__f_thread_oncess_delete_callback__fails(void **state); - -/** - * Test that the function works. - * - * @see f_thread_oncess_delete_callback_() - */ -extern void test__f_thread_oncess_delete_callback__works(void **state); - -#endif // _TEST__F_thread__oncess_delete_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.c b/level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.c deleted file mode 100644 index 016cb90..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.c +++ /dev/null @@ -1,61 +0,0 @@ -#include "test-thread.h" -#include "test-thread-oncess_destroy_callback.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_oncess_destroy_callback__fails(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datas_array[] = { datas }; - f_thread_oncess_t datass = { .array = datas_array, .used = 1, .size = 1 }; - f_thread_oncess_t datass_array[] = { datass }; - - int errnos[] = { - 1, - mock_errno_generic, - }; - - f_status_t statuss[] = { - F_status_set_error(F_failure), - F_status_set_error(F_failure), - }; - - for (uint8_t i = 0; i < 2; ++i) { - - will_return(__wrap_pthread_attr_destroy, true); - will_return(__wrap_pthread_attr_destroy, errnos[i]); - - const f_status_t status = f_thread_oncess_destroy_callback(0, 1, (void *) datass_array); - - assert_int_equal(status, statuss[i]); - } // for -} - -void test__f_thread_oncess_destroy_callback__works(void **state) { - - f_thread_once_t data = f_thread_once_t_initialize; - f_thread_once_t data_array[] = { data }; - f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; - f_thread_onces_t datas_array[] = { datas }; - f_thread_oncess_t datass = { .array = datas_array, .used = 1, .size = 1 }; - f_thread_oncess_t datass_array[] = { datass }; - const f_number_unsigned_t length = 1; - - { - will_return(__wrap_pthread_attr_destroy, false); - will_return(__wrap_f_memory_array_adjust, false); - will_return(__wrap_f_memory_array_adjust, F_okay); - - const f_status_t status = f_thread_oncess_destroy_callback(0, length, (void *) datass_array); - - assert_int_equal(status, F_okay); - } -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.h b/level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.h deleted file mode 100644 index 7c82532..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-oncess_destroy_callback.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the type project. - */ -#ifndef _TEST__F_thread__oncess_destroy_callback -#define _TEST__F_thread__oncess_destroy_callback - -/** - * Test that the function fails. - * - * @see f_thread_oncess_destroy_callback_() - */ -extern void test__f_thread_oncess_destroy_callback__fails(void **state); - -/** - * Test that the function works. - * - * @see f_thread_oncess_destroy_callback_() - */ -extern void test__f_thread_oncess_destroy_callback__works(void **state); - -#endif // _TEST__F_thread__oncess_destroy_callback -- 1.8.3.1