From 1784a70b30934b71619626038568f60ebebffa6c Mon Sep 17 00:00:00 2001 From: Alexey Skvortsov Date: Sat, 12 Dec 2020 02:36:04 +0700 Subject: [PATCH] Add gcc function attributes --- include/os_mutex.h | 6 ++++ include/os_sema.h | 6 ++++ include/os_signal.h | 8 +++++ include/os_task.h | 27 +++++++++++++++++ include/os_timer.h | 11 +++++++ include/os_timer_sig.h | 11 +++++++ include/str_buf.h | 2 ++ include/time_units.h | 3 ++ src/os_mutex.c | 5 ++++ src/os_sema.c | 5 ++++ src/os_signal.c | 7 +++++ src/os_str.c | 4 +++ src/os_task.c | 29 +++++++++++++++++++ src/os_timer.c | 10 +++++++ src/os_timer_sig.c | 10 +++++++ src/str_buf.c | 13 +++++++++ .../test_os_signal_freertos.cpp | 6 ++-- .../test_os_timer_sig_freertos.cpp | 3 +- 18 files changed, 163 insertions(+), 3 deletions(-) diff --git a/include/os_mutex.h b/include/os_mutex.h index 9ae5446..8a81c28 100644 --- a/include/os_mutex.h +++ b/include/os_mutex.h @@ -12,6 +12,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "os_wrapper_types.h" +#include "attribs.h" #ifdef __cplusplus extern "C" { @@ -20,14 +21,19 @@ extern "C" { typedef SemaphoreHandle_t os_mutex_t; typedef StaticSemaphore_t os_mutex_static_t; +ATTR_WARN_UNUSED_RESULT os_mutex_t os_mutex_create(void); #if configSUPPORT_STATIC_ALLOCATION +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_mutex_t os_mutex_create_static(os_mutex_static_t *const p_mutex_static); #endif +ATTR_NONNULL(1) void os_mutex_delete(os_mutex_t *const ph_mutex); diff --git a/include/os_sema.h b/include/os_sema.h index 98cb944..1136199 100644 --- a/include/os_sema.h +++ b/include/os_sema.h @@ -12,6 +12,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "os_wrapper_types.h" +#include "attribs.h" #ifdef __cplusplus extern "C" { @@ -20,14 +21,19 @@ extern "C" { typedef SemaphoreHandle_t os_sema_t; typedef StaticSemaphore_t os_sema_static_t; +ATTR_WARN_UNUSED_RESULT os_sema_t os_sema_create(void); #if configSUPPORT_STATIC_ALLOCATION +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_sema_t os_sema_create_static(os_sema_static_t *const p_sema_static); #endif +ATTR_NONNULL(1) void os_sema_delete(os_sema_t *const ph_sema); diff --git a/include/os_signal.h b/include/os_signal.h index 499ea30..9f5955c 100644 --- a/include/os_signal.h +++ b/include/os_signal.h @@ -11,6 +11,7 @@ #include #include #include "os_wrapper_types.h" +#include "attribs.h" #ifdef __cplusplus extern "C" { @@ -81,6 +82,8 @@ os_signal_create(void); * @brief Create new os_signal_t object using pre-allocated memory. * @return ptr to the instance of os_signal_t object. */ +ATTR_RETURNS_NONNULL +ATTR_NONNULL(1) os_signal_t * os_signal_create_static(os_signal_static_t *const p_signal_mem); @@ -90,6 +93,7 @@ os_signal_create_static(os_signal_static_t *const p_signal_mem); * @note the passed ptr to the object will be set to NULL. * @return None. */ +ATTR_NONNULL(1) void os_signal_delete(os_signal_t **pp_signal); @@ -140,6 +144,7 @@ os_signal_send(os_signal_t *const p_signal, const os_signal_num_e sig_num); * @param[OUT] p_sig_events - ptr to @ref os_signal_events_t. * @return true if success. */ +ATTR_NONNULL(4) bool os_signal_wait_with_sig_mask( os_signal_t *const p_signal, @@ -154,6 +159,7 @@ os_signal_wait_with_sig_mask( * @param[OUT] p_sig_events - ptr to @ref os_signal_events_t * @return true if success */ +ATTR_NONNULL(3) bool os_signal_wait_with_timeout( os_signal_t *const p_signal, @@ -166,9 +172,11 @@ os_signal_wait_with_timeout( * @param[OUT] p_sig_events - ptr to @ref os_signal_events_t * @return true if success */ +ATTR_NONNULL(2) void os_signal_wait(os_signal_t *const p_signal, os_signal_events_t *const p_sig_events); +ATTR_NONNULL(1) os_signal_num_e os_signal_num_get_next(os_signal_events_t *const p_sig_events); diff --git a/include/os_task.h b/include/os_task.h index 2eee9aa..8962806 100644 --- a/include/os_task.h +++ b/include/os_task.h @@ -39,6 +39,8 @@ typedef StaticTask_t os_task_static_t; * @param[out] ph_task - pointer to the variable to return task handle * @return true if successful */ +ATTR_NONNULL(1, 6) +ATTR_WARN_UNUSED_RESULT bool os_task_create( const os_task_func_t p_func, @@ -58,6 +60,8 @@ os_task_create( * @param[out] ph_task - pointer to the variable to return task handle * @return true if successful */ +ATTR_NONNULL(1, 4, 6) +ATTR_WARN_UNUSED_RESULT bool os_task_create_with_const_param( const os_task_func_const_param_t p_func, @@ -76,6 +80,8 @@ os_task_create_with_const_param( * @param[out] ph_task - pointer to the variable to return task handle * @return true if successful */ +ATTR_NONNULL(1, 5) +ATTR_WARN_UNUSED_RESULT bool os_task_create_without_param( const os_task_func_without_param_t p_func, @@ -93,6 +99,8 @@ os_task_create_without_param( * @param priority - task priority * @return true if successful */ +ATTR_NONNULL(1) +ATTR_WARN_UNUSED_RESULT bool os_task_create_finite( const os_task_finite_func_with_param_t p_func, @@ -110,6 +118,8 @@ os_task_create_finite( * @param priority - task priority * @return true if successful */ +ATTR_NONNULL(1) +ATTR_WARN_UNUSED_RESULT bool os_task_create_finite_with_const_param( const os_task_finite_func_with_const_param_t p_func, @@ -126,6 +136,8 @@ os_task_create_finite_with_const_param( * @param priority - task priority * @return true if successful */ +ATTR_NONNULL(1) +ATTR_WARN_UNUSED_RESULT bool os_task_create_finite_without_param( const os_task_finite_func_without_param_t p_func, @@ -145,6 +157,8 @@ os_task_create_finite_without_param( * @param[out] ph_task - pointer to the variable to return task handle * @return true if successful */ +ATTR_NONNULL(1, 3, 7, 8) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static( const os_task_func_t p_func, @@ -168,6 +182,8 @@ os_task_create_static( * @param[out] ph_task - pointer to the variable to return task handle * @return true if successful */ +ATTR_NONNULL(1, 3, 7, 8) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_with_const_param( const os_task_func_const_param_t p_func, @@ -190,6 +206,8 @@ os_task_create_static_with_const_param( * @param[out] ph_task - pointer to the variable to return task handle * @return true if successful */ +ATTR_NONNULL(1, 3, 6, 7) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_without_param( const os_task_func_without_param_t p_func, @@ -211,6 +229,8 @@ os_task_create_static_without_param( * @param p_task_mem - pointer to the statically allocated buffer for @ref os_task_static_t * @return true if successful */ +ATTR_NONNULL(1, 3, 7) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_finite( const os_task_finite_func_with_param_t p_func, @@ -232,6 +252,8 @@ os_task_create_static_finite( * @param p_task_mem - pointer to the statically allocated buffer for @ref os_task_static_t * @return true if successful */ +ATTR_NONNULL(1, 3, 7) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_finite_with_const_param( const os_task_finite_func_with_const_param_t p_func, @@ -252,6 +274,8 @@ os_task_create_static_finite_with_const_param( * @param p_task_mem - pointer to the statically allocated buffer for @ref os_task_static_t * @return true if successful */ +ATTR_NONNULL(1, 3, 6) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_finite_without_param( const os_task_finite_func_without_param_t p_func, @@ -266,6 +290,7 @@ os_task_create_static_finite_without_param( * @note All resources (dynamic memory, sockets, file descriptors, ...) allocated by the task will remain allocated. * @param ph_task - ptr to variable which contains the task handle, this variable will be automatically cleared. */ +ATTR_NONNULL(1) void os_task_delete(os_task_handle_t *const ph_task); @@ -273,6 +298,7 @@ os_task_delete(os_task_handle_t *const ph_task); * Get task name for the current thread. * @return pointer to the string with the current task name. */ +ATTR_WARN_UNUSED_RESULT const char * os_task_get_name(void); @@ -287,6 +313,7 @@ os_task_delay(const os_delta_ticks_t delay_ticks); * Get the handle of the current task. * @return handle of the current task - @ref os_task_handle_t */ +ATTR_WARN_UNUSED_RESULT os_task_handle_t os_task_get_cur_task_handle(void); diff --git a/include/os_timer.h b/include/os_timer.h index fc33032..272191e 100644 --- a/include/os_timer.h +++ b/include/os_timer.h @@ -12,6 +12,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/timers.h" #include "os_wrapper_types.h" +#include "attribs.h" #ifdef __cplusplus extern "C" { @@ -51,6 +52,7 @@ typedef struct os_timer_one_shot_static_t typedef void (*os_timer_callback_periodic_t)(os_timer_periodic_t *p_timer, void *p_arg); typedef void (*os_timer_callback_one_shot_t)(os_timer_one_shot_t *p_timer, void *p_arg); +ATTR_WARN_UNUSED_RESULT os_timer_periodic_t * os_timer_periodic_create( const char *const p_timer_name, @@ -58,6 +60,9 @@ os_timer_periodic_create( const os_timer_callback_periodic_t cb_func, void *const p_arg); +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_periodic_t * os_timer_periodic_create_static( os_timer_periodic_static_t *const p_mem, @@ -66,6 +71,7 @@ os_timer_periodic_create_static( const os_timer_callback_periodic_t cb_func, void *const p_arg); +ATTR_WARN_UNUSED_RESULT os_timer_one_shot_t * os_timer_one_shot_create( const char *const p_timer_name, @@ -73,6 +79,9 @@ os_timer_one_shot_create( const os_timer_callback_one_shot_t cb_func, void *const p_arg); +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_one_shot_t * os_timer_one_shot_create_static( os_timer_one_shot_static_t *const p_mem, @@ -81,9 +90,11 @@ os_timer_one_shot_create_static( const os_timer_callback_one_shot_t cb_func, void *const p_arg); +ATTR_NONNULL(1) void os_timer_periodic_delete(os_timer_periodic_t **const pp_timer); +ATTR_NONNULL(1) void os_timer_one_shot_delete(os_timer_one_shot_t **const pp_timer); diff --git a/include/os_timer_sig.h b/include/os_timer_sig.h index c234982..7fe57eb 100644 --- a/include/os_timer_sig.h +++ b/include/os_timer_sig.h @@ -11,6 +11,7 @@ #include "os_signal.h" #include "os_timer.h" #include "os_wrapper_types.h" +#include "attribs.h" #ifdef __cplusplus extern "C" { @@ -49,6 +50,7 @@ typedef struct os_timer_sig_one_shot_static_t os_timer_one_shot_static_t os_timer_mem; } os_timer_sig_one_shot_static_t; +ATTR_WARN_UNUSED_RESULT os_timer_sig_periodic_t * os_timer_sig_periodic_create( const char *const p_timer_name, @@ -56,6 +58,9 @@ os_timer_sig_periodic_create( const os_signal_num_e sig_num, const os_delta_ticks_t period_ticks); +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_sig_periodic_t * os_timer_sig_periodic_create_static( os_timer_sig_periodic_static_t *const p_timer_sig_mem, @@ -64,6 +69,7 @@ os_timer_sig_periodic_create_static( const os_signal_num_e sig_num, const os_delta_ticks_t period_ticks); +ATTR_WARN_UNUSED_RESULT os_timer_sig_one_shot_t * os_timer_sig_one_shot_create( const char *const p_timer_name, @@ -71,6 +77,9 @@ os_timer_sig_one_shot_create( const os_signal_num_e sig_num, const os_delta_ticks_t period_ticks); +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_sig_one_shot_t * os_timer_sig_one_shot_create_static( os_timer_sig_one_shot_static_t *const p_timer_sig_mem, @@ -79,9 +88,11 @@ os_timer_sig_one_shot_create_static( const os_signal_num_e sig_num, const os_delta_ticks_t period_ticks); +ATTR_NONNULL(1) void os_timer_sig_periodic_delete(os_timer_sig_periodic_t **const pp_obj); +ATTR_NONNULL(1) void os_timer_sig_one_shot_delete(os_timer_sig_one_shot_t **const pp_obj); diff --git a/include/str_buf.h b/include/str_buf.h index 8cbbd59..2748c86 100644 --- a/include/str_buf.h +++ b/include/str_buf.h @@ -66,6 +66,7 @@ str_buf_init_with_alloc(str_buf_t *const p_str_buf); * @return length of string. */ ATTR_NONNULL(1) +ATTR_PURE str_buf_size_t str_buf_get_len(const str_buf_t *const p_str_buf); @@ -75,6 +76,7 @@ str_buf_get_len(const str_buf_t *const p_str_buf); * @return true if buffer overflow occurred. */ ATTR_NONNULL(1) +ATTR_PURE bool str_buf_is_overflow(const str_buf_t *const p_str_buf); diff --git a/include/time_units.h b/include/time_units.h index 8c382a9..e045ea4 100644 --- a/include/time_units.h +++ b/include/time_units.h @@ -9,6 +9,7 @@ #define RUUVI_TIME_UNITS_H #include +#include "attribs.h" #ifdef __cplusplus extern "C" { @@ -25,12 +26,14 @@ typedef uint32_t TimeUnitsSeconds_t; typedef uint32_t TimeUnitsMilliSeconds_t; typedef uint64_t TimeUnitsMicroSeconds_t; +ATTR_CONST static inline TimeUnitsMilliSeconds_t time_units_conv_seconds_to_ms(const TimeUnitsSeconds_t num_seconds) { return num_seconds * TIME_UNITS_MS_PER_SECOND; } +ATTR_CONST static inline TimeUnitsMicroSeconds_t time_units_conv_ms_to_us(const TimeUnitsMilliSeconds_t num_ms) { diff --git a/src/os_mutex.c b/src/os_mutex.c index fc95d62..de6ea97 100644 --- a/src/os_mutex.c +++ b/src/os_mutex.c @@ -8,6 +8,7 @@ #include "os_mutex.h" #include +ATTR_WARN_UNUSED_RESULT os_mutex_t os_mutex_create(void) { @@ -16,6 +17,9 @@ os_mutex_create(void) } #if configSUPPORT_STATIC_ALLOCATION +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_mutex_t os_mutex_create_static(os_mutex_static_t *const p_mutex_static) { @@ -24,6 +28,7 @@ os_mutex_create_static(os_mutex_static_t *const p_mutex_static) } #endif +ATTR_NONNULL(1) void os_mutex_delete(os_mutex_t *const ph_mutex) { diff --git a/src/os_sema.c b/src/os_sema.c index 18516bd..f23abf5 100644 --- a/src/os_sema.c +++ b/src/os_sema.c @@ -8,6 +8,7 @@ #include "os_sema.h" #include +ATTR_WARN_UNUSED_RESULT os_sema_t os_sema_create(void) { @@ -16,6 +17,9 @@ os_sema_create(void) } #if configSUPPORT_STATIC_ALLOCATION +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_sema_t os_sema_create_static(os_sema_static_t *const p_sema_static) { @@ -24,6 +28,7 @@ os_sema_create_static(os_sema_static_t *const p_sema_static) } #endif +ATTR_NONNULL(1) void os_sema_delete(os_sema_t *const ph_sema) { diff --git a/src/os_signal.c b/src/os_signal.c index 6a7593a..c4eafd4 100644 --- a/src/os_signal.c +++ b/src/os_signal.c @@ -21,6 +21,7 @@ struct os_signal_t _Static_assert(sizeof(os_signal_t) == sizeof(os_signal_static_t), "os_signal_t != os_signal_static_t"); +ATTR_NONNULL(1) static os_signal_t * os_signal_init(os_signal_t *const p_signal, const bool is_static) { @@ -52,6 +53,7 @@ os_signal_create_static(os_signal_static_t *const p_signal_mem) return os_signal_init(p_signal, is_static); } +ATTR_NONNULL(1) void os_signal_delete(os_signal_t **const pp_signal) { @@ -104,6 +106,7 @@ os_signal_is_current_thread_registered(os_signal_t *const p_signal) return false; } +ATTR_CONST static bool os_signal_is_valid_sig_num(const os_signal_num_e sig_num) { @@ -179,6 +182,7 @@ os_signal_send(os_signal_t *const p_signal, const os_signal_num_e sig_num) return true; } +ATTR_NONNULL(4) bool os_signal_wait_with_sig_mask( os_signal_t *const p_signal, @@ -211,6 +215,7 @@ os_signal_wait_with_sig_mask( return true; } +ATTR_NONNULL(3) bool os_signal_wait_with_timeout( os_signal_t *const p_signal, @@ -220,12 +225,14 @@ os_signal_wait_with_timeout( return os_signal_wait_with_sig_mask(p_signal, p_signal->sig_mask, timeout_ticks, p_sig_events); } +ATTR_NONNULL(2) void os_signal_wait(os_signal_t *const p_signal, os_signal_events_t *const p_sig_events) { os_signal_wait_with_timeout(p_signal, OS_DELTA_TICKS_INFINITE, p_sig_events); } +ATTR_NONNULL(1) os_signal_num_e os_signal_num_get_next(os_signal_events_t *const p_sig_events) { diff --git a/src/os_str.c b/src/os_str.c index 986dd05..c1b103c 100644 --- a/src/os_str.c +++ b/src/os_str.c @@ -11,6 +11,7 @@ typedef unsigned long os_strtoul_result_t; typedef long os_strtol_result_t; +ATTR_NONNULL(1) uint32_t os_str_to_uint32_cptr( const char *__restrict const p_str, @@ -25,6 +26,7 @@ os_str_to_uint32_cptr( return (uint32_t)result; } +ATTR_NONNULL(1) uint32_t os_str_to_uint32(char *__restrict const p_str, char **__restrict const pp_end, const os_str2num_base_t base) { @@ -36,6 +38,7 @@ os_str_to_uint32(char *__restrict const p_str, char **__restrict const pp_end, c return (uint32_t)result; } +ATTR_NONNULL(1) int32_t os_str_to_int32_cptr( const char *__restrict const p_str, @@ -59,6 +62,7 @@ os_str_to_int32_cptr( return (int32_t)result; } +ATTR_NONNULL(1) int32_t os_str_to_int32(char *__restrict const p_str, char **__restrict const pp_end, const os_str2num_base_t base) { diff --git a/src/os_task.c b/src/os_task.c index 9131f8a..537f4f6 100644 --- a/src/os_task.c +++ b/src/os_task.c @@ -24,6 +24,7 @@ typedef struct os_task_arg_finite_with_const_param_t static const char *TAG = "os_task"; +ATTR_NONNULL(1, 6) static bool os_task_create_internal( const os_task_func_t p_func, @@ -42,6 +43,8 @@ os_task_create_internal( return true; } +ATTR_NONNULL(1, 4, 6) +ATTR_WARN_UNUSED_RESULT bool os_task_create( const os_task_func_t p_func, @@ -54,6 +57,8 @@ os_task_create( return os_task_create_internal(p_func, p_name, stack_depth, p_param, priority, ph_task); } +ATTR_NONNULL(1, 4, 6) +ATTR_WARN_UNUSED_RESULT bool os_task_create_with_const_param( const os_task_func_const_param_t p_func, @@ -76,6 +81,8 @@ os_task_thread_func_wrapper_without_param(void *p_arg) assert(0); } +ATTR_NONNULL(1, 5) +ATTR_WARN_UNUSED_RESULT bool os_task_create_without_param( const os_task_func_without_param_t p_func, @@ -106,6 +113,8 @@ os_task_thread_func_wrapper_finite_with_param(void *p_arg) assert(0); } +ATTR_NONNULL(1) +ATTR_WARN_UNUSED_RESULT bool os_task_create_finite( const os_task_finite_func_with_param_t p_func, @@ -145,6 +154,8 @@ os_task_thread_func_wrapper_finite_with_const_param(void *p_arg) assert(0); } +ATTR_NONNULL(1) +ATTR_WARN_UNUSED_RESULT bool os_task_create_finite_with_const_param( const os_task_finite_func_with_const_param_t p_func, @@ -183,6 +194,8 @@ os_task_thread_func_wrapper_finite_without_param(void *p_arg) assert(0); } +ATTR_NONNULL(1) +ATTR_WARN_UNUSED_RESULT bool os_task_create_finite_without_param( const os_task_finite_func_without_param_t p_func, @@ -200,6 +213,7 @@ os_task_create_finite_without_param( &h_task); } +ATTR_NONNULL(1, 3, 7, 8) static bool os_task_create_static_internal( const os_task_func_t p_func, @@ -221,6 +235,8 @@ os_task_create_static_internal( return true; } +ATTR_NONNULL(1, 3, 7, 8) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static( const os_task_func_t p_func, @@ -243,6 +259,8 @@ os_task_create_static( ph_task); } +ATTR_NONNULL(1, 3, 7, 8) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_with_const_param( const os_task_func_const_param_t p_func, @@ -265,6 +283,8 @@ os_task_create_static_with_const_param( ph_task); } +ATTR_NONNULL(1, 3, 6, 7) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_without_param( const os_task_func_without_param_t p_func, @@ -286,6 +306,8 @@ os_task_create_static_without_param( ph_task); } +ATTR_NONNULL(1, 3, 7) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_finite( const os_task_finite_func_with_param_t p_func, @@ -316,6 +338,8 @@ os_task_create_static_finite( &h_task); } +ATTR_NONNULL(1, 3, 7) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_finite_with_const_param( const os_task_finite_func_with_const_param_t p_func, @@ -346,6 +370,8 @@ os_task_create_static_finite_with_const_param( &h_task); } +ATTR_NONNULL(1, 3, 6) +ATTR_WARN_UNUSED_RESULT bool os_task_create_static_finite_without_param( const os_task_finite_func_without_param_t p_func, @@ -367,6 +393,7 @@ os_task_create_static_finite_without_param( &h_task); } +ATTR_NONNULL(1) void os_task_delete(os_task_handle_t *const ph_task) { @@ -374,6 +401,7 @@ os_task_delete(os_task_handle_t *const ph_task) *ph_task = NULL; } +ATTR_WARN_UNUSED_RESULT const char * os_task_get_name(void) { @@ -385,6 +413,7 @@ os_task_get_name(void) return task_name; } +ATTR_WARN_UNUSED_RESULT os_task_handle_t os_task_get_cur_task_handle(void) { diff --git a/src/os_timer.c b/src/os_timer.c index 0a58c43..7530bd4 100644 --- a/src/os_timer.c +++ b/src/os_timer.c @@ -61,6 +61,7 @@ os_timer_callback_one_shot(TimerHandle_t h_timer) p_timer->cb_func(p_timer, p_timer->p_arg); } +ATTR_WARN_UNUSED_RESULT os_timer_periodic_t * os_timer_periodic_create( const char *const p_timer_name, @@ -85,6 +86,9 @@ os_timer_periodic_create( return p_timer; } +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_periodic_t * os_timer_periodic_create_static( os_timer_periodic_static_t *const p_mem, @@ -107,6 +111,7 @@ os_timer_periodic_create_static( return p_timer; } +ATTR_WARN_UNUSED_RESULT os_timer_one_shot_t * os_timer_one_shot_create( const char *const p_timer_name, @@ -131,6 +136,9 @@ os_timer_one_shot_create( return p_timer; } +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_one_shot_t * os_timer_one_shot_create_static( os_timer_one_shot_static_t *const p_mem, @@ -182,6 +190,7 @@ os_timer_one_shot_is_active(os_timer_one_shot_t *const p_timer) return true; } +ATTR_NONNULL(1) void os_timer_periodic_delete(os_timer_periodic_t **const pp_timer) { @@ -203,6 +212,7 @@ os_timer_periodic_delete(os_timer_periodic_t **const pp_timer) } } +ATTR_NONNULL(1) void os_timer_one_shot_delete(os_timer_one_shot_t **const pp_timer) { diff --git a/src/os_timer_sig.c b/src/os_timer_sig.c index 0458837..3cc810d 100644 --- a/src/os_timer_sig.c +++ b/src/os_timer_sig.c @@ -67,6 +67,7 @@ os_timer_sig_cb_one_shot(ATTR_UNUSED os_timer_one_shot_t *p_timer, void *p_arg) } } +ATTR_WARN_UNUSED_RESULT os_timer_sig_periodic_t * os_timer_sig_periodic_create( const char *const p_timer_name, @@ -92,6 +93,9 @@ os_timer_sig_periodic_create( return p_obj; } +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_sig_periodic_t * os_timer_sig_periodic_create_static( os_timer_sig_periodic_static_t *const p_timer_sig_mem, @@ -116,6 +120,7 @@ os_timer_sig_periodic_create_static( return p_obj; } +ATTR_WARN_UNUSED_RESULT os_timer_sig_one_shot_t * os_timer_sig_one_shot_create( const char *const p_timer_name, @@ -141,6 +146,9 @@ os_timer_sig_one_shot_create( return p_obj; } +ATTR_WARN_UNUSED_RESULT +ATTR_NONNULL(1) +ATTR_RETURNS_NONNULL os_timer_sig_one_shot_t * os_timer_sig_one_shot_create_static( os_timer_sig_one_shot_static_t *const p_timer_sig_mem, @@ -165,6 +173,7 @@ os_timer_sig_one_shot_create_static( return p_obj; } +ATTR_NONNULL(1) void os_timer_sig_periodic_delete(os_timer_sig_periodic_t **const pp_obj) { @@ -187,6 +196,7 @@ os_timer_sig_periodic_delete(os_timer_sig_periodic_t **const pp_obj) } } +ATTR_NONNULL(1) void os_timer_sig_one_shot_delete(os_timer_sig_one_shot_t **const pp_obj) { diff --git a/src/str_buf.c b/src/str_buf.c index 7dea988..b56bbe9 100644 --- a/src/str_buf.c +++ b/src/str_buf.c @@ -9,6 +9,7 @@ #include #include "os_malloc.h" +ATTR_NONNULL(1) str_buf_t str_buf_init(char *const p_buf, const str_buf_size_t buf_size) { @@ -23,6 +24,7 @@ str_buf_init_null(void) return str_buf; } +ATTR_NONNULL(1) bool str_buf_init_with_alloc(str_buf_t *const p_str_buf) { @@ -36,12 +38,16 @@ str_buf_init_with_alloc(str_buf_t *const p_str_buf) return true; } +ATTR_NONNULL(1) +ATTR_PURE str_buf_size_t str_buf_get_len(const str_buf_t *const p_str_buf) { return p_str_buf->idx; } +ATTR_NONNULL(1) +ATTR_PURE bool str_buf_is_overflow(const str_buf_t *const p_str_buf) { @@ -56,6 +62,7 @@ str_buf_is_overflow(const str_buf_t *const p_str_buf) return false; } +ATTR_NONNULL(1, 2) bool str_buf_vprintf(str_buf_t *const p_str_buf, const char *const fmt, va_list args) { @@ -109,6 +116,8 @@ str_buf_vprintf(str_buf_t *const p_str_buf, const char *const fmt, va_list args) return true; } +ATTR_PRINTF(2, 3) +ATTR_NONNULL(1, 2) bool str_buf_printf(str_buf_t *const p_str_buf, const char *const fmt, ...) { @@ -119,6 +128,7 @@ str_buf_printf(str_buf_t *const p_str_buf, const char *const fmt, ...) return res; } +ATTR_NONNULL(1) str_buf_t str_buf_vprintf_with_alloc(const char *const fmt, va_list args) { @@ -139,6 +149,8 @@ str_buf_vprintf_with_alloc(const char *const fmt, va_list args) return str_buf; } +ATTR_PRINTF(1, 2) +ATTR_NONNULL(1) str_buf_t str_buf_printf_with_alloc(const char *const fmt, ...) { @@ -149,6 +161,7 @@ str_buf_printf_with_alloc(const char *const fmt, ...) return str_buf; } +ATTR_NONNULL(1) void str_buf_free_buf(str_buf_t *const p_str_buf) { diff --git a/tests/test_os_signal_freertos/test_os_signal_freertos.cpp b/tests/test_os_signal_freertos/test_os_signal_freertos.cpp index 5c649e6..d7851c8 100644 --- a/tests/test_os_signal_freertos/test_os_signal_freertos.cpp +++ b/tests/test_os_signal_freertos/test_os_signal_freertos.cpp @@ -312,24 +312,26 @@ cmdHandlerTask(void *p_param) break; case MainTaskCmd_RunSignalHandlerTask1: { + os_task_handle_t h_task = nullptr; pObj->result_run_signal_handler_task = os_task_create( &signalHandlerTask1, "SignalHandler1", configMINIMAL_STACK_SIZE, pObj, tskIDLE_PRIORITY + 1, - nullptr); + &h_task); break; } case MainTaskCmd_RunSignalHandlerTask2: { + os_task_handle_t h_task = nullptr; pObj->result_run_signal_handler_task = os_task_create( &signalHandlerTask2, "SignalHandler2", configMINIMAL_STACK_SIZE, pObj, tskIDLE_PRIORITY + 1, - nullptr); + &h_task); break; } case MainTaskCmd_SendToTask1Signal0: diff --git a/tests/test_os_timer_sig_freertos/test_os_timer_sig_freertos.cpp b/tests/test_os_timer_sig_freertos/test_os_timer_sig_freertos.cpp index ed7a062..f819e7a 100644 --- a/tests/test_os_timer_sig_freertos/test_os_timer_sig_freertos.cpp +++ b/tests/test_os_timer_sig_freertos/test_os_timer_sig_freertos.cpp @@ -274,13 +274,14 @@ cmdHandlerTask(void *p_param) break; case MainTaskCmd_RunSignalHandlerTask1: { + os_task_handle_t h_task = nullptr; pObj->result_run_signal_handler_task = os_task_create( &signalHandlerTask1, "SignalHandler", configMINIMAL_STACK_SIZE, pObj, tskIDLE_PRIORITY + 1, - nullptr); + &h_task); break; } case MainTaskCmd_TimerSigPeriodicCreate: