Skip to content

fix: remove unnecessary let binding in defmt-only logging macros#749

Open
damonhunka wants to merge 1 commit intoOpenDevicePartnership:mainfrom
damonhunka:personal/damonhunka/remove-unnecessary-let-binding-defmt-macros
Open

fix: remove unnecessary let binding in defmt-only logging macros#749
damonhunka wants to merge 1 commit intoOpenDevicePartnership:mainfrom
damonhunka:personal/damonhunka/remove-unnecessary-let-binding-defmt-macros

Conversation

@damonhunka
Copy link

A suspected copy-pasted line in a logging macro made each log call slightly bigger, and 45 of them inside one async function added up to enough extra stack usage to silently overwrite battery data on a memory-constrained microcontroller.

Copilot AI review requested due to automatic review settings March 16, 2026 15:06
@damonhunka damonhunka requested a review from a team as a code owner March 16, 2026 15:06
@github-project-automation github-project-automation bot moved this to In progress in ODP Backlog Mar 16, 2026
@jerrysxie jerrysxie self-assigned this Mar 16, 2026
@jerrysxie jerrysxie added the bug Something isn't working label Mar 16, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces stack usage on embedded targets by removing an unnecessary local tuple binding from the defmt-only logging macro wrappers, addressing a suspected copy/paste artifact that inflated per-call stack frames.

Changes:

  • Remove let _ = (...) from trace!/debug!/info!/warn!/error! wrappers in the defmt-only logging module.
  • Keep the actual ::defmt::* invocations unchanged to preserve logging behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kurtjd
Copy link
Contributor

kurtjd commented Mar 16, 2026

These were originally added to fix cargo clippy issues you can see are being caught by CI (unused variables). Surprising that you see code size/stack size penalties, I figured they would be optimized out since the let let _ = ... has no effect. Except, I do remember mentioning in that PR that if the arguments passed into the logging macro have side effects (such as an argument that is a function that touches volatile memory) then that's not the case, so maybe that is what you are seeing here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

4 participants