Repository navigation
COMP: Declare the exported functions that no header declares - #90
Open
hjmjohnson wants to merge 6 commits into
Open
hjmjohnson wants to merge 6 commits into
hjmjohnson wants to merge 6 commits into
Conversation
hjmjohnson
marked this pull request as ready for review
September 24, 2026 12:03
hjmjohnson
force-pushed
the
pr/fix-missing-prototypes
branch
from
October 6, 2026 14:39
9fc0c69 to
b58fbc6
Compare
This was referenced Nov 3, 2026
hjmjohnson
force-pushed
the
pr/fix-missing-prototypes
branch
from
November 6, 2026 15:11
b58fbc6 to
36416fd
Compare
Member
Author
hjmjohnson
force-pushed
the
pr/fix-missing-prototypes
branch
from
November 6, 2026 15:22
36416fd to
b612547
Compare
Member
Author
|
@greptileai review |
seanm
requested changes
Nov 8, 2026
hjmjohnson
force-pushed
the
pr/fix-missing-prototypes
branch
2 times, most recently
from
November 9, 2026 18:35
026c6cb to
d61944c
Compare
Member
Author
|
Two force-pushes: |
gdevenyi
requested changes
Nov 12, 2026
gdevenyi
left a comment
Collaborator
There was a problem hiding this comment.
Review by Google Carbon
Verdict: Request Changes
Verified that this PR reduces both -Wmissing-prototypes (Clang & GCC) and -Wmissing-declarations (GCC) from 18 warnings to 0 across all library and test configurations (FSLSTYLE=OFF/ON). Making the 7 uncalled internal fslio.c helpers and doPigz/doPigz2 static (and deleting NIFTI-1's duplicate dead doPigz2) is clean and well-reasoned.
However, one newly published header declaration exposes a broken infinite-recursion function:
- [BLOCKER]
axml_recur_find_xml(cifti/afni_xml.h:91-92/cifti/afni_xml.c:556-578): Addingaxml_recur_find_xmlto the installed headercifti/afni_xml.hturns an uncalled function into public API, but its implementation incifti/afni_xml.c:573passesaxinstead ofax->xchild[ind]to the recursive call:It never visits any child node, and wheneverrx = axml_recur_find_xml(func, ax, depth+1, max_depth);
max_depth <= 0("unlimited depth", per line 567) andax->nchild > 0, calling it causes unbounded recursion and an immediate stack overflow! Please either fixax->ax->xchild[ind]incifti/afni_xml.c:573(with a small unit test) if publishing it intentionally, or keep it out ofafni_xml.h/ remove the dead function if ABI baseline policy permits (note also#93annotates itCIF_API).
FslGetHdrImgNames and FslSetIntensityScaling are defined here but declared nowhere, while FslGetIntensityScaling and FslInit are already published. axml_recur_find_xml sits beside axml_recur in afni_xml.h the same way. The upstream fslio was deleted in 2015 in favor of a C++ replacement, so this copy is the surviving one and its header is ours to correct. Additive; no symbol changes.
The depth-first search passed the current node, not its child, to the recursive call, so it never visited a child. With max_depth <= 0 and any child present it recursed without bound and overflowed the stack; with a depth limit it returned NULL for any match below the root. The new test builds a three-level tree and checks limited, unlimited, and leaf searches. Without the fix it aborts under ASan with a stack overflow.
Nine functions in fslio.c have external linkage and no declaration in any header. Nothing in the tree calls them across a translation unit, AFNI's vendored copy never calls them, and no public source outside a vendored copy of this file references them, so a caller would have had to declare them itself. Seven of them are used within fslio.c and become static, with their prototypes collected in one block so the boundary between internal and published is visible in one place. FslSetVoxUnits and FslGetVoxUnits have no caller at all and are deleted. Removes nine exported symbols from libfslio.
nifti1_io.c and nifti2_io.c each define nifti_fileexists with external linkage, so libniftiio and libnifti2 export the same name and ELF link order decides which one a caller linking both resolves to. Declaring it locally silences the warning without choosing between publishing it and making it static; that choice needs the duplication settled first, and it covers a hundred names, not this one. The duplicate definition is left for a later change, because removing either copy or making it static alters the exported API.
Keeps FslGetAuxFile and FslSetAuxFile deriving the same length so the pair cannot drift if the field width changes. sizeof is 24, so the copy still writes at most 23 bytes.
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 NIFTI-1 library also carried a doPigz2, taking a nifti_1_header despite its name, byte-identical to doPigz beside it and called from nowhere. It is removed. The exported symbol set of the default build is unchanged: this code compiles only under PIGZ, which FSLSTYLE enables.
hjmjohnson
force-pushed
the
pr/fix-missing-prototypes
branch
from
November 17, 2026 22:33
d61944c to
5c2f709
Compare
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.
COMP: Declare the exported functions that no header declares
Clears every
-Wmissing-declarationswarning withUSE_FSL_CODE=ON,USE_CIFTI_CODE=ON, and the apps on, for bothFSLSTYLE=OFFandON, sothe CI job proposed in #92 can make that flag an error.
ABI note: seven fsliolib functions become
staticand two uncalled ones(
FslSetVoxUnits,FslGetVoxUnits) are deleted, so libfslio exports ninefewer symbols. Under
FSLSTYLE=ON, libniftiio and libnifti2 also stopexporting
doPigzanddoPigz2. None is declared in any header, but thisbelongs in the next minor tag's release notes.
Base:
master. Independent of the rest of the re-submitted stack.Commits
(
FslGetHdrImgNames,FslSetIntensityScaling,axml_recur_find_xml).current node instead of the child, so it never searched below the root
and overflowed the stack with no depth limit; adds a ctest.
static, two deleted).prototype in
nifti1_io.candnifti2_io.c; both libraries still defineand export it, and deduplicating it is left for a later change because it
alters the exported API.
doPigz,doPigz2; onlycompiled under
FSLSTYLE=ON, which enables PIGZ). The NIFTI-1 copy ofdoPigz2, uncalled and identical todoPigz, is deleted.Verification
Built with Homebrew gcc-16,
-DCMAKE_C_FLAGS=-Wmissing-declarations,USE_FSL_CODE=ON,USE_CIFTI_CODE=ON,NIFTI_BUILD_APPLICATIONS=ON,NIFTI_BUILD_TESTING=ON, Release, atd61944c:Before the pigz commit,
FSLSTYLE=ONreported four warnings (doPigzanddoPigz2in each ofnifti1_io.candnifti2_io.c).