Skip to content

Commit

Permalink
Make function's arguments 'const' whenever possible
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSomeMan committed Dec 14, 2020
1 parent fba3848 commit b3011f9
Show file tree
Hide file tree
Showing 16 changed files with 380 additions and 360 deletions.
12 changes: 6 additions & 6 deletions include/os_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ os_mutex_create(void);

#if configSUPPORT_STATIC_ALLOCATION
os_mutex_t
os_mutex_create_static(os_mutex_static_t* p_mutex_static);
os_mutex_create_static(os_mutex_static_t *const p_mutex_static);
#endif

void
os_mutex_delete(os_mutex_t * const ph_mutex);
os_mutex_delete(os_mutex_t *const ph_mutex);

void
os_mutex_lock(os_mutex_t h_mutex);
os_mutex_lock(os_mutex_t const h_mutex);

void
os_mutex_unlock(os_mutex_t h_mutex);
os_mutex_unlock(os_mutex_t const h_mutex);

bool
os_mutex_try_lock(os_mutex_t h_mutex);
os_mutex_try_lock(os_mutex_t const h_mutex);

bool
os_mutex_lock_with_timeout(os_mutex_t h_mutex, const os_delta_ticks_t ticks_to_wait);
os_mutex_lock_with_timeout(os_mutex_t const h_mutex, const os_delta_ticks_t ticks_to_wait);

#ifdef __cplusplus
}
Expand Down
12 changes: 6 additions & 6 deletions include/os_sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ os_sema_create(void);

#if configSUPPORT_STATIC_ALLOCATION
os_sema_t
os_sema_create_static(os_sema_static_t* p_sema_static);
os_sema_create_static(os_sema_static_t *const p_sema_static);
#endif

void
os_sema_delete(os_sema_t * const ph_sema);
os_sema_delete(os_sema_t *const ph_sema);

void
os_sema_wait_infinite(os_sema_t h_sema);
os_sema_wait_infinite(os_sema_t const h_sema);

bool
os_sema_wait_immediate(os_sema_t h_sema);
os_sema_wait_immediate(os_sema_t const h_sema);

bool
os_sema_wait_with_timeout(os_sema_t h_sema, const os_delta_ticks_t ticks_to_wait);
os_sema_wait_with_timeout(os_sema_t const h_sema, const os_delta_ticks_t ticks_to_wait);

void
os_sema_signal(os_sema_t h_sema);
os_sema_signal(os_sema_t const h_sema);

#ifdef __cplusplus
}
Expand Down
25 changes: 14 additions & 11 deletions include/os_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ os_signal_create(void);
* @return ptr to the instance of os_signal_t object.
*/
os_signal_t *
os_signal_create_static(os_signal_static_t *p_signal_mem);
os_signal_create_static(os_signal_static_t *const p_signal_mem);

/**
* @brief Create os_signal_t object.
Expand All @@ -98,21 +98,21 @@ os_signal_delete(os_signal_t **pp_signal);
* @param None.
*/
void
os_signal_register_cur_thread(os_signal_t *p_signal);
os_signal_register_cur_thread(os_signal_t *const p_signal);

/**
* @brief Check if any task registered in os_signal_t object.
* @param true if any task was registered.
*/
bool
os_signal_is_any_thread_registered(os_signal_t *p_signal);
os_signal_is_any_thread_registered(os_signal_t *const p_signal);

/**
* @brief Check if the current task registered in os_signal_t object.
* @param true if the current task was registered.
*/
bool
os_signal_is_current_thread_registered(os_signal_t *p_signal);
os_signal_is_current_thread_registered(os_signal_t *const p_signal);

/**
* @brief Register a signal number to handle by os_signal_t.
Expand All @@ -121,7 +121,7 @@ os_signal_is_current_thread_registered(os_signal_t *p_signal);
* @return true if success.
*/
bool
os_signal_add(os_signal_t *p_signal, const os_signal_num_e sig_num);
os_signal_add(os_signal_t *const p_signal, const os_signal_num_e sig_num);

/**
* @brief Send the signal to the registered thread.
Expand All @@ -130,7 +130,7 @@ os_signal_add(os_signal_t *p_signal, const os_signal_num_e sig_num);
* @return true if successful
*/
bool
os_signal_send(os_signal_t *p_signal, const os_signal_num_e sig_num);
os_signal_send(os_signal_t *const p_signal, const os_signal_num_e sig_num);

/**
* @brief Wait for the calling task to receive one or more signals.
Expand All @@ -142,10 +142,10 @@ os_signal_send(os_signal_t *p_signal, const os_signal_num_e sig_num);
*/
bool
os_signal_wait_with_sig_mask(
os_signal_t * p_signal,
os_signal_t *const p_signal,
const os_signal_sig_mask_t expected_sig_mask,
const os_delta_ticks_t timeout_ticks,
os_signal_events_t * p_sig_events);
os_signal_events_t *const p_sig_events);

/**
* @brief Wait for the calling task to receive one or more signals withing the specified timeout.
Expand All @@ -155,7 +155,10 @@ os_signal_wait_with_sig_mask(
* @return true if success
*/
bool
os_signal_wait_with_timeout(os_signal_t *p_signal, os_delta_ticks_t timeout_ticks, os_signal_events_t *p_sig_events);
os_signal_wait_with_timeout(
os_signal_t *const p_signal,
const os_delta_ticks_t timeout_ticks,
os_signal_events_t *const p_sig_events);

/**
* @brief Wait infinitely for the calling task to receive one or more signals.
Expand All @@ -164,10 +167,10 @@ os_signal_wait_with_timeout(os_signal_t *p_signal, os_delta_ticks_t timeout_tick
* @return true if success
*/
void
os_signal_wait(os_signal_t *p_signal, os_signal_events_t *p_sig_events);
os_signal_wait(os_signal_t *const p_signal, os_signal_events_t *const p_sig_events);

os_signal_num_e
os_signal_num_get_next(os_signal_events_t *p_sig_events);
os_signal_num_get_next(os_signal_events_t *const p_sig_events);

#ifdef __cplusplus
}
Expand Down
14 changes: 10 additions & 4 deletions include/os_str.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ typedef int os_str2num_base_t;
*/
ATTR_NONNULL(1)
uint32_t
os_str_to_uint32_cptr(const char *__restrict p_str, const char **__restrict pp_end, const os_str2num_base_t base);
os_str_to_uint32_cptr(
const char *__restrict const p_str,
const char **__restrict const pp_end,
const os_str2num_base_t base);

/**
* @brief This is a wrapper for stdlib strtoul which implements const-correctness and fixes portability issues (MISRA)
Expand All @@ -37,7 +40,7 @@ os_str_to_uint32_cptr(const char *__restrict p_str, const char **__restrict pp_e
*/
ATTR_NONNULL(1)
uint32_t
os_str_to_uint32(char *__restrict p_str, char **__restrict pp_end, const os_str2num_base_t base);
os_str_to_uint32(char *__restrict const p_str, char **__restrict const pp_end, const os_str2num_base_t base);

/**
* @brief This is a wrapper for stdlib strtol which implements const-correctness and fixes portability issues (MISRA)
Expand All @@ -48,7 +51,10 @@ os_str_to_uint32(char *__restrict p_str, char **__restrict pp_end, const os_str2
*/
ATTR_NONNULL(1)
int32_t
os_str_to_int32_cptr(const char *__restrict p_str, const char **__restrict pp_end, const os_str2num_base_t base);
os_str_to_int32_cptr(
const char *__restrict const p_str,
const char **__restrict const pp_end,
const os_str2num_base_t base);

/**
* @brief This is a wrapper for stdlib strtul which implements const-correctness and fixes portability issues (MISRA)
Expand All @@ -59,7 +65,7 @@ os_str_to_int32_cptr(const char *__restrict p_str, const char **__restrict pp_en
*/
ATTR_NONNULL(1)
int32_t
os_str_to_int32(char *__restrict p_str, char **__restrict pp_end, const os_str2num_base_t base);
os_str_to_int32(char *__restrict const p_str, char **__restrict const pp_end, const os_str2num_base_t base);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit b3011f9

Please sign in to comment.