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 <noreply@anthropic.com>
This commit is contained in:
Austin
2026-08-01 13:03:03 -04:00
committed by GitHub
parent 4b4e82bd72
commit ad5d877c16

View File

@@ -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
}
}