Skip to content

fix(esp32/lcd_spi): explicit r-m-w on volatile mNextByteOffset (#2723) - #2734

Merged
zackees merged 1 commit into
masterfrom
fix/2723-volatile-compound-assign
Jun 4, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/2723-volatile-compound-assign

Conversation

@zackees

@zackees zackees commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

Closes #2723.

Summary

-Wvolatile fires on src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_spi.cpp.hpp:256:

warning: compound assignment with volatile-qualified left operand is deprecated [-Wvolatile]
  ctx.mNextByteOffset += chunkBytes;

C++20 deprecates this; C++23 makes it a hard error. ESP-IDF 5.x is already shipping with GCC 14 and the FastLED matrix is moving toward C++23/26, so this needs to land before the toolchain default crosses that line.

Fix

mNextByteOffset is legitimately volatile — it's the ISR/main-thread memory model documented at channel_driver_lcd_spi.h:117-130 (ISR writes, main thread reads after detecting mStreamComplete). Dropping the qualifier is the wrong fix.

The right fix is the explicit read-modify-write the warning is asking for:

-ctx.mNextByteOffset += chunkBytes;
+ctx.mNextByteOffset = ctx.mNextByteOffset + chunkBytes;

Same code-gen, same memory semantics, no warning, no future C++23 break.

The other volatile field writes in this TU (mStreamComplete, mRingWriteIdx) already use plain = (line 257 even pre-stages writeIdx into a local), so no other sites need fixing.

Test plan

  • bash lint clean
  • CI green on esp32s3 (where LCD-SPI driver actually compiles in)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of LCD SPI display communication on ESP32 devices through corrected interrupt memory handling.

`-Wvolatile` fires on `ctx.mNextByteOffset += chunkBytes;` — C++20
deprecates compound assignment on volatile-qualified left operands;
C++23 makes it a hard error. ESP-IDF 5.x is already shipping with GCC 14
and the FastLED matrix is moving toward C++23/26, so this needs to land
before the toolchain default crosses that line.

`mNextByteOffset` is legitimately volatile — it's the ISR/main-thread
memory model documented at channel_driver_lcd_spi.h:117-130 (ISR writes,
main thread reads after detecting mStreamComplete). Dropping the
qualifier is the wrong fix; the right fix is to spell the r-m-w out:

  ctx.mNextByteOffset = ctx.mNextByteOffset + chunkBytes;

Closes #2723.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4035a882-8142-44b7-99b3-a30cb1f24012

📥 Commits

Reviewing files that changed from the base of the PR and between ae6785b and 6e16946.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_spi.cpp.hpp

📝 Walkthrough

Walkthrough

The ESP32 LCD-SPI driver's ISR chunk completion handler is updated to comply with C++23's restriction on volatile compound assignments. The offset counter update is refactored from compound assignment (+=) to explicit read-modify-write, eliminating a deprecation warning that becomes a hard error in C++23.

Changes

Volatile Compound Assignment Compliance

Layer / File(s) Summary
ISR volatile offset update for C++23 compliance
src/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_spi.cpp.hpp
The isrChunkDone ISR handler updates ctx.mNextByteOffset using explicit read-modify-write (ctx.mNextByteOffset = ctx.mNextByteOffset + chunkBytes) instead of compound assignment (+=), with added comments documenting volatile semantics and C++23 compliance.

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A volatile fix for C++23 days,
Compound assignments now go away,
Read-modify-write takes the stage,
ISRs update with finesse and grace,
FastLED hops forward without a trace. 🐰⚡

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary change: replacing compound assignment with explicit read-modify-write on a volatile field to address the C++20/23 compliance issue.
Linked Issues check ✅ Passed The code change directly implements the proposed fix from issue #2723: replacing compound assignment (+=) with explicit read-modify-write on mNextByteOffset to resolve the -Wvolatile warning/error.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to fixing the volatile compound assignment issue in the ISR handler; no unrelated modifications were introduced.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/2723-volatile-compound-assign

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 4, 2026
@zackees
zackees merged commit 6917beb into master Jun 4, 2026
6 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 4, 2026
@zackees
zackees deleted the fix/2723-volatile-compound-assign branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

CRITICAL: -Wvolatile compound assignment in channel_driver_lcd_spi.cpp.hpp:256 (hard error in C++23)

1 participant