refactor(platform): out-line ModuleParams setParent and destructor to save flash (#28321)

Both were defined inline in the header, so the List add/remove bodies
were duplicated into the constructor and destructor of every one of the
150+ ModuleParams-derived classes. Construction and destruction are cold
paths; a call is smaller at each site.

Two consumers reach ModuleParams without px4_platform on the link line
and now need the definitions explicitly: health_and_arming_checks (the
functional-ModeManagement test only pulls it in transitively through
modules__commander, after px4_platform) and the failsafe_web emscripten
build, which compiles module_params.cpp directly.

The smaller constructors let the compiler fully inline the defaulted
FlightTaskDescend constructor on the ITCM boards, so its entry is
dropped from their linker scripts.

Saves 3968 B of .text on px4_fmu-v6x_default.


Assisted-by: Claude:claude-fable-5

Signed-off-by: Jacob Dahl <dahl.jakejacob@gmail.com>
Co-authored-by: Balduin <balduin@auterion.com>
This commit is contained in:
Jacob DahlandBalduin authored and GitHub committed 2026-08-21 10:34:09 -06:00
1 parent 047f91167d
commit 6c53460f2e
8 files changed
+53 -16

No files matched your search

@@ -56,19 +56,9 @@ public:
* @brief Sets the parent module. This is typically not required,
* only in cases where the parent cannot be set via constructor.
*/
void setParent(ModuleParams *parent)
{
if (parent) {
parent->_children.add(this);
}
void setParent(ModuleParams *parent);
_parent = parent;
}
virtual ~ModuleParams()
{
if (_parent) { _parent->_children.remove(this); }
}
virtual ~ModuleParams();
// Disallow copy construction and move assignment.
ModuleParams(const ModuleParams &) = delete;