BUG: Give the statement macros a do/while(0) body and drop the stray semicolons - #120
Open
hjmjohnson wants to merge 2 commits into
Open
hjmjohnson wants to merge 2 commits into
hjmjohnson wants to merge 2 commits into
Conversation
A macro whose body is a bare { ... } block cannot be used as a
statement:
if( cond )
FSLIOERR(...); /* the ; ends the if, the block runs */
else /* ...and this is a syntax error */
No current call site is written that way -- FSLIOERR has no `else`
after it anywhere, and none of the nifti_*_test macros appears in an
if or else arm -- so the change is prophylactic and nothing observable
moves. The next person to write one, though, gets a syntax error a
long way from the cause. clang reports the call sites as
-Wextra-semi-stmt, because the trailing semicolon at each is an empty
statement.
Wrapped: FSLIOERR in fslio.c and the seven nifti_*_test macros in
nifti_tester001.c. The NT_FILL and NT_MAT* families in the tool
headers already have do/while bodies.
Two genuine empty statements go too: a doubled semicolon inside
unescape_string() in both io files, and a stray semicolon after the
closing brace of an if block in FslClose().
FSLIOERR is worth calling out: it expands to fprintf plus
exit(EXIT_FAILURE), and of its roughly fifty call sites several are
the whole body of a braceless if. Those are correct today only
because the macro always exits.
(cherry picked from commit 4ac84e5)
The backslashes sat at four different columns within a single macro, one of them past 80. Each macro is now aligned to its own width, one space past its longest line, so a block stays as narrow as its content allows rather than being widened by one long line. Only the seven macros the preceding commit gives a do/while(0) body are touched. (cherry picked from commit 3f14c7e)
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 #49, reverted from
masteron 2026-09-24 so it can bereviewed before merging. Content is unchanged from the original.
Base:
clang-tidy-fixes, notmaster. It edits the same lines as thatchange, so merge that one first.
Commits
Ordering for all the re-submitted work is tracked in #84.