From c34d5e7a71303c91fab134606841dd62ec57eef6 Mon Sep 17 00:00:00 2001 From: dp111 <19616418+dp111@users.noreply.github.com> Date: Fri, 16 Aug 2024 21:43:41 +0100 Subject: [PATCH 1/4] Put break inside #if #endif --- src/common/tusb_fifo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c index 8a0fd44176..5f2dcabad5 100644 --- a/src/common/tusb_fifo.c +++ b/src/common/tusb_fifo.c @@ -315,9 +315,8 @@ static void _ff_pull_n(tu_fifo_t* f, void* app_buf, uint16_t n, uint16_t rd_ptr, // Read data wrapped part if (wrap_bytes > 0) _ff_pull_const_addr(app_buf, ff_buf, wrap_bytes); } -#endif break; - +#endif default: break; } } From 461a3469b269ae0f3c783148487be6a3f0d462d8 Mon Sep 17 00:00:00 2001 From: dp111 <19616418+dp111@users.noreply.github.com> Date: Fri, 16 Aug 2024 22:09:51 +0100 Subject: [PATCH 2/4] make function variables match prototypes --- src/common/tusb_fifo.c | 24 +++++++++---------- .../vendor/ceedling/vendor/unity/src/unity.c | 20 ++++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c index 5f2dcabad5..85da05a9b4 100644 --- a/src/common/tusb_fifo.c +++ b/src/common/tusb_fifo.c @@ -690,19 +690,19 @@ void tu_fifo_correct_read_pointer(tu_fifo_t* f) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] buffer + @param[in] p_buffer Pointer to the place holder for data read from the buffer @returns TRUE if the queue is not empty */ /******************************************************************************/ -bool tu_fifo_read(tu_fifo_t* f, void * buffer) +bool tu_fifo_read(tu_fifo_t* f, void * p_buffer) { _ff_lock(f->mutex_rd); // Peek the data // f->rd_idx might get modified in case of an overflow so we can not use a local variable - bool ret = _tu_fifo_peek(f, buffer, f->wr_idx, f->rd_idx); + bool ret = _tu_fifo_peek(f, p_buffer, f->wr_idx, f->rd_idx); // Advance pointer f->rd_idx = advance_index(f->depth, f->rd_idx, ret); @@ -719,7 +719,7 @@ bool tu_fifo_read(tu_fifo_t* f, void * buffer) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] buffer + @param[in] p_buffer The pointer to data location @param[in] n Number of element that buffer can afford @@ -727,9 +727,9 @@ bool tu_fifo_read(tu_fifo_t* f, void * buffer) @returns number of items read from the FIFO */ /******************************************************************************/ -uint16_t tu_fifo_read_n(tu_fifo_t* f, void * buffer, uint16_t n) +uint16_t tu_fifo_read_n(tu_fifo_t* f, void * p_buffer, uint16_t n) { - return _tu_fifo_read_n(f, buffer, n, TU_FIFO_COPY_INC); + return _tu_fifo_read_n(f, p_buffer, n, TU_FIFO_COPY_INC); } #ifdef TUP_MEM_CONST_ADDR @@ -809,14 +809,14 @@ uint16_t tu_fifo_peek_n(tu_fifo_t* f, void * p_buffer, uint16_t n) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] data + @param[in] p_data The byte to add to the FIFO @returns TRUE if the data was written to the FIFO (overwrittable FIFO will always return TRUE) */ /******************************************************************************/ -bool tu_fifo_write(tu_fifo_t* f, const void * data) +bool tu_fifo_write(tu_fifo_t* f, const void * p_data) { _ff_lock(f->mutex_wr); @@ -831,7 +831,7 @@ bool tu_fifo_write(tu_fifo_t* f, const void * data) uint16_t wr_ptr = idx2ptr(f->depth, wr_idx); // Write data - _ff_push(f, data, wr_ptr); + _ff_push(f, p_data, wr_ptr); // Advance pointer f->wr_idx = advance_index(f->depth, wr_idx, 1); @@ -851,16 +851,16 @@ bool tu_fifo_write(tu_fifo_t* f, const void * data) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] data + @param[in] p_data The pointer to data to add to the FIFO @param[in] count Number of element @return Number of written elements */ /******************************************************************************/ -uint16_t tu_fifo_write_n(tu_fifo_t* f, const void * data, uint16_t n) +uint16_t tu_fifo_write_n(tu_fifo_t* f, const void * p_data, uint16_t n) { - return _tu_fifo_write_n(f, data, n, TU_FIFO_COPY_INC); + return _tu_fifo_write_n(f, p_data, n, TU_FIFO_COPY_INC); } #ifdef TUP_MEM_CONST_ADDR diff --git a/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c b/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c index ae5afa856e..3a6daa6d30 100644 --- a/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c +++ b/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c @@ -1755,13 +1755,13 @@ void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...) *-----------------------------------------------*/ /*-----------------------------------------------*/ -void UnityFail(const char* msg, const UNITY_LINE_TYPE line) +void UnityFail(const char* message, const UNITY_LINE_TYPE line) { RETURN_IF_FAIL_OR_IGNORE; UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrFail); - if (msg != NULL) + if (message != NULL) { UNITY_OUTPUT_CHAR(':'); @@ -1781,42 +1781,42 @@ void UnityFail(const char* msg, const UNITY_LINE_TYPE line) UnityPrint(UnityStrSpacer); } #endif - if (msg[0] != ' ') + if (message[0] != ' ') { UNITY_OUTPUT_CHAR(' '); } - UnityPrint(msg); + UnityPrint(message); } UNITY_FAIL_AND_BAIL; } /*-----------------------------------------------*/ -void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) +void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) { RETURN_IF_FAIL_OR_IGNORE; UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrIgnore); - if (msg != NULL) + if (message != NULL) { UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(' '); - UnityPrint(msg); + UnityPrint(message); } UNITY_IGNORE_AND_BAIL; } /*-----------------------------------------------*/ -void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) +void UnityMessage(const char* message, const UNITY_LINE_TYPE line) { UnityTestResultsBegin(Unity.TestFile, line); UnityPrint("INFO"); - if (msg != NULL) + if (message != NULL) { UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(' '); - UnityPrint(msg); + UnityPrint(message); } UNITY_PRINT_EOL(); } From 9f1a6b66614cc17dab58450ea7fd78be9a2a7085 Mon Sep 17 00:00:00 2001 From: dp111 <19616418+dp111@users.noreply.github.com> Date: Sun, 1 Sep 2024 19:01:46 +0100 Subject: [PATCH 3/4] Revert "make function variables match prototypes" This reverts commit 461a3469b269ae0f3c783148487be6a3f0d462d8. --- src/common/tusb_fifo.c | 24 +++++++++---------- .../vendor/ceedling/vendor/unity/src/unity.c | 20 ++++++++-------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c index 85da05a9b4..5f2dcabad5 100644 --- a/src/common/tusb_fifo.c +++ b/src/common/tusb_fifo.c @@ -690,19 +690,19 @@ void tu_fifo_correct_read_pointer(tu_fifo_t* f) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] p_buffer + @param[in] buffer Pointer to the place holder for data read from the buffer @returns TRUE if the queue is not empty */ /******************************************************************************/ -bool tu_fifo_read(tu_fifo_t* f, void * p_buffer) +bool tu_fifo_read(tu_fifo_t* f, void * buffer) { _ff_lock(f->mutex_rd); // Peek the data // f->rd_idx might get modified in case of an overflow so we can not use a local variable - bool ret = _tu_fifo_peek(f, p_buffer, f->wr_idx, f->rd_idx); + bool ret = _tu_fifo_peek(f, buffer, f->wr_idx, f->rd_idx); // Advance pointer f->rd_idx = advance_index(f->depth, f->rd_idx, ret); @@ -719,7 +719,7 @@ bool tu_fifo_read(tu_fifo_t* f, void * p_buffer) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] p_buffer + @param[in] buffer The pointer to data location @param[in] n Number of element that buffer can afford @@ -727,9 +727,9 @@ bool tu_fifo_read(tu_fifo_t* f, void * p_buffer) @returns number of items read from the FIFO */ /******************************************************************************/ -uint16_t tu_fifo_read_n(tu_fifo_t* f, void * p_buffer, uint16_t n) +uint16_t tu_fifo_read_n(tu_fifo_t* f, void * buffer, uint16_t n) { - return _tu_fifo_read_n(f, p_buffer, n, TU_FIFO_COPY_INC); + return _tu_fifo_read_n(f, buffer, n, TU_FIFO_COPY_INC); } #ifdef TUP_MEM_CONST_ADDR @@ -809,14 +809,14 @@ uint16_t tu_fifo_peek_n(tu_fifo_t* f, void * p_buffer, uint16_t n) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] p_data + @param[in] data The byte to add to the FIFO @returns TRUE if the data was written to the FIFO (overwrittable FIFO will always return TRUE) */ /******************************************************************************/ -bool tu_fifo_write(tu_fifo_t* f, const void * p_data) +bool tu_fifo_write(tu_fifo_t* f, const void * data) { _ff_lock(f->mutex_wr); @@ -831,7 +831,7 @@ bool tu_fifo_write(tu_fifo_t* f, const void * p_data) uint16_t wr_ptr = idx2ptr(f->depth, wr_idx); // Write data - _ff_push(f, p_data, wr_ptr); + _ff_push(f, data, wr_ptr); // Advance pointer f->wr_idx = advance_index(f->depth, wr_idx, 1); @@ -851,16 +851,16 @@ bool tu_fifo_write(tu_fifo_t* f, const void * p_data) @param[in] f Pointer to the FIFO buffer to manipulate - @param[in] p_data + @param[in] data The pointer to data to add to the FIFO @param[in] count Number of element @return Number of written elements */ /******************************************************************************/ -uint16_t tu_fifo_write_n(tu_fifo_t* f, const void * p_data, uint16_t n) +uint16_t tu_fifo_write_n(tu_fifo_t* f, const void * data, uint16_t n) { - return _tu_fifo_write_n(f, p_data, n, TU_FIFO_COPY_INC); + return _tu_fifo_write_n(f, data, n, TU_FIFO_COPY_INC); } #ifdef TUP_MEM_CONST_ADDR diff --git a/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c b/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c index 3a6daa6d30..ae5afa856e 100644 --- a/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c +++ b/test/unit-test/vendor/ceedling/vendor/unity/src/unity.c @@ -1755,13 +1755,13 @@ void UnityPrintF(const UNITY_LINE_TYPE line, const char* format, ...) *-----------------------------------------------*/ /*-----------------------------------------------*/ -void UnityFail(const char* message, const UNITY_LINE_TYPE line) +void UnityFail(const char* msg, const UNITY_LINE_TYPE line) { RETURN_IF_FAIL_OR_IGNORE; UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrFail); - if (message != NULL) + if (msg != NULL) { UNITY_OUTPUT_CHAR(':'); @@ -1781,42 +1781,42 @@ void UnityFail(const char* message, const UNITY_LINE_TYPE line) UnityPrint(UnityStrSpacer); } #endif - if (message[0] != ' ') + if (msg[0] != ' ') { UNITY_OUTPUT_CHAR(' '); } - UnityPrint(message); + UnityPrint(msg); } UNITY_FAIL_AND_BAIL; } /*-----------------------------------------------*/ -void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) +void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) { RETURN_IF_FAIL_OR_IGNORE; UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrIgnore); - if (message != NULL) + if (msg != NULL) { UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(' '); - UnityPrint(message); + UnityPrint(msg); } UNITY_IGNORE_AND_BAIL; } /*-----------------------------------------------*/ -void UnityMessage(const char* message, const UNITY_LINE_TYPE line) +void UnityMessage(const char* msg, const UNITY_LINE_TYPE line) { UnityTestResultsBegin(Unity.TestFile, line); UnityPrint("INFO"); - if (message != NULL) + if (msg != NULL) { UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(' '); - UnityPrint(message); + UnityPrint(msg); } UNITY_PRINT_EOL(); } From 37a5bd22747e400ba1570738a85250faf36489f2 Mon Sep 17 00:00:00 2001 From: dp111 <19616418+dp111@users.noreply.github.com> Date: Sun, 1 Sep 2024 19:44:32 +0100 Subject: [PATCH 4/4] tusb_fifo.h : make prototype variables match functions ( found with cppcheck) --- src/common/tusb_fifo.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/tusb_fifo.h b/src/common/tusb_fifo.h index 6c0efb5090..879acda4fd 100644 --- a/src/common/tusb_fifo.h +++ b/src/common/tusb_fifo.h @@ -154,14 +154,14 @@ void tu_fifo_config_mutex(tu_fifo_t *f, osal_mutex_t wr_mutex, osal_mutex_t rd_m #define tu_fifo_config_mutex(_f, _wr_mutex, _rd_mutex) #endif -bool tu_fifo_write (tu_fifo_t* f, void const * p_data); -uint16_t tu_fifo_write_n (tu_fifo_t* f, void const * p_data, uint16_t n); +bool tu_fifo_write (tu_fifo_t* f, void const * data); +uint16_t tu_fifo_write_n (tu_fifo_t* f, void const * data, uint16_t n); #ifdef TUP_MEM_CONST_ADDR uint16_t tu_fifo_write_n_const_addr_full_words (tu_fifo_t* f, const void * data, uint16_t n); #endif -bool tu_fifo_read (tu_fifo_t* f, void * p_buffer); -uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t n); +bool tu_fifo_read (tu_fifo_t* f, void * buffer); +uint16_t tu_fifo_read_n (tu_fifo_t* f, void * buffer, uint16_t n); #ifdef TUP_MEM_CONST_ADDR uint16_t tu_fifo_read_n_const_addr_full_words (tu_fifo_t* f, void * buffer, uint16_t n); #endif