Skip to content

Commit 347296c

Browse files
committed
Fixing Copilot findings
1 parent 3c8e7f8 commit 347296c

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

py/circuitpy_mpconfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ typedef long mp_off_t;
406406
#define CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE (512)
407407
#endif
408408

409+
// Port-level upper bound for the QSPI display buffer (uint32_t words).
410+
// The _Static_assert in BusDisplay.c enforces this at compile time.
411+
// Ports with larger stacks can raise this in mpconfigport.h.
412+
#ifndef CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE_MAX
413+
#define CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE_MAX (2048)
414+
#endif
415+
409416
#else
410417
#define CIRCUITPY_DISPLAY_LIMIT (0)
411418
#define CIRCUITPY_DISPLAY_AREA_BUFFER_SIZE (0)

shared-module/busdisplay/BusDisplay.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,10 @@ static bool _refresh_area(busdisplay_busdisplay_obj_t *self, const displayio_are
261261
// QSPI panels benefit from larger sub-rectangle buffers because each chunk
262262
// has non-trivial command/window overhead. Keep this path qspibus-specific
263263
// to avoid increasing stack usage on other display buses.
264-
// Guard: buffer is a VLA on stack; 2048 uint32_t words = 8KB is the safe
265-
// upper bound for ESP32-S3's 24KB main task stack.
266-
_Static_assert(CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE <= 2048,
267-
"CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE exceeds safe stack limit (8KB)");
264+
// Guard: buffer is a VLA on stack. The port-specific max keeps shared
265+
// code free of single-port assumptions (default 2048 words = 8KB).
266+
_Static_assert(CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE <= CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE_MAX,
267+
"CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE exceeds CIRCUITPY_QSPI_DISPLAY_AREA_BUFFER_SIZE_MAX");
268268
bool is_qspi_bus = mp_obj_is_type(self->bus.bus, &qspibus_qspibus_type);
269269
if (is_qspi_bus &&
270270
self->core.colorspace.depth == 16 &&

0 commit comments

Comments
 (0)