From 18c3095346159a4f5c3db9775b4f7c6aebca77c2 Mon Sep 17 00:00:00 2001 From: Nathaniel Brough Date: Fri, 20 Jan 2023 15:40:32 -0800 Subject: fix: Change all static variables to thread when fuzzing --- src/common/tusb_compiler.h | 7 +++++++ src/common/tusb_debug.h | 2 +- src/common/tusb_types.h | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/common') diff --git a/src/common/tusb_compiler.h b/src/common/tusb_compiler.h index 2c30daf6f..6a02959ca 100644 --- a/src/common/tusb_compiler.h +++ b/src/common/tusb_compiler.h @@ -61,6 +61,13 @@ #define TU_VERIFY_STATIC(const_expr, _mess) enum { TU_XSTRCAT(_verify_static_, _TU_COUNTER_) = 1/(!!(const_expr)) } #endif +/* --------------------- Fuzzing types -------------------------------------- */ +#ifdef FUZZ + #define TU_STATIC __thread static +#else + #define TU_STATIC static +#endif + // for declaration of reserved field, make use of _TU_COUNTER_ #define TU_RESERVED TU_XSTRCAT(reserved, _TU_COUNTER_) diff --git a/src/common/tusb_debug.h b/src/common/tusb_debug.h index 65fd1920d..8587b6771 100644 --- a/src/common/tusb_debug.h +++ b/src/common/tusb_debug.h @@ -114,7 +114,7 @@ typedef struct static inline const char* tu_lookup_find(tu_lookup_table_t const* p_table, uint32_t key) { - static char not_found[11]; + TU_STATIC char not_found[11]; for(uint16_t i=0; icount; i++) { diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index 32cdba450..56f782ca3 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -529,13 +529,13 @@ TU_ATTR_ALWAYS_INLINE static inline uint16_t tu_edpt_packet_size(tusb_desc_endpo #if CFG_TUSB_DEBUG TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_dir_str(tusb_dir_t dir) { - static const char *str[] = {"out", "in"}; + TU_STATIC const char *str[] = {"out", "in"}; return str[dir]; } TU_ATTR_ALWAYS_INLINE static inline const char *tu_edpt_type_str(tusb_xfer_type_t t) { - static const char *str[] = {"control", "isochronous", "bulk", "interrupt"}; + TU_STATIC const char *str[] = {"control", "isochronous", "bulk", "interrupt"}; return str[t]; } #endif -- cgit v1.3.1