@@ -181,7 +181,12 @@ using torch::executor::etdump_result;
181181 * EXT_RAM_BSS_ATTR places the buffer in PSRAM .bss section.
182182 */
183183#if defined(CONFIG_SPIRAM) && defined(ESP_PLATFORM)
184+ #include < esp_attr.h> // EXT_RAM_BSS_ATTR
184185#include < esp_heap_caps.h>
186+ #ifndef EXT_RAM_BSS_ATTR
187+ // Fallback for static analysis where ESP-IDF headers are unavailable.
188+ #define EXT_RAM_BSS_ATTR
189+ #endif
185190// Use PSRAM for large allocations
186191static const size_t method_allocation_pool_size =
187192 ET_ESP_METHOD_ALLOCATOR_POOL_SIZE ;
@@ -277,7 +282,7 @@ class Box {
277282 }
278283
279284 private:
280- alignas (T) uint8_t mem[sizeof (T)];
285+ alignas (T) uint8_t mem[sizeof (T)] = {} ;
281286 bool has_value = false ;
282287
283288 T* ptr () {
@@ -290,7 +295,7 @@ class Box {
290295};
291296
292297template <typename ValueType>
293- void fill_tensor_with_default_value (Tensor& tensor) {
298+ [[maybe_unused]] void fill_tensor_with_default_value (Tensor& tensor) {
294299 ValueType fill_value{};
295300 if constexpr (std::is_same_v<ValueType, bool >) {
296301 fill_value = true ;
@@ -482,7 +487,7 @@ struct RunnerContext {
482487#if defined(ET_EVENT_TRACER_ENABLED)
483488 Box<ETDumpGen> etdump_gen;
484489#if defined(ET_DUMP_INTERMEDIATE_OUTPUTS) || defined(ET_DUMP_OUTPUTS)
485- void * debug_buffer;
490+ void * debug_buffer = nullptr ;
486491#endif
487492#endif
488493};
@@ -605,7 +610,7 @@ void runner_init(RunnerContext& ctx, size_t pte_size) {
605610 ctx.debug_buffer = ctx.method_allocator ->allocate (ET_DEBUG_BUFFER_SIZE , 16 );
606611 if (ctx.debug_buffer != nullptr ) {
607612 Span<uint8_t > debug_buffer_span (
608- ( uint8_t *) ctx.debug_buffer , ET_DEBUG_BUFFER_SIZE );
613+ reinterpret_cast < uint8_t *>( ctx.debug_buffer ) , ET_DEBUG_BUFFER_SIZE );
609614
610615 Result<bool > result =
611616 ctx.etdump_gen .value ().set_debug_buffer (debug_buffer_span);
@@ -859,6 +864,7 @@ void print_outputs(RunnerContext& ctx) {
859864 }
860865}
861866
867+ // cppcheck-suppress constParameterReference
862868void write_etdump (RunnerContext& ctx) {
863869#if defined(ET_EVENT_TRACER_ENABLED)
864870 ETDumpResult result = ctx.etdump_gen ->get_etdump_data ();
@@ -876,7 +882,8 @@ void write_etdump(RunnerContext& ctx) {
876882 ET_LOG (Info, " Writing etdump to file: %s" , etdump_filename);
877883 FILE * f = fopen (etdump_filename, " wb" );
878884 if (f) {
879- size_t bytes_written = fwrite ((uint8_t *)result.buf , 1 , result.size , f);
885+ size_t bytes_written =
886+ fwrite (reinterpret_cast <uint8_t *>(result.buf ), 1 , result.size , f);
880887 if (bytes_written != result.size ) {
881888 ET_LOG (
882889 Error,
@@ -894,6 +901,9 @@ void write_etdump(RunnerContext& ctx) {
894901#endif
895902}
896903
904+ // cppcheck-suppress constParameterReference
905+ // ET_BUNDLE_IO verification passes ctx.method into devtools/bundled_program
906+ // helpers, which currently require a non-const Method&.
897907bool verify_result (RunnerContext& ctx, const void * model_pte) {
898908 bool model_ok = false ;
899909#if defined(ET_BUNDLE_IO)
@@ -1213,7 +1223,7 @@ size_t et_runner_outputs_size(void) {
12131223 * On ESP-IDF, this is called from app_main() (see below).
12141224 * The function can also be compiled for host testing without ESP-IDF.
12151225 */
1216- void executor_runner_main (void ) {
1226+ [[maybe_unused]] void executor_runner_main (void ) {
12171227 if (!et_runner_init ()) {
12181228 return ;
12191229 }
0 commit comments