Skip to content

C: remove broken and unused put_bitfield_n_by_index helper - #1227

Open
julianoes wants to merge 1 commit into
ArduPilot:masterfrom
julianoes:remove-dead-bitfield-helper
Open

C: remove broken and unused put_bitfield_n_by_index helper#1227
julianoes wants to merge 1 commit into
ArduPilot:masterfrom
julianoes:remove-dead-bitfield-helper

Conversation

@julianoes

Copy link
Copy Markdown
Contributor

Disclaimer: found by Claude.

put_bitfield_n_by_index() seems to be dead code, and not doing anything if used anywhere.

buffer[i_byte_index] |= ((0x00 << curr_bits_n) & v);

put_bitfield_n_by_index() is dead code: it is never called by any
generated message code or generator template, and the MAVLink wire
format has no sub-byte bitfield field type (fields are byte-aligned
scalars/arrays only), so nothing can drive a call to it.

It is also buggy: the packing line

    buffer[i_byte_index] |= ((0x00 << curr_bits_n) & v);

masks the value with 0, so any bits packed would come out as zero. As
the only way to reach it is to call this public helper directly from
application code, remove it (and its MAVLINK_SEPARATE_HELPERS forward
declaration) from the v1.0 and v2.0 fixed headers rather than fix and
maintain an untested feature with no users. The frozen v0.9 headers are
left untouched.
@tridge
tridge force-pushed the remove-dead-bitfield-helper branch from 0953267 to 0264928 Compare July 29, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant