Skip to content

COMP: Track the warning flags that are not yet clean (companion to #33) - #76

Open
hjmjohnson wants to merge 1 commit into
comp/shared-warning-setfrom
future/33-warning-flags-future
Open

hjmjohnson wants to merge 1 commit into
comp/shared-warning-setfrom
future/33-warning-flags-future

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Companion to #33. That PR carries the clean set — the warning flags the tree is already at zero under, which can merge now. This draft carries the future set: the flags that still produce warnings, enabled so CI measures them on every run.

This branch is green. NIFTI_WARNINGS_AS_ERRORS stays OFF here by design, so the build succeeds and the warnings appear in the log rather than failing it. Verified locally: ninja exit 0, 368 warnings.

Keep as a draft. Flags graduate out of it one at a time, each only after the PR that fixes its warnings has landed, so CI is green at every step.

What is still dirty

Measured at d773c59, AppleClang 21, Release, USE_CIFTI_CODE=ON USE_FSL_CODE=ON FSLSTYLE=ON, NIFTI_BUILD_TESTING=OFF.

Flag Hits Blocked on
-Wsign-conversion 200 #53 / #52
-Wextra-semi-stmt 74 relates to #49
-Wshorten-64-to-32 31 relates to #52
-Wcast-align 19 relates to #44
-Wmissing-prototypes 18 #37
-Wconditional-uninitialized 11 relates to #47 / #48
-Wcast-qual 9 #45
-Wsign-compare (via -Wextra) 3 #51
-Wmissing-variable-declarations 2 —
-Wnewline-eof 1 #35 covers one file

-Wsign-conversion alone is 54% of the total. By directory: niftilib 79, nifti2 58, fsliolib 45, cifti 14, znzlib 4 — worth splitting so no single PR carries 200 mechanical casts through review.

Promotion order
  1. Measure the GCC-only block from a CI log (see below), promote whichever are already at zero.
  2. -Wnewline-eof (1), -Wmissing-variable-declarations (2).
  3. -Wsign-compare via BUG: Fix signed/unsigned comparisons in the nifti tools #51 — unlocks -Wextra.
  4. -Wcast-qual (9) via BUG: Stop casting away const in fslio and cifti #45.
  5. -Wconditional-uninitialized (11) via BUG: Give i and j a defined value in nifti_mat44_to_orientation #47 / ENH: Zero-initialize the matrix locals clang cannot prove are filled #48.
  6. -Wmissing-prototypes (18) via COMP: Declare the exported functions that no header declares #37, after resolving its two symbols that want static.
  7. -Wcast-align (19) via BUG: Use memcpy instead of casting to over-aligned pointer types #44.
  8. -Wshorten-64-to-32 (31), then -Wextra-semi-stmt (74).
  9. -Wsign-conversion (200), split by directory.
  10. Only then NIFTI_WARNINGS_AS_ERRORS=ON in CI, and COMP: Add CI jobs for clang-tidy and for building with -Werror #59's -Werror jobs.
Two branches left disabled for lack of CI

GCC-only block — -Wcast-align=strict, -Wduplicated-branches, -Wduplicated-cond, -Wjump-misses-init, -Wlogical-op, -Wold-style-definition. GNU 13.3.0 runs in CI, but these have never been enabled anywhere, so their counts are unknown. They cannot be measured on an Apple workstation, where /usr/bin/gcc is a clang shim. Measuring them from this branch's ubuntu-latest, gcc log is the first task here.

MSVC /W3 — no workflow has a Windows job, so that branch compiles nowhere. Enabling it would assert a cleanliness nobody can check.

Caveats and housekeeping
  • NIFTI_BUILD_TESTING=OFF in the census, so test sources are uncounted. Re-run with testing on before calling any flag clean tree-wide.
  • Counts are AppleClang; GNU 13.3 may differ. This branch's own CI is what will tell us.
  • This branch and COMP: Add a shared compiler warning set #33 both add cmake/nifti_warnings.cmake, so they conflict by construction. Rebase this one onto master once COMP: Add a shared compiler warning set #33 lands; the diff then reduces to the future-set block alone.
  • Both branches are based on current master (d773c59).

@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch from d57fd15 to 0a31a6b Compare September 21, 2026 16:30
@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch from 0a31a6b to 8a83c06 Compare September 22, 2026 13:51
@hjmjohnson

Copy link
Copy Markdown
Member Author

Rebased onto current master (b4876bf) and the census re-run. Three flags have gone to zero since the last measurement and are now staged as ready to promote rather than listed as future work.

Rebase — one real conflict, resolved on the merits

master's last 44 commits were rewritten on 2026-09-22 (messages only, trees byte-identical), so this branch's base no longer existed. Rebased with git rebase --onto master 0a31a6b^.

The CMakeLists.txt hunk dropped out: the include(nifti_warnings) line is already upstream.

cmake/nifti_warnings.cmake conflicted for real, not mechanically. master's copy of the file has moved on since this branch forked: it gained the per-flag explanatory comments in the clean set, the CLEAN SET - Clang only section heading, the census command with -DCMAKE_C_FLAGS="<the candidate flag>", and a trailing FUTURE SET block carried as documentation. This branch's copy predates all of that and would have reverted it.

Resolved by taking master's file whole and adding only what is actually this branch's contribution — the list(APPEND) blocks that enable the future set — rather than by taking either side. No master content was reverted.

Census refreshed — the old counts were stale

Re-measured at b4876bf, AppleClang 21.0.0, Release, USE_CIFTI_CODE=ON USE_FSL_CODE=ON FSLSTYLE=ON NIFTI_BUILD_TESTING=OFF — the same configuration the recorded counts were taken in.

flag was (d773c59) now (b4876bf)
-Wextra (via -Wsign-compare) 3 0
-Wmissing-prototypes 18 0
-Wnewline-eof 1 0
-Wextra-semi-stmt 74 72
-Wcast-qual 9 9
-Wsign-conversion 200 200
-Wmissing-variable-declarations 2 2
-Wconditional-uninitialized 11 11
-Wcast-align 19 19
-Wshorten-64-to-32 31 31

-Wmissing-prototypes going to zero is the direct consequence of -Werror=missing-declarations landing on master as a CI job — the census had not been re-run since.

The three zeroed flags are now in a READY TO PROMOTE block: still enabled here so a regression is caught, but labeled as belonging in the clean set, which is the companion change's job rather than this branch's. The -Wsign-conversion per-directory split is unchanged (znzlib 4, cifti 14, fsliolib 45, nifti2 58, niftilib 79); -Wextra-semi-stmt's 72 are fsliolib 70, niftilib 1, nifti2 1.

I also dropped the "needs PR #NN" column from the in-file table. Those numbers were going stale faster than the counts were, and a file in the repository is the wrong place to track a PR queue.

Commit message

Rewrapped to 78/72 and the census refresh recorded in the body. The Co-Authored-By: Gabriel A. Devenyi trailer is a human co-author and was kept. No tool trailers or transient URLs were present.

No regression test — and why

BUILD class: this change only adds compiler warning flags. There is no runtime seam a ctest could fail on. The correct verification is the census itself, which is what the table above is.

Build and test

macOS/arm64, Ninja, Release, -DNIFTI_BUILD_APPLICATIONS=ON -DUSE_NIFTI2_CODE=ON -DUSE_CIFTI_CODE=ON -DUSE_FSL_CODE=ON -DFSLSTYLE=ON: ninja -k 0 exits 0 — the build succeeds with the future set enabled, as intended — and 100% tests passed, 0 tests failed out of 364.

That build has NIFTI_BUILD_TESTING=ON, so its warning counts are higher than the recorded census (-Wextra-semi-stmt 270, -Wsign-conversion 204, -Wconditional-uninitialized 13); the test sources are outside the census configuration by design. The numbers in the file are the TESTING=OFF ones and were measured separately.

@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch 2 times, most recently from 922d25c to 0ea22ef Compare September 23, 2026 00:42
Enable the future-set flags alongside the clean set so CI measures them
on every run and the counts stay honest as the fixing changes land.

NIFTI_WARNINGS_AS_ERRORS stays OFF here by design.  The future-set
flags still warn, so making them errors would leave this branch
permanently red and useless as a measurement.  The build succeeds and
the warnings appear in the log.

The census was re-run against the current tree.  -Wextra, its
-Wsign-compare hits, -Wmissing-prototypes and -Wnewline-eof now measure
zero and are staged as ready to promote rather than listed as future
work.  -Wextra-semi-stmt fell from 74 to 72; the rest are unchanged.

The GCC-only and MSVC branches stay disabled: the GCC block has never
been enabled anywhere so its counts are unknown, and no workflow builds
on Windows.

Co-Authored-By: Gabriel A. Devenyi <3001850+gdevenyi@users.noreply.github.com>
(cherry picked from commit 0ea22ef)
@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch from 0ea22ef to 2b85fca Compare September 24, 2026 12:03
@hjmjohnson
hjmjohnson changed the base branch from master to comp/shared-warning-set September 24, 2026 12:03
@hjmjohnson
hjmjohnson marked this pull request as ready for review September 24, 2026 12:03
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