From df2ff090bf1a982d684900effec9d34e7d1a89ab Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 22 Sep 2026 07:44:30 -0500 Subject: [PATCH 1/2] COMP: Give the pigz writers internal linkage doPigz and doPigz2 are called only from the file that defines them and appear in no header, so they are internal. Declaring them so is what lets -Wmissing-declarations be promoted to an error on the FSLSTYLE path, where they were the only offenders. The copy of doPigz2 in the NIFTI-1 library is byte-identical to doPigz beside it and nothing calls it, so it is excluded from the build rather than given linkage it does not need. The exported symbol set is unchanged: this code compiles only under PIGZ, which the shared build behind the baseline does not define. (cherry picked from commit 1abbd8572bc489638c2568e0151086e8c2914a5b) --- nifti2/nifti2_io.c | 4 ++-- niftilib/nifti1_io.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/nifti2/nifti2_io.c b/nifti2/nifti2_io.c index 58b20841..7bf82c88 100644 --- a/nifti2/nifti2_io.c +++ b/nifti2/nifti2_io.c @@ -7859,7 +7859,7 @@ znzFile nifti_image_write_hdr_img2(nifti_image *nim, int write_opts, #ifdef PIGZ #ifdef HAVE_ZLIB -int doPigz2(nifti_image *nim, struct nifti_2_header nhdr, const nifti_brick_list * NBL) { +static int doPigz2(nifti_image *nim, struct nifti_2_header nhdr, const nifti_brick_list * NBL) { FILE *pigzPipe; char command[768]; strcpy(command, "pigz" ); @@ -7891,7 +7891,7 @@ int doPigz2(nifti_image *nim, struct nifti_2_header nhdr, const nifti_brick_list return 0; } -int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) { +static int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) { FILE *pigzPipe; char command[768]; strcpy(command, "pigz" ); diff --git a/niftilib/nifti1_io.c b/niftilib/nifti1_io.c index 1992b188..68afb733 100644 --- a/niftilib/nifti1_io.c +++ b/niftilib/nifti1_io.c @@ -5776,6 +5776,7 @@ znzFile nifti_image_write_hdr_img2(nifti_image *nim, int write_opts, #ifdef PIGZ #ifdef HAVE_ZLIB +#if 0 /* unused here: identical to doPigz below */ int doPigz2(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) { FILE *pigzPipe; char command[768]; @@ -5807,8 +5808,9 @@ int doPigz2(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list free(fp); return 0; } +#endif -int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) { +static int doPigz(nifti_image *nim, struct nifti_1_header nhdr, const nifti_brick_list * NBL) { FILE *pigzPipe; char command[768]; strcpy(command, "pigz" ); From 5f432d3157420cdf065b3a1cdd84223e95aa49ea Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 22 Sep 2026 07:44:54 -0500 Subject: [PATCH 2/2] COMP: Make an undeclared external function fail the build -Wmissing-declarations is already in the project's clean set, but a warning in a build that passes anyway is not read, so two changes that added declarations reached master with nothing to stop the next one. Both FSLSTYLE settings are covered. The flag catches nifti_fileexists on one side and axml_recur_find_xml, FslGetHdrImgNames and FslSetIntensityScaling on the other, each of which reached master as a warning nobody acted on. (cherry picked from commit b4876bf7dfe0d650c2cb675aa7a080416b34479f) --- .github/workflows/cmake-multi-platform.yml | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 68197e71..57639632 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -196,3 +196,37 @@ jobs: exit 1 fi echo "Exported symbols match the baseline." + + missing-declarations: + # A function defined without a prior declaration is either missing + # from its header or should have been static. Both shapes reached + # master before, because the flag is in the project's clean set but + # nothing makes it fatal, and a warning in a build that passes is + # not read. + # + # Promoting this one flag needs no preparatory cleanup. The whole + # NIFTI_WARNINGS_AS_ERRORS set is still blocked by + # -Wmaybe-uninitialized in fslio.c, and waiting for that would + # leave this uncovered meanwhile. + name: no undeclared external functions (FSLSTYLE=${{ matrix.fslstyle }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + fslstyle: ["OFF", "ON"] + steps: + - uses: actions/checkout@v4 + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y libexpat1-dev zlib1g-dev ninja-build + - name: Configure CMake + run: > + cmake -G Ninja -B ${{ github.workspace }}/build + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_C_FLAGS=-Werror=missing-declarations + -DNIFTI_BUILD_APPLICATIONS=ON + -DUSE_CIFTI_CODE=ON + -DUSE_FSL_CODE=ON + -DFSLSTYLE=${{ matrix.fslstyle }} + -S ${{ github.workspace }} + - name: Build + run: cmake --build ${{ github.workspace }}/build