From ad5d877c16f8fdf9586c570853e8bb9c59ae91c2 Mon Sep 17 00:00:00 2001 From: Austin Date: Sat, 1 Aug 2026 13:03:03 -0400 Subject: [PATCH] Fix cppcheck redundantAssignment for OLED_GEOMETRY_OVERRIDE variants (#11325) `pio check` reports at src/main.cpp:878: [low:style] Variable 'screen_geometry' is reassigned a value before the old one has been used. [redundantAssignment] for every variant that pins its panel size with OLED_GEOMETRY_OVERRIDE (t-impulse-plus -> GEOMETRY_64_32, t-echo-card -> GEOMETRY_72_40). The diagnostic pairs the override write with the `GEOMETRY_128_128` write in the SH1107 normalization branch: on those boards that write is a dead store, clobbered a few lines later. Skip the geometry writes when the variant pins the panel size. The screen_model normalization still runs (the driver needs it) and precedence is unchanged - the override still wins on those boards, and nothing changes for boards without one. The compile-time USE_SH1107 write is guarded the same way so the defect can't reappear if a future variant combines the two. Co-authored-by: Claude Opus 5 --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 7989778cf..f2b40da01 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -878,9 +878,13 @@ void setup() #if HAS_SCREEN // fixed screen override? + // The geometry picks below are skipped on variants that pin the panel size with + // OLED_GEOMETRY_OVERRIDE (see the end of this block) - there they would only be dead stores. #if defined(USE_SH1107) screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // set dimension of 128x128 +#ifndef OLED_GEOMETRY_OVERRIDE screen_geometry = GEOMETRY_128_128; +#endif #elif defined(USE_SH1107_128_64) screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // keep dimension of 128x64 #else @@ -889,7 +893,9 @@ void setup() // Fix: update geometry for SH1107 128x128 selected via menu if (screen_model == meshtastic_Config_DisplayConfig_OledType_OLED_SH1107_128_128) { +#ifndef OLED_GEOMETRY_OVERRIDE screen_geometry = GEOMETRY_128_128; +#endif screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // normalize } }