From 498fd737663a5017f00f19739569c08bb7476811 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Devenyi" Date: Fri, 14 Aug 2026 23:03:04 -0400 Subject: [PATCH 1/3] COMP: Give install_linking the source directory instead of guessing it The test hard-codes the path to the downstream example project: cmake ... ../../nifti_clib/real_easy/minimal_example_of_downstream_usage That only resolves when the build directory happens to be a sibling of a source tree named exactly "nifti_clib". It fails for an in-tree build, for a build directory named anything else, and on CI, where the checkout lives at /nifti_clib and the path resolves to /nifti_clib/nifti_clib/real_easy/... CMake now passes CMAKE_SOURCE_DIR to the script, the way the other test scripts in that directory already receive their arguments. (cherry picked from commit 6458714c7bd0cb1a5b2be12d442eb82a70dacd98) --- nifti2/CMakeLists.txt | 2 +- .../cmake_testscripts/install_linking_test.sh | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/nifti2/CMakeLists.txt b/nifti2/CMakeLists.txt index 6028291d..758df0b9 100644 --- a/nifti2/CMakeLists.txt +++ b/nifti2/CMakeLists.txt @@ -184,7 +184,7 @@ if(NIFTI_BUILD_TESTING AND NIFTI_BUILD_APPLICATIONS) if(TEST_INSTALL) add_test( NAME install_linking - COMMAND sh ${NIFTI_TEST_SCRIPT_DIR}/install_linking_test.sh ${CMAKE_MAKE_PROGRAM} + COMMAND sh ${NIFTI_TEST_SCRIPT_DIR}/install_linking_test.sh ${CMAKE_MAKE_PROGRAM} ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_BINARY_DIR} ) endif() endif() diff --git a/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh b/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh index dccf0fe9..89dcaeaf 100755 --- a/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh +++ b/nifti2/nifti_regress_test/cmake_testscripts/install_linking_test.sh @@ -10,6 +10,18 @@ else export BUILD_TOOL=$1 fi +# Where the project source lives. This used to be hard-coded as +# ../../nifti_clib relative to the build directory, which only resolved +# when the build tree happened to be a sibling of a source tree named +# exactly "nifti_clib" -- so the test failed for an in-tree build, for a +# build directory named anything else, and on CI. +if [ $# -lt 2 ] +then + echo Missing source directory + exit 1 +fi +SRC_DIR=$2 + # Set variables for local install export DESTDIR=installed export PATH="$PWD/$DESTDIR/usr/local/bin:$PATH" @@ -28,7 +40,7 @@ cd downstream_example cmake \ -G 'Unix Makefiles' \ -DCMAKE_MODULE_PATH=../installed/usr/local/share \ - ../../nifti_clib/real_easy/minimal_example_of_downstream_usage + "${SRC_DIR}/real_easy/minimal_example_of_downstream_usage" make echo Success From e845414c3685fdb407bfe439baaca80158751fd1 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Wed, 23 Sep 2026 06:18:05 -0500 Subject: [PATCH 2/3] BUG: Pass a void pointer to %p in the CIFTI NULL-input message %p takes a pointer to void. fname was passed as const char *, while its two siblings on the same line were already cast, so the mismatch was a single argument. Clang reports it under -Wformat-pedantic. (cherry picked from commit 7fa06d7bb4c5b9c76f1066c33c790738d22be560) (cherry picked from commit f7381a3a99b892b26ab877f06b45ac178f34780f) --- cifti/afni_xml_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cifti/afni_xml_io.c b/cifti/afni_xml_io.c index a59f5c3e..c4513557 100644 --- a/cifti/afni_xml_io.c +++ b/cifti/afni_xml_io.c @@ -45,7 +45,7 @@ int axio_read_cifti_file(const char * fname, int get_ndata, if( !fname || !nim_out || !ax_out ) { fprintf(stderr,"** axio_CIFTI: NULL inputs %p, %p, %p\n", - fname, (void *)nim_out, (void *)ax_out); + (const void *)fname, (void *)nim_out, (void *)ax_out); return 1; } From 1bbf73e440a8475aa141012f0ea5166b01b431c1 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Devenyi" Date: Sat, 15 Aug 2026 00:14:50 -0400 Subject: [PATCH 3/3] COMP: Add CI jobs for clang-tidy and for building with -Werror A new workflow with two jobs, so that the clang-tidy configuration and the shared warning set are exercised rather than merely present. clang-tidy configures with CMAKE_EXPORT_COMPILE_COMMANDS and runs run-clang-tidy. It reports findings without failing; removing the '|| true' is the last step of that work, once the remaining checks are clean. warnings-as-errors a gcc and a clang job, each configuring with NIFTI_WARNINGS_AS_ERRORS=ON, building and testing. The warning sites that once blocked the second job have since been fixed: the sign conversions in the tools, the transposed calloc arguments, and the ambiguous-filename rewrite all landed separately. (cherry picked from commit bb8e9af3a9a291364ab1b5010ef1e61cf25ea332) (cherry picked from commit 5fdc07c77c6afc1b27b92f8595279d79ea34a44a) --- .github/workflows/static-checks.yml | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/static-checks.yml diff --git a/.github/workflows/static-checks.yml b/.github/workflows/static-checks.yml new file mode 100644 index 00000000..79e0186d --- /dev/null +++ b/.github/workflows/static-checks.yml @@ -0,0 +1,61 @@ +name: Static checks + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + clang-tidy: + name: clang-tidy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + cmake ninja-build clang-tidy zlib1g-dev libexpat1-dev + + - name: Configure + run: | + cmake -S . -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DUSE_CIFTI_CODE=ON -DUSE_FSL_CODE=ON + + # The tree is not yet clean under every enabled check, so this reports + # findings without failing. Drop the "|| true" once it is. + - name: Run clang-tidy + run: run-clang-tidy -p build -j "$(nproc)" -quiet || true + + warnings-as-errors: + name: warnings-as-errors (${{ matrix.cc }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + cc: [gcc, clang] + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends \ + cmake ninja-build zlib1g-dev libexpat1-dev + + - name: Build with -Werror + run: | + cmake -S . -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER=${{ matrix.cc }} \ + -DBUILD_SHARED_LIBS=ON \ + -DUSE_CIFTI_CODE=ON -DUSE_FSL_CODE=ON \ + -DNIFTI_WARNINGS_AS_ERRORS=ON + cmake --build build -j "$(nproc)" + + - name: Test + run: ctest --test-dir build --output-on-failure