Skip to content

Copter: remove written-only Copter._last_reason member - #35210

Closed
peterbarker wants to merge 1 commit into
ArduPilot:masterfrom
peterbarker:pr/remove-last-reason
Closed

peterbarker wants to merge 1 commit into
ArduPilot:masterfrom
peterbarker:pr/remove-last-reason

Conversation

@peterbarker

Copy link
Copy Markdown
Contributor

Summary

Remove this member which is only ever written to (roughly speaking)

Classification & Testing (check all that apply and add your own)

  • Checked by a human programmer
  • Non-functional change
  • No-binary change
  • Infrastructure change (e.g. unit tests, helper scripts)
  • Automated test(s) verify changes (e.g. unit test, autotest)
  • Tested manually, description below (e.g. SITL)
  • Tested on hardware
  • Logs attached
  • Logs available on request

Description

replaced by AP_Vehicle.control_mode_reason

replaced by AP_Vehicle.control_mode_reason
@AP-Review

Copy link
Copy Markdown

Automated review note — AI-generated (Claude+Codex), validated against the live diff. Please sanity-check before acting.
Verdict: REQUEST CHANGES

Reviewed at head 8c53fd4d11.
Full report: https://firmware.ardupilot.org/Tools/APReview/DevCallReviews/PRReviews/ardupilot/ardupilot/35210/1.html#pr35210

This head does not compile: removing the last_reason snapshot leaves its only use in place.

Blocking

  1. ArduCopter/mode.cpp:321 removes const ModeReason last_reason = _last_reason;, but line 328 still has reason != last_reason, so the SITL copter build fails with "'last_reason' was not declared in this scope". The member isn't written-only: it controls the notify beep when the current mode is re-selected with a different reason. If control_mode_reason is meant to replace it, read it before line 322 overwrites it, or the comparison is always false. Note that it is only updated on successful mode changes, unlike _last_reason.

@github-actions

Copy link
Copy Markdown

Global Size Summary (Total Flash delta in bytes)

Built from 8c53fd4 rebased onto a995235

Board Periph tracker blimp bootloader copter heli iofw plane rover sub
DrotekP3Pro _ _ _ * _ _ _ _ _ _
Hitec-Airspeed * _ _ _ _ _ _ _ _ _
MatekF405-CAN _ _ _ * _ _ _ _ _ _
f103-GPS * _ _ _ _ _ _ _ _ _

Jobs that did not succeed: Durandal, KakuteF7, MambaH743v4, MatekF405, MatekH743-bdshot, Pixhawk1-1M, disco (no sizes for Durandal, KakuteF7, MambaH743v4, MatekF405, MatekH743-bdshot, Pixhawk1-1M, disco).

@peterbarker
peterbarker deleted the pr/remove-last-reason branch November 17, 2026 01:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants