Repository navigation
fix(esp32/lcd_spi): explicit r-m-w on volatile mNextByteOffset (#2723) - #2734
Conversation
`-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]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 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 ( ChangesVolatile Compound Assignment Compliance
Estimated Code Review Effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Closes #2723.
Summary
-Wvolatilefires onsrc/platforms/esp/32/drivers/lcd_spi/channel_driver_lcd_spi.cpp.hpp:256: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
mNextByteOffsetis legitimately volatile — it's the ISR/main-thread memory model documented atchannel_driver_lcd_spi.h:117-130(ISR writes, main thread reads after detectingmStreamComplete). Dropping the qualifier is the wrong fix.The right fix is the explicit read-modify-write the warning is asking for:
Same code-gen, same memory semantics, no warning, no future C++23 break.
The other
volatilefield writes in this TU (mStreamComplete,mRingWriteIdx) already use plain=(line 257 even pre-stageswriteIdxinto a local), so no other sites need fixing.Test plan
bash lintcleanesp32s3(where LCD-SPI driver actually compiles in)🤖 Generated with Claude Code
Summary by CodeRabbit