NIFTI-Imaging / nifti_clib

C libraries for NIFTI support
Other
35 stars 25 forks source link

Fixed some cppcheck warnings that were real bugs #160

Closed seanm closed 1 year ago

seanm commented 2 years ago

Fixes:

nifti2/nifti2_io.c:4183:27: warning: Either the condition '!test_ext' is redundant or there is possible null pointer dereference: test_ext. [nullPointerRedundantCheck]
nifti2/nifti2_io.c:4183:37: warning: Either the condition '!known_ext' is redundant or there is possible null pointer dereference: known_ext. [nullPointerRedundantCheck]
nifti2/nifti2_io.c:4187:8: note: Assuming that condition '!test_ext' is not redundant
nifti2/nifti2_io.c:4208:29: warning: Either the condition '!test_ext' is redundant or there is possible null pointer dereference: test_ext. [nullPointerRedundantCheck]
nifti2/nifti2_io.c:4208:39: warning: Either the condition '!known_ext' is redundant or there is possible null pointer dereference: known_ext. [nullPointerRedundantCheck]
nifti2/nifti2_io.c:6296:7: warning: %d in format string (no. 2) requires 'int' but the argument type is 'size_t {aka unsigned long}'. [invalidPrintfArgType_sint]
nifti2/nifti_tool.c:7478:15: warning: Memory leak: hdr [memleak]
nifti2/nifti_tool.c:7491:15: warning: Memory leak: hdr [memleak]
niftilib/nifti1_io.c:3225:27: warning: Either the condition '!test_ext' is redundant or there is possible null pointer dereference: test_ext. [nullPointerRedundantCheck]
niftilib/nifti1_io.c:3225:37: warning: Either the condition '!known_ext' is redundant or there is possible null pointer dereference: known_ext. [nullPointerRedundantCheck]
niftilib/nifti1_io.c:3250:29: warning: Either the condition '!test_ext' is redundant or there is possible null pointer dereference: test_ext. [nullPointerRedundantCheck]
niftilib/nifti1_io.c:3250:39: warning: Either the condition '!known_ext' is redundant or there is possible null pointer dereference: known_ext. [nullPointerRedundantCheck]
niftilib/nifti1_io.c:4532:7: warning: %d in format string (no. 2) requires 'int' but the argument type is 'size_t {aka unsigned long}'. [invalidPrintfArgType_sint]
seanm commented 2 years ago

@hjmjohnson @afni-rickr

seanm commented 1 year ago

@afni-rickr @mrneont @hjmjohnson friendly ping. Care to review?

seanm commented 1 year ago

@afni-rickr @mrneont @hjmjohnson friendly re-ping. :)

seanm commented 1 year ago

@afni-rickr @hjmjohnson ok this PR was clearly too big to review, so I've reduced it to just the fixes that are bugs instead of just suboptimal.

seanm commented 1 year ago

@afni-rickr @hjmjohnson I've just updated this to use old C89 variable declarations. This PR is actually quite small now, so should be quick to review. And unlike the other, these are not stylistic but actual (small) bugs.

seanm commented 1 year ago

@afni-rickr @hjmjohnson friendly re-ping. :)

This PR is actually quite small now, so should be quick to review. And unlike the other, these are not stylistic but actual (small) bugs.