Skip to content

Fix broken SITL build: unbalanced #if SITL_BUILD in taskSystem() (merge #11727 artifact) - #11738

Merged
sensei-hacker merged 1 commit into
iNavFlight:maintenance-10.xfrom
xznhj8129:fix/sitl-scheduler-dup-preprocessor
Jul 20, 2026
Merged

Fix broken SITL build: unbalanced #if SITL_BUILD in taskSystem() (merge #11727 artifact)#11738
sensei-hacker merged 1 commit into
iNavFlight:maintenance-10.xfrom
xznhj8129:fix/sitl-scheduler-dup-preprocessor

Conversation

@xznhj8129

Copy link
Copy Markdown
Contributor

Problem

maintenance-10.x does not build for SITL. Every SITL build fails at scheduler.c:

src/main/scheduler/scheduler.c:131: error: unterminated #else
src/main/scheduler/scheduler.c:148: error: expected declaration or statement at end of input

(plus a cascade of -Werror=unused-function/unused-variable on the scheduler queue statics, because the malformed conditional excludes their users). Unit-test builds are unaffected — they define UNIT_TEST, not SITL_BUILD, so the broken branch isn't compiled there and CI's unit jobs stay green while SITL is dead.

Cause

taskSystem() had two independent fixes for the SITL load-accounting bug (#11710) land on different lines — one on release/9.1, one via the MAVLink stack — that both rewrote the same block. The release/9.1 merge (#11727) resolved that conflict by concatenating both copies rather than choosing one: it kept the release/9.1 block as the outer #if defined(SITL_BUILD) and pasted the other copy inside the #else branch. The inner #endif then closes the duplicate's #if, leaving the outer #if (line 131) with no matching #endif.

Fix

Remove the duplicated #if defined(SITL_BUILD) block from inside the #else, restoring the single intended (release/9.1) version. No functional change to load accounting — the two copies were the same wall-clock algorithm.

Verified

SITL builds and links cleanly with -Werror after the change. taskSystem() is now byte-identical to the intended release/9.1 version.

The release/9.1 merge (iNavFlight#11727) hit a conflict in taskSystem() where two
independent fixes for the SITL load-accounting bug (iNavFlight#11710) — one from
release/9.1, one from the mavlink stack — were concatenated instead of
one being chosen. The result nested a duplicate '#if defined(SITL_BUILD)'
block inside the '#else' branch, leaving the outer '#if' with no matching
'#endif' and failing every SITL build with 'unterminated #else'.

Remove the duplicated block, restoring the single intended (release/9.1)
version. No functional change to load accounting; unit builds were
unaffected (UNIT_TEST, not SITL_BUILD).
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@sensei-hacker
sensei-hacker merged commit 27052b1 into iNavFlight:maintenance-10.x Jul 20, 2026
22 of 23 checks passed
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.

2 participants