Skip to content

Commit

Permalink
BUG: Fix uninitialized value ImageRegistrationMethodv4::m_NumberOfLevels
Browse files Browse the repository at this point in the history
Fix uninitialized value warning for
`itk::ImageRegistrationMethodv4::m_NumberOfLevels`.

Fixes:
```
UMC ==16463== Conditional jump or move depends on uninitialised value(s)
==16463==    at 0x9BD983: itk::ImageRegistrationMethodv4, itk::Image, itk::DisplacementFieldTransform, itk::Image, itk::PointSet > >::SetNumberOfLevels(unsigned long) (itkImageRegistrationMethodv4.hxx:881)
==16463==    by 0x9C44B6: itk::ImageRegistrationMethodv4, itk::Image, itk::DisplacementFieldTransform, itk::Image, itk::PointSet > >::ImageRegistrationMethodv4() (itkImageRegistrationMethodv4.hxx:103)
==16463==    by 0x9BBFA0: itk::SyNImageRegistrationMethod, itk::Image, itk::DisplacementFieldTransform, itk::Image, itk::PointSet > >::SyNImageRegistrationMethod() (itkSyNImageRegistrationMethod.hxx:41)
==16463==    by 0x9B5974: itk::SyNImageRegistrationMethod, itk::Image, itk::DisplacementFieldTransform, itk::Image, itk::PointSet > >::New() (itkSyNImageRegistrationMethod.h:84)
==16463==    by 0xA15CD4: itkSyNPointSetRegistrationTest(int, char**) (itkSyNPointSetRegistrationTest.cxx:132)
==16463==    by 0x317927: main (ITKRegistrationMethodsv4TestDriver.cxx:222)
```

and similar warnings triggered by registration testing code.

Visible in:
https://open.cdash.org/viewDynamicAnalysis.php?buildid=8374098

Introduced in d1c46d6.

Recover the comment highlighting the initialization to a 3-level
registration, and reword to make the need for the call (with a value
different from the current value) even more explicit.
  • Loading branch information
jhlegarreta authored and dzenanz committed Jan 10, 2023
1 parent e528a89 commit a31e8bf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -532,7 +532,7 @@ class ITK_TEMPLATE_EXPORT ImageRegistrationMethodv4 : public ProcessObject
SetMetricSamplePoints();

SizeValueType m_CurrentLevel;
SizeValueType m_NumberOfLevels;
SizeValueType m_NumberOfLevels{ 0 };
SizeValueType m_CurrentIteration;
RealType m_CurrentMetricValue;
RealType m_CurrentConvergenceValue;
Expand Down
Expand Up @@ -99,7 +99,7 @@ ImageRegistrationMethodv4<TFixedImage, TMovingImage, TTransform, TVirtualImage,
this->ProcessObject::SetNthOutput(0, transformDecorator);
this->m_OutputTransform = transformDecorator->GetModifiable();

// By default we set up a 3-level image registration.
// Default to a 3-level image registration: force the initialization of the ivars that depend on the number of levels.
this->SetNumberOfLevels(3);

this->m_ShrinkFactorsPerLevel.resize(this->m_NumberOfLevels);
Expand Down

0 comments on commit a31e8bf

Please sign in to comment.