diff options
| author | hathach <[email protected]> | 2025-11-05 15:31:02 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-11-05 17:34:27 +0700 |
| commit | 1f04fe7924e8777c1583323171c0e1cabcb29062 (patch) | |
| tree | b619bbd1b1c002132c4b810d651abfe47b19d9bd /src/common | |
| parent | 8979af34c0e5b97520070bcfdffe5280de9ac24c (diff) | |
added .clang-format
fix more alerts
disable IAR CStat since pvs-studio check is better integrated with clion
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/tusb_common.h | 7 | ||||
| -rw-r--r-- | src/common/tusb_debug.h | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index 5f659eb95..7aa42a2d7 100644 --- a/src/common/tusb_common.h +++ b/src/common/tusb_common.h @@ -236,7 +236,7 @@ TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_round_up(uint32_t v, uint32_t f) // TODO use clz TODO remove TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_log2(uint32_t value) { uint8_t result = 0; - while (value >>= 1) { + while ((value >>= 1u) != 0u) { result++; } return result; @@ -355,7 +355,10 @@ TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_subtype(void const* desc) { } TU_ATTR_ALWAYS_INLINE static inline uint8_t tu_desc_in_bounds(uint8_t const* p_desc, uint8_t const* desc_end) { - return (p_desc < desc_end) && (tu_desc_next(p_desc) <= desc_end); + if (p_desc >= desc_end) { + return false; + } + return tu_desc_next(p_desc) <= desc_end; } // find descriptor that match byte1 (type) diff --git a/src/common/tusb_debug.h b/src/common/tusb_debug.h index df4034098..a7bf3e959 100644 --- a/src/common/tusb_debug.h +++ b/src/common/tusb_debug.h @@ -119,7 +119,9 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3 // not found return the key value in hex static char not_found[11]; - snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key); + if (snprintf(not_found, sizeof(not_found), "0x%08lX", (unsigned long) key) <= 0) { + not_found[0] = 0; + } return not_found; } |
