BUG: Fix the REJECT_COMPLEX path in nifti_image_read - #132
Open
hjmjohnson wants to merge 3 commits into
Open
hjmjohnson wants to merge 3 commits into
hjmjohnson wants to merge 3 commits into
Conversation
Clears all 155 bugprone-macro-parentheses findings: 152 in nifti2/nifti_tool.c, 2 in niftilib/nifti1_tool.c, 1 in fsliolib/fslio.c. An unparenthesized argument takes the precedence of whatever the caller passed. NT_FILL(..., rv) expands to `rv = ...` and NT_MAT33_TO_MAT44 to `m44.m[0][0] = ...`, which break for an argument that is not already a postfix expression. Every current caller passes a plain identifier, a literal or `nim->sto_xyz`, so nothing observable moves. The NT_DCONVERT dtype and stype parameters stay bare behind a NOLINT fence: they name types, so `(dtype) * pd = dptr;` would be a cast expression rather than a declaration. FSL_RADIOLOGICAL is in an installed header, so its replacement list changes from -1 to (-1); its value does not. (cherry picked from commit dbfb59d)
nifti_image_read() ended the calling process with exit(13) when it met a complex datatype, leaking the open file and hfile on the way out. A library reports the condition to its caller: the block now frees the image, closes the file, releases hfile and returns NULL, which is how every other rejection in the function behaves. The message also loses its "64", which was wrong for the 128 and 256 cases. REJECT_COMPLEX is off by default but is supported: -DFSLSTYLE:BOOL=ON turns it on, and nifti2/Makefile defines it always. (cherry picked from commit c8a10fe)
Writes a DT_COMPLEX64 image and a DT_FLOAT32 image, then asserts nifti_image_read() returns NULL for the first and a usable image for the second, so a blanket refusal cannot pass. Registered only when FSLSTYLE_REJECT_COMPLEX is on. Against exit(13) the test process dies with status 13 before reaching either assertion. (cherry picked from commit 461cd33)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Re-submission of #74, reverted from
masteron 2026-09-24. Content isunchanged from the original.
Position 10 of 11 in the deep stack. Base:
stack/pr-fix-shorten-64-to-32.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
stack/test-regression-coveragemasterstack/pr-fix-alloc-null-checksstack/test-regression-coveragestack/fix-axml-skip-depthstack/pr-fix-alloc-null-checksstack/pr-fix-analyzer-leaksstack/fix-axml-skip-depthstack/pr-fix-sign-conversionstack/pr-fix-analyzer-leaksstack/fix-fslio-64bit-arithmeticstack/pr-fix-sign-conversionstack/fix-cifti-null-streamstack/fix-fslio-64bit-arithmeticstack/pr-fix-calloc-transposed-argsstack/fix-cifti-null-streamstack/pr-fix-shorten-64-to-32stack/pr-fix-calloc-transposed-argsstack/fix-image-read-complex-check<- this PRstack/pr-fix-shorten-64-to-32stack/pr-fix-xml-read-errorsstack/fix-image-read-complex-checkThe order is the order these changes sat on
masterbefore the revert, soit builds and tests at every step.
Commits introduced by this PR
Ordering for all the re-submitted work is tracked in #84.