summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2025-10-26 01:44:04 +0700
committerGitHub <[email protected]>2025-10-26 01:44:04 +0700
commit96d510978eafb1b43344acf0ba52260c3bdb9f81 (patch)
tree88e1c0a8b33dd136f96486a88aaebb98cdc84c9f /src/common
parentac37176cec68a26a308c67b238cbf8901b3f1f29 (diff)
parent42f000df8e52cfe0a46867a5e1fa5817cd58bc8a (diff)
Merge pull request #3318 from hathach/static-analysis
Static analysis
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_common.h2
-rw-r--r--src/common/tusb_debug.h12
-rw-r--r--src/common/tusb_types.h8
3 files changed, 12 insertions, 10 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 50c1be2c6..dfa9299c1 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -131,7 +131,7 @@ TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, c
}
// For memcpy, src may be NULL only if count == 0. Reject otherwise.
- if (src == NULL && count != 0) {
+ if (src == NULL && count != 0u) {
return -1;
}
diff --git a/src/common/tusb_debug.h b/src/common/tusb_debug.h
index 1d0c6f1ad..86517b9c9 100644
--- a/src/common/tusb_debug.h
+++ b/src/common/tusb_debug.h
@@ -58,8 +58,10 @@ void tu_print_mem(void const *buf, uint32_t count, uint8_t indent);
#define tu_printf printf
#endif
-static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
- for(uint32_t i=0; i<bufsize; i++) tu_printf("%02X ", buf[i]);
+TU_ATTR_ALWAYS_INLINE static inline void tu_print_buf(uint8_t const* buf, uint32_t bufsize) {
+ for(uint32_t i=0; i<bufsize; i++) {
+ tu_printf("%02X ", buf[i]);
+ }
tu_printf("\r\n");
}
@@ -109,7 +111,9 @@ typedef struct {
static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) {
for(uint16_t i=0; i<p_table->count; i++) {
- if (p_table->items[i].key == key) { return p_table->items[i].data; }
+ if (p_table->items[i].key == key) {
+ return p_table->items[i].data;
+ }
}
// not found return the key value in hex
@@ -130,8 +134,6 @@ static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint3
#define TU_LOG_FAILED()
#endif
-// TODO replace all TU_LOGn with TU_LOG(n)
-
#define TU_LOG0(...)
#define TU_LOG0_MEM(...)
#define TU_LOG0_BUF(...)
diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h
index ec01bbf0f..c0b7469ed 100644
--- a/src/common/tusb_types.h
+++ b/src/common/tusb_types.h
@@ -77,9 +77,9 @@
*------------------------------------------------------------------*/
typedef enum {
- TUSB_ROLE_INVALID = 0,
- TUSB_ROLE_DEVICE = 0x1,
- TUSB_ROLE_HOST = 0x2,
+ TUSB_ROLE_INVALID = 0u,
+ TUSB_ROLE_DEVICE = 0x1u,
+ TUSB_ROLE_HOST = 0x2u,
} tusb_role_t;
/// defined base on EHCI specs value for Endpoint Speed
@@ -178,7 +178,7 @@ typedef enum {
} tusb_request_feature_selector_t;
typedef enum {
- TUSB_REQ_TYPE_STANDARD = 0,
+ TUSB_REQ_TYPE_STANDARD = 0u,
TUSB_REQ_TYPE_CLASS,
TUSB_REQ_TYPE_VENDOR,
TUSB_REQ_TYPE_INVALID