Skip to content

COMP: Track the warning flags that are not yet clean - #76

Draft
hjmjohnson wants to merge 1 commit into
masterfrom
future/33-warning-flags-future
Draft

hjmjohnson wants to merge 1 commit into
masterfrom
future/33-warning-flags-future

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

Measurement branch: enables the warning flags the tree does not yet pass, so CI counts them on every run. The clean set it sits on top of is on master (#33, #95). Keep as a draft; flags graduate out of it one at a time, each after the change fixing its warnings has landed.

NIFTI_WARNINGS_AS_ERRORS stays OFF here by design: the build succeeds and the warnings appear in the log.

Ready to promote now: -Wcast-align, -Wextra-semi-stmt, -Wmissing-variable-declarations, and -Wnewline-eof (Clang), plus -Wduplicated-branches, -Wduplicated-cond, -Wjump-misses-init, -Wlogical-op, and -Wold-style-definition (GCC) measure zero on master and can move into the clean set in their own change.

Census at 81f36bf

AppleClang 21 and GCC 16, Release, NIFTI_BUILD_TESTING=ON USE_CIFTI_CODE=ON USE_FSL_CODE=ON FSLSTYLE=ON.

Flag AppleClang 21 GCC 16
-Wsign-conversion 198 217
-Wshorten-64-to-32 31 n/a
-Wmissing-prototypes 18 18
-Wconditional-uninitialized 13 n/a
-Wextra 0 10
-Wcast-qual 1 1
ready block, Clang 0 n/a
ready block, GCC n/a 0

-Wextra on GCC 16 is all -Wcalloc-transposed-args. -Wcast-qual is one cast in niftilib/nifti_short_read_test.c.

Promotion order
  1. The ready block (already zero).
  2. -Wcast-qual (1), then -Wextra once the calloc argument order is fixed.
  3. -Wconditional-uninitialized (13), -Wmissing-prototypes (18).
  4. -Wshorten-64-to-32 (31).
  5. -Wsign-conversion (198), split by directory.
  6. Only then NIFTI_WARNINGS_AS_ERRORS=ON in CI.
clang-cl and MSVC

The blocks this branch adds skip clang-cl (AND NOT MSVC), which reports the Clang compiler ID but takes MSVC-style flags. The clean-set blocks on master still lack that guard and need their own change. MSVC /W3 has never been measured.

@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
@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
@hjmjohnson
hjmjohnson force-pushed the comp/shared-warning-set branch from cce3156 to da23237 Compare October 6, 2026 14:35
@hjmjohnson
hjmjohnson marked this pull request as draft October 6, 2026 15:02
@hjmjohnson
hjmjohnson force-pushed the comp/shared-warning-set branch 2 times, most recently from 9047293 to 8e6e2c8 Compare October 6, 2026 19:08
@hjmjohnson
hjmjohnson force-pushed the comp/shared-warning-set branch 3 times, most recently from ab05240 to a4b9fe6 Compare October 14, 2026 19:00
Base automatically changed from comp/shared-warning-set to master October 23, 2026 18:33
@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch from 2b85fca to 2c25cc9 Compare November 2, 2026 13:59
@hjmjohnson hjmjohnson changed the title COMP: Track the warning flags that are not yet clean (companion to #33) COMP: Track the warning flags that are not yet clean Nov 2, 2026
@hjmjohnson

Copy link
Copy Markdown
Member Author

Rebuilt on master (a2ff9a0) as one commit, 2b85fca → 2c25cc9. This push mixes rebase and content because the conflict could not be resolved mechanically: master's nifti_warnings.cmake dropped the documentation-only FUTURE SET section and the per-flag comments during #95's review, and replaying the old commit would have put both back.

What changed
  • The clean-set commit (cce3156) dropped out; its content is master's.
  • The future-set commit is re-authored on master's file: two list(APPEND) blocks (ready to promote, still warns), no per-flag comments, and one header sentence corrected so it no longer claims every flag is at zero. Counts now live in the PR body.
  • The census was re-run on a2ff9a0. The September comment's "now zero" claims for -Wextra and -Wmissing-prototypes were measured on the lineage master was later reverted from; on current master they are 3 and 18 again. -Wcast-qual has gone from 9 to 0.
  • (cherry picked from commit …) trailer removed; the human Co-Authored-By kept.

Verified locally: ninja exit 0 with testing off and on, warning counts from the branch alone match the census, ctest 344/344.

@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch from 2c25cc9 to d86c549 Compare November 2, 2026 21:54

@gdevenyi gdevenyi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Google Carbon

Verdict: Request Changes (Keep as Draft measurement branch; rebase & update census)

Since this PR intentionally enables noisy future flags with NIFTI_WARNINGS_AS_ERRORS=OFF to measure warning counts across CI, it should remain unmerged as a draft tracking branch, with the following updates needed:

  1. Rebase onto current master (50a9216): Base a2ff9a0 predates #88 (a79dd8a), so CI on this branch is currently not compiling cifti/, fsliolib/, or -DFSLSTYLE=ON (-DPIGZ, -DREJECT_COMPLEX)!
  2. Guard CMAKE_C_COMPILER_ID MATCHES ... blocks against clang-cl (AND NOT MSVC): On Windows with clang-cl, CMAKE_C_COMPILER_ID is "Clang" while MSVC is TRUE, and passing -Wall to clang-cl maps to MSVC /Wall = Clang -Weverything! Every GNU/Clang block in cmake/nifti_warnings.cmake (both here and on master) should check if(CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang)$" AND NOT MSVC).
  3. Updated warning census on origin/master (50a9216) (verified with clang-20, gcc-13, and gcc-14 across all targets & tests with FSLSTYLE=OFF/ON):
    • Ready to promote to master's clean set now (0 warnings): -Wcast-qual, -Wnewline-eof, and 5 GCC-only flags that were previously unmeasured: -Wduplicated-branches, -Wduplicated-cond, -Wjump-misses-init, -Wlogical-op, -Wold-style-definition.
    • -Wextra is already 0 on Clang 20 and GCC 13! (-Wsign-compare was cleared in ab70a3b; on GCC >= 14 -Wextra only trips 8–10 -Wcalloc-transposed-args sites).
    • Note on -Wmissing-declarations: Already in master's clean set because the initial census ran on AppleClang (where -Wmissing-declarations is a no-op for C functions!), but it actually emits 14–18 warnings on GCC until PR #90 lands.

Comment thread cmake/nifti_warnings.cmake Outdated
# ---------------------------------------------------------------------
# Ready to promote: measured at zero, not yet in the clean set
# ---------------------------------------------------------------------
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Google Carbon] Guard all GNU|Clang|AppleClang / Clang|AppleClang conditions (here and on lines 37, 46, 55, 72, 81, 89) with AND NOT MSVC and anchor the regex (MATCHES "^(GNU|Clang|AppleClang)$" AND NOT MSVC). Under clang-cl on Windows, CMAKE_C_COMPILER_ID is "Clang" with MSVC=TRUE, where -Wall is interpreted as /Wall (-Weverything).

Also note that -Wcast-qual (here), -Wnewline-eof (line 74), and GCC's -Wduplicated-branches, -Wduplicated-cond, -Wjump-misses-init, -Wlogical-op, and -Wold-style-definition are all at 0 warnings on current master and ready for a standalone promotion PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blocks this branch adds are anchored and guarded with AND NOT MSVC in 51485b4, and the zero-count flags you listed (GCC-only five included) now sit in the ready block; -Wcast-qual went back to the future set because nifti_short_read_test.c now has one hit. The two clean-set blocks belong to master, so their guard needs its own change there; leaving this open until that is decided.

Comment thread cmake/nifti_warnings.cmake Resolved
@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch from d86c549 to 51485b4 Compare November 17, 2026 22:33
Enable the flags the tree does not yet pass 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.  These 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.

Flags that now measure zero on AppleClang and GCC sit in their own
block, ready to move into the clean set.  The added blocks skip
clang-cl, which reports the Clang ID but reads GCC-style flags as MSVC
ones.

Co-Authored-By: Gabriel A. Devenyi <gdevenyi@gmail.com>
@hjmjohnson
hjmjohnson force-pushed the future/33-warning-flags-future branch from 51485b4 to 4277649 Compare November 17, 2026 22:33
@hjmjohnson

Copy link
Copy Markdown
Member Author

Two force-pushes: d86c549..51485b4 is the review fix only (on the old base); 51485b4..4277649 is a plain rebase onto master (81f36bf), which brings in the all CI legs that build cifti/, fsliolib/, and FSLSTYLE.

Census at 81f36bf (AppleClang 21 and GCC 16, Release, testing ON, cifti, FSL, and FSLSTYLE ON)
Flag AppleClang 21 GCC 16
-Wsign-conversion 198 217
-Wshorten-64-to-32 31 n/a
-Wmissing-prototypes 18 18
-Wconditional-uninitialized 13 n/a
-Wcast-qual 1 1
-Wextra 0 10 (-Wcalloc-transposed-args)
-Wcast-align, -Wextra-semi-stmt, -Wmissing-variable-declarations, -Wnewline-eof 0 n/a
-Wduplicated-branches, -Wduplicated-cond, -Wjump-misses-init, -Wlogical-op, -Wold-style-definition n/a 0

-Wcast-qual is no longer zero: niftilib/nifti_short_read_test.c:85 (added in 060eb74) casts away const, so it moved back to the future set. GCC 16 also reports two -Wuse-after-free hits from -Wall (clean set) in the FSLSTYLE branch of nifti_findhdrname() in both nifti1_io.c and nifti2_io.c, where basename is printed after free(); that is a master bug, not this branch's.

Build exits 0 under both compilers; ctest 351/351 on AppleClang.

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