Skip to content

Commit

Permalink
Format source code using clang-format-14 (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSomeMan authored Oct 14, 2022
1 parent 694777e commit b6b0e71
Show file tree
Hide file tree
Showing 61 changed files with 1,026 additions and 1,029 deletions.
12 changes: 6 additions & 6 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# use with clang-format v10
# use with clang-format v14
# this code style is based on BARR-C:2018 (https://barrgroup.com/embedded-systems/books/embedded-c-coding-standard)
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveDeclarations: Consecutive
AlignEscapedNewlines: DontAlign
AlignOperands: true
AlignTrailingComments: true
Expand Down Expand Up @@ -104,9 +104,9 @@ PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
#PenaltyReturnTypeOnItsOwnLine: 200
PenaltyReturnTypeOnItsOwnLine: 0
PointerAlignment: Right
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortIncludes: Never
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
Expand Down
6 changes: 3 additions & 3 deletions include/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ esp_log_timestamp(void);
extern void
log_print_dump(
esp_log_level_t level,
const char * p_tag,
const char * p_log_prefix,
const uint8_t * p_buf,
const char* p_tag,
const char* p_log_prefix,
const uint8_t* p_buf,
const uint32_t buf_size);

#if LOG_LOCAL_LEVEL >= LOG_LEVEL_ERROR
Expand Down
4 changes: 2 additions & 2 deletions include/mac_addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ typedef struct mac_address_str_t
}

void
mac_address_bin_init(mac_address_bin_t *p_mac, const uint8_t mac[MAC_ADDRESS_NUM_BYTES]);
mac_address_bin_init(mac_address_bin_t* p_mac, const uint8_t mac[MAC_ADDRESS_NUM_BYTES]);

mac_address_str_t
mac_address_to_str(const mac_address_bin_t *p_mac);
mac_address_to_str(const mac_address_bin_t* p_mac);

#ifdef __cplusplus
}
Expand Down
12 changes: 6 additions & 6 deletions include/os_malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C" {
*/
ATTR_MALLOC
ATTR_MALLOC_SIZE(1)
void *
void*
os_malloc(const size_t size);

/**
Expand All @@ -35,7 +35,7 @@ os_malloc(const size_t size);
*/
ATTR_MALLOC
ATTR_CALLOC_SIZE(1, 2)
void *
void*
os_calloc(const size_t nmemb, const size_t size);

/**
Expand All @@ -50,7 +50,7 @@ os_calloc(const size_t nmemb, const size_t size);
*/
ATTR_WARN_UNUSED_RESULT
bool
os_realloc_safe(void **const p_ptr, const size_t size);
os_realloc_safe(void** const p_ptr, const size_t size);

/**
* @brief This is a safer wrap for realloc,
Expand All @@ -66,23 +66,23 @@ os_realloc_safe(void **const p_ptr, const size_t size);
ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1)
bool
os_realloc_safe_and_clean(void **const p_ptr, const size_t size);
os_realloc_safe_and_clean(void** const p_ptr, const size_t size);

/**
* This is a wrap for 'free' - it deallocates a block of memory
* @note This function should not be used, use macro @ref os_free instead.
* @param ptr - pointer to the memory block
*/
void
os_free_internal(void *ptr);
os_free_internal(void* ptr);

/**
* @brief os_free - is a wrap for 'free' which automatically sets pointer to NULL after the memory freeing.
*/
#define os_free(ptr) \
do \
{ \
os_free_internal((void *)(ptr)); \
os_free_internal((void*)(ptr)); \
ptr = NULL; \
} while (0)

Expand Down
2 changes: 1 addition & 1 deletion include/os_mkgmtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
* @return time_t - calendar time (or unix-time - seconds since the Epoch 1970) or (time_t)-1 if a error was detected.
*/
time_t
os_mkgmtime(struct tm *const p_tm_time_utc);
os_mkgmtime(struct tm* const p_tm_time_utc);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/os_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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);
os_mutex_create_static(os_mutex_static_t* const p_mutex_static);
#endif

/**
Expand All @@ -49,7 +49,7 @@ os_mutex_create_static(os_mutex_static_t *const p_mutex_static);
*/
ATTR_NONNULL(1)
void
os_mutex_delete(os_mutex_t *const ph_mutex);
os_mutex_delete(os_mutex_t* const ph_mutex);

/**
* @brief Lock the mutex (wait until it will be locked).
Expand Down
4 changes: 2 additions & 2 deletions include/os_mutex_recursive.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1)
ATTR_RETURNS_NONNULL
os_mutex_recursive_t
os_mutex_recursive_create_static(os_mutex_recursive_static_t *const p_mutex_static);
os_mutex_recursive_create_static(os_mutex_recursive_static_t* const p_mutex_static);
#endif

/**
Expand All @@ -49,7 +49,7 @@ os_mutex_recursive_create_static(os_mutex_recursive_static_t *const p_mutex_stat
*/
ATTR_NONNULL(1)
void
os_mutex_recursive_delete(os_mutex_recursive_t *const ph_mutex);
os_mutex_recursive_delete(os_mutex_recursive_t* const ph_mutex);

/**
* @brief Lock the mutex (wait until it will be locked).
Expand Down
4 changes: 2 additions & 2 deletions include/os_sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ 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);
os_sema_create_static(os_sema_static_t* const p_sema_static);
#endif

/**
Expand All @@ -49,7 +49,7 @@ os_sema_create_static(os_sema_static_t *const p_sema_static);
*/
ATTR_NONNULL(1)
void
os_sema_delete(os_sema_t *const ph_sema);
os_sema_delete(os_sema_t* const ph_sema);

/**
* @brief Wait until the semaphore is available and acquire it.
Expand Down
34 changes: 17 additions & 17 deletions include/os_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct os_signal_t os_signal_t;

typedef struct os_signal_static_t
{
void * stub1;
void* stub1;
uint32_t stub2;
bool stub3;
} os_signal_static_t;
Expand Down Expand Up @@ -75,7 +75,7 @@ typedef struct os_signal_bit_mask_t
* @brief Create new os_signal_t object.
* @return ptr to the instance of os_signal_t object.
*/
os_signal_t *
os_signal_t*
os_signal_create(void);

/**
Expand All @@ -85,8 +85,8 @@ os_signal_create(void);
*/
ATTR_RETURNS_NONNULL
ATTR_NONNULL(1)
os_signal_t *
os_signal_create_static(os_signal_static_t *const p_signal_mem);
os_signal_t*
os_signal_create_static(os_signal_static_t* const p_signal_mem);

/**
* @brief Create os_signal_t object.
Expand All @@ -96,31 +96,31 @@ os_signal_create_static(os_signal_static_t *const p_signal_mem);
*/
ATTR_NONNULL(1)
void
os_signal_delete(os_signal_t **pp_signal);
os_signal_delete(os_signal_t** pp_signal);

/**
* @brief Register the current task in os_signal_t object.
* @param true if the current task was registered successfully, false - if some other task was already registered.
*/
bool
os_signal_register_cur_thread(os_signal_t *const p_signal);
os_signal_register_cur_thread(os_signal_t* const p_signal);

void
os_signal_unregister_cur_thread(os_signal_t *const p_signal);
os_signal_unregister_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 *const 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 *const 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 @@ -129,7 +129,7 @@ os_signal_is_current_thread_registered(os_signal_t *const p_signal);
* @return true if success.
*/
bool
os_signal_add(os_signal_t *const 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 @@ -138,7 +138,7 @@ os_signal_add(os_signal_t *const p_signal, const os_signal_num_e sig_num);
* @return true if successful
*/
bool
os_signal_send(os_signal_t *const 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 @@ -151,10 +151,10 @@ os_signal_send(os_signal_t *const p_signal, const os_signal_num_e sig_num);
ATTR_NONNULL(4)
bool
os_signal_wait_with_sig_mask(
os_signal_t *const 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 *const 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 @@ -166,9 +166,9 @@ os_signal_wait_with_sig_mask(
ATTR_NONNULL(3)
bool
os_signal_wait_with_timeout(
os_signal_t *const p_signal,
os_signal_t* const p_signal,
const os_delta_ticks_t timeout_ticks,
os_signal_events_t *const p_sig_events);
os_signal_events_t* const p_sig_events);

/**
* @brief Wait infinitely for the calling task to receive one or more signals.
Expand All @@ -178,11 +178,11 @@ os_signal_wait_with_timeout(
*/
ATTR_NONNULL(2)
void
os_signal_wait(os_signal_t *const p_signal, os_signal_events_t *const p_sig_events);
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);
os_signal_num_get_next(os_signal_events_t* const p_sig_events);

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

/**
Expand All @@ -40,7 +40,7 @@ os_str_to_uint32_cptr(
*/
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);
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 @@ -52,8 +52,8 @@ os_str_to_uint32(char *__restrict const p_str, char **__restrict const pp_end, c
ATTR_NONNULL(1)
int32_t
os_str_to_int32_cptr(
const char *__restrict const p_str,
const char **__restrict const pp_end,
const char* __restrict const p_str,
const char** __restrict const pp_end,
const os_str2num_base_t base);

/**
Expand All @@ -65,7 +65,7 @@ os_str_to_int32_cptr(
*/
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);
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 b6b0e71

Please sign in to comment.