Ref shouldACK in lambda to only set once

This commit is contained in:
Allen Hill
2026-07-05 19:40:48 -07:00
parent 1e416a3457
commit 1fdd296784
+6 -3
View File
@@ -83,7 +83,12 @@ auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
if (auto rerr = handle.read<ADDR_WIDTH>(
&in->peripheral_addr,
[&]() { return !is_muted() && (in->peripheral_addr == address); });
// Using lambda for delayed evaluation of peripheral_addr field
// deref, which will be written by the time the lambda is evaluated
[&]() {
shouldACK = !is_muted() && (in->peripheral_addr == address);
return shouldACK;
});
rerr == BAD_PARITY) {
err.errno = BAD_PERIPHERAL_PARITY;
if (print.verbose) {
@@ -92,8 +97,6 @@ auto Bus::read(uint16_t address, Frame *in, Frame::Print print) -> Error::Read {
goto handle_err;
}
shouldACK = !is_muted() && (in->peripheral_addr == address);
if (auto rerr = handle.read<CONTROL_WIDTH>(&in->control, shouldACK);
rerr == BAD_PARITY) {
err.errno = BAD_CONTROL_PARITY;