Skip to content

BUG: Fix cifti_tool's CIFTI extension search, which never advanced - #126

Open
hjmjohnson wants to merge 7 commits into
stack/fix-axml-skip-depthfrom
stack/pr-fix-analyzer-leaks
Open

hjmjohnson wants to merge 7 commits into
stack/fix-axml-skip-depthfrom
stack/pr-fix-analyzer-leaks

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Re-submission of #56, reverted from master on 2026-09-24. Content is
unchanged from the original.

Position 4 of 11 in the deep stack. Base: stack/fix-axml-skip-depth.

Based on the pull request above it in the stack, so the diff shown here is
this change alone. Merge the stack bottom-up.

Stack order

# branch base
1 stack/test-regression-coverage master
2 stack/pr-fix-alloc-null-checks stack/test-regression-coverage
3 stack/fix-axml-skip-depth stack/pr-fix-alloc-null-checks
4 stack/pr-fix-analyzer-leaks <- this PR stack/fix-axml-skip-depth
5 stack/pr-fix-sign-conversion stack/pr-fix-analyzer-leaks
6 stack/fix-fslio-64bit-arithmetic stack/pr-fix-sign-conversion
7 stack/fix-cifti-null-stream stack/fix-fslio-64bit-arithmetic
8 stack/pr-fix-calloc-transposed-args stack/fix-cifti-null-stream
9 stack/pr-fix-shorten-64-to-32 stack/pr-fix-calloc-transposed-args
10 stack/fix-image-read-complex-check stack/pr-fix-shorten-64-to-32
11 stack/pr-fix-xml-read-errors stack/fix-image-read-complex-check

The order is the order these changes sat on master before the revert, so
it builds and tests at every step.

Commits introduced by this PR
  • BUG: Fix cifti_tool's CIFTI extension search, which never advanced
  • ENH: Cover a CIFTI extension that is not first in the list

Ordering for all the re-submitted work is tracked in #84.

hjmjohnson and others added 7 commits September 24, 2026 07:12
A branch filter naming a branch that does not exist leaves the workflow
configured but never run, which looks the same as one that runs and
passes: no red check appears because no check appears at all. build.yml
sat dead behind a filter naming main on a repository whose branch is
master, and the only thing that found it was reading the file.

The check judges a filter only when every entry is a literal name, so a
release-* pattern or a branch that does not exist yet is left alone, and
it reports a name that resolves to nothing rather than one that merely
differs from the default.

(cherry picked from commit db038e9)
cppcheck 2.19 nullPointerOutOfMemory: the uppercase copy of the name
was written into an unchecked malloc result.  Return -1, the same
value the function already uses for an unrecognized name.

(cherry picked from commit c2d181e)
cppcheck 2.19 unreachableCode: FSLIOERR ends in exit(EXIT_FAILURE), so
the return statements following it in FslReadAllVolumes and
FslReadHeader can never run.

(cherry picked from commit f5f3766)
Fixes some clang-tidy bugprone-macro-parentheses warnings.

Would be an issue where an argument that is an expression would evaluated different with different precedence.

(cherry picked from commit 7387fd5)
Fixes many bugprone-implicit-widening-of-multiplication-result warnings.

Here the multiplications were happening in small types (int, usually 32 bit) then stored in large types (size_t, usually 64 bit). The multiplication could have overflowed. Now the multiplication is done with large types and thus less likely to overflow.

(cherry picked from commit 6d06faa)
disp_cifti_extension() searched for the CIFTI extension with

    ext = nim->ext_list;
    for( ind = 0; ind < nim->num_ext; ind++ )
       if( ext->ecode == NIFTI_ECODE_CIFTI ) break;

ext is never advanced, so this tests the first extension num_ext times.
cifti_tool could only ever find a CIFTI extension that happened to be
first in the list; with any other extension ahead of it the tool
reported 'no CIFTI extension' for a file that has one.  It now indexes
ext_list[ind] and leaves ext NULL when there is no match, which also
avoids the read past the end of the list that a bare ext++ would have
introduced.

The same function opened its output stream before the 'no CIFTI
extension' check and returned without closing it; the early return now
closes the stream like the normal path does.

(cherry picked from commit d93153c)
cext_second_extension.nii carries a comment extension ahead of the
CIFTI one.  The test requires the extension's payload in the output and
forbids the 'no CIFTI extension' message, and the existing
unterminated-cext test still pins the first-position case, so neither a
search that always matches nor one that never does would pass.

(cherry picked from commit 2405d09)
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.

3 participants