From 2b85fca4ceb85012bbe43de20f8b0599c7bb40be Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Mon, 21 Sep 2026 11:28:33 -0500 Subject: [PATCH] COMP: Track the warning flags that are not yet clean 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 0ea22ef1cfc5b5ba580d75c7828f8d05ec39ca22) --- cmake/nifti_warnings.cmake | 80 +++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 19 deletions(-) diff --git a/cmake/nifti_warnings.cmake b/cmake/nifti_warnings.cmake index 65553fe4..6fe471c5 100644 --- a/cmake/nifti_warnings.cmake +++ b/cmake/nifti_warnings.cmake @@ -20,6 +20,14 @@ # make CI fail on them. That option is only safe to turn on in CI once # the future set below is empty. # +# THIS BRANCH ALSO ENABLES THE FUTURE SET, so that CI measures it on +# every run and the counts below stay honest as the fixing changes land. +# NIFTI_WARNINGS_AS_ERRORS therefore stays OFF here: the future-set +# flags still warn, and making them errors would leave this branch +# permanently red and useless as a measurement. A flag graduates into +# the clean set only in a change that follows the one fixing its +# warnings, so CI is green at every step. +# option(NIFTI_ENABLE_WARNINGS "Enable the project's compiler warning set" ON) option(NIFTI_WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) @@ -61,6 +69,45 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang") ) endif() +# --------------------------------------------------------------------- +# READY TO PROMOTE - measured at zero on this tree +# --------------------------------------------------------------------- +# These were in the future set and now hit nothing. They belong in the +# clean set above; moving them there is the companion change's job, not +# this branch's. Kept enabled here so a regression is caught. +if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") + list(APPEND _nifti_warnings + -Wextra # was 3 via -Wsign-compare, now 0 + -Wmissing-prototypes # was 18, now 0 + ) +endif() + +if(CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang") + list(APPEND _nifti_warnings + -Wnewline-eof # was 1, now 0 + ) +endif() + +# --------------------------------------------------------------------- +# FUTURE SET - still warns, enabled here only to keep the count honest +# --------------------------------------------------------------------- +if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang|AppleClang") + list(APPEND _nifti_warnings + -Wcast-qual # 9 + -Wsign-conversion # 200 + ) +endif() + +if(CMAKE_C_COMPILER_ID MATCHES "Clang|AppleClang") + list(APPEND _nifti_warnings + -Wmissing-variable-declarations # 2 + -Wconditional-uninitialized # 11 + -Wcast-align # 19 + -Wshorten-64-to-32 # 31 + -Wextra-semi-stmt # 72 + ) +endif() + if(NIFTI_WARNINGS_AS_ERRORS) if(MSVC) list(APPEND _nifti_warnings /WX) @@ -76,31 +123,26 @@ unset(_nifti_warnings) # FUTURE SET - wanted, not yet earned # ===================================================================== # -# Counts measured 2026-09-21 at d773c59, AppleClang 21.0.0, Release, +# Counts measured 2026-09-22 at b4876bf, AppleClang 21.0.0, Release, # USE_CIFTI_CODE=ON USE_FSL_CODE=ON FSLSTYLE=ON, NIFTI_BUILD_TESTING=OFF. -# Promote a flag to the clean set above only in a PR that follows the -# PR fixing its warnings, so CI is green at every step. # -# flag hits fix +# flag hits # ------------------------------------------------------------------ -# -Wsign-compare (via -Wextra) 3 PR #51 -# -Wcast-qual 9 PR #45 -# -Wmissing-prototypes 18 PR #37 -# -Wsign-conversion 200 PR #53 / #52, split by dir: -# znzlib 4, cifti 14, -# fsliolib 45, nifti2 58, -# niftilib 79 +# -Wextra (via -Wsign-compare) 0 ready to promote +# -Wcast-qual 9 +# -Wmissing-prototypes 0 ready to promote +# -Wsign-conversion 200 split by dir: znzlib 4, +# cifti 14, fsliolib 45, +# nifti2 58, niftilib 79 # # Clang-only: -# -Wnewline-eof 1 PR #35 covers one file only +# -Wnewline-eof 0 ready to promote # -Wmissing-variable-declarations 2 -# -Wconditional-uninitialized 11 relates to PR #47 / #48 -# -Wcast-align 19 relates to PR #44 -# -Wshorten-64-to-32 31 relates to PR #52 -# -Wextra-semi-stmt 74 relates to PR #49 -# -# -Wextra is held back only because it implies -Wsign-compare; once -# PR #51 lands it moves to the clean set with its 3 hits resolved. +# -Wconditional-uninitialized 11 +# -Wcast-align 19 +# -Wshorten-64-to-32 31 +# -Wextra-semi-stmt 72 fsliolib 70, niftilib 1, +# nifti2 1 # # NOT MEASURED, do not add without a census first: #