Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STYLE: Add missing braces to the substatements of if statements #3875

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Modules/Core/Common/include/itkMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,13 @@ struct AlmostEqualsSignedVsUnsigned
AlmostEqualsFunction(TSignedInt signedVariable, TUnsignedInt unsignedVariable)
{
if (signedVariable < 0)
{
return false;
}
if (unsignedVariable > static_cast<size_t>(itk::NumericTraits<TSignedInt>::max()))
{
return false;
}
return signedVariable == static_cast<TSignedInt>(unsignedVariable);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ printnb(const TIteratorType & nb, bool full)
{
std::cout << **it << " ";
if ((count % sz) == 0)
{
std::cout << std::endl;
}
++it;
++count;
}
Expand Down Expand Up @@ -82,7 +84,9 @@ FillImage(itk::Image<itk::Index<VDimension>, VDimension> * img)
loop[i] = 0;
}
else
{
break;
}
}
++it;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ itk_feenableexcept(const fexcept_t excepts)

static fenv_t fenv;
if (fegetenv(&fenv))
{
return static_cast<fexcept_t>(-1);
}

// all previous masks
const fexcept_t old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
Expand All @@ -74,7 +76,9 @@ itk_fedisableexcept(const fexcept_t excepts)

static fenv_t fenv;
if (fegetenv(&fenv))
{
return static_cast<fexcept_t>(-1);
}

// previous masks
const fexcept_t old_excepts = (fenv & FM_ALL_EXCEPT) << FE_EXCEPT_SHIFT;
Expand Down Expand Up @@ -109,7 +113,9 @@ itk_feenableexcept(const fexcept_t excepts)

static fenv_t fenv;
if (fegetenv(&fenv))
{
return static_cast<fexcept_t>(-1);
}

// previous masks
const fexcept_t old_excepts = fenv._itk_control_word & FE_ALL_EXCEPT;
Expand All @@ -128,7 +134,9 @@ itk_fedisableexcept(const fexcept_t excepts)

static fenv_t fenv;
if (fegetenv(&fenv))
{
return static_cast<fexcept_t>(-1);
}

// all previous masks
fexcept_t old_excepts = fenv._itk_control_word & FE_ALL_EXCEPT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ itkEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[])
testPosition[2] = z;
functionValue = spatialFunc->Evaluate(testPosition);
if (functionValue == 1)
{
interiorPixelCounter++;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ itkFiniteCylinderSpatialFunctionTest(int, char *[])
testPosition[2] = z;
functionValue = spatialFunc->Evaluate(testPosition);
if (functionValue == 1)
{
interiorPixelCounter++;
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkFixedArrayTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ itkFixedArrayTest2(int, char *[])

const bool sameptr = (vec == vec2);
if (sameptr)
{
std::cout << "Same pointers: true" << std::endl;
}
else
{
std::cout << "Same pointers: false" << std::endl;
}

std::cout << "Performance ratio = " << ratio << "%" << std::endl;

Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkHashTableTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ itkHashTableTest(int, char *[])
// CppCheck gives us a warning if the return value isn't used.
// This is to prevent the user from calling empty() when they mean clear().
if (Set.empty())
{
std::cout << "Set is empty." << std::endl;
}
Set.rehash(50);
Set.insert("the horror");
auto hsh_it = Set.begin();
Expand Down Expand Up @@ -116,7 +118,9 @@ itkHashTableTest(int, char *[])
// CppCheck gives us a warning if the return value isn't used.
// This is to prevent the user from calling empty() when they mean clear().
if (months.empty())
{
std::cout << "Set is empty." << std::endl;
}
months.rehash(50);
HashMapType::value_type p("psychotic break", 2);
months.insert(p);
Expand Down
2 changes: 2 additions & 0 deletions Modules/Core/Common/test/itkImageAlgorithmCopyTest2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ CheckBuffer(const TImageType * image, typename TImageType::PixelType p)
while (!iter.IsAtEnd())
{
if (itk::Math::NotExactlyEquals(iter.Get(), p))
{
return false;
}
++iter;
}
return true;
Expand Down
8 changes: 8 additions & 0 deletions Modules/Core/Common/test/itkImageRegionTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,23 @@ itkImageRegionTest(int, char *[])

indexC.Fill(13);
if (regionA.IsInside(indexC))
{
std::cout << "13,13,13 IsInside" << std::endl;
}
else
{
std::cout << "13,13,13 is not inside !" << std::endl;
}

indexC[0] = ContinuousIndexNumericTraits::quiet_NaN();
if (regionA.IsInside(indexC))
{
std::cout << "** NaN,13,13 *is* inside. **" << std::endl;
}
else
{
std::cout << "NaN,13,13 is not inside" << std::endl;
}

std::cout << "NaN < -1 = " << (indexC[0] < -1.0) << std::endl;
std::cout << "NaN > -1 = " << (indexC[0] > -1.0) << std::endl;
Expand Down
12 changes: 12 additions & 0 deletions Modules/Core/Common/test/itkIntTypesTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ CheckTraits(bool issigned, T * = nullptr)

// make sure the numeric_limits is specialized
if (!itk::NumericTraits<T>::is_specialized)
{
return false;
}

if (itk::NumericTraits<T>::is_signed != issigned)
{
return false;
}

return true;
}
Expand All @@ -69,14 +73,20 @@ CheckType(size_t size, bool exactSize, bool issigned, const char * name, T * = n
bool ret = true;

if (exactSize)
{
ret &= CheckSize<T>(size);
}
else
{
ret &= CheckAtleastSize<T>(size);
}

ret &= CheckTraits<T>(issigned);

if (ret)
{
return ret;
}

std::cout << "error with type \"" << name << "\" sizeof: " << sizeof(T)
<< " specialized: " << itk::NumericTraits<T>::is_specialized << " digits: " << itk::NumericTraits<T>::digits
Expand Down Expand Up @@ -140,7 +150,9 @@ itkIntTypesTest(int, char *[])


if (pass)
{
return EXIT_SUCCESS;
}

return EXIT_FAILURE;
}
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkMathCastWithRangeCheckTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ itkMathCastWithRangeCheckTest(int, char *[])
#endif

if (pass)
{
return EXIT_SUCCESS;
}
else
{
return EXIT_FAILURE;
}
}
2 changes: 2 additions & 0 deletions Modules/Core/Common/test/itkMatrixTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,9 @@ itkMatrixTest(int, char *[])
for (unsigned int j = 0; j < 3; ++j)
{
if (itk::Math::isnan(invertedMatrix[i][j]))
{
++num_nans;
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions Modules/Core/Common/test/itkNeighborhoodAlgorithmTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ ImageBoundaryFaceCalculatorTest(TImage * image,
}

if (faceList.empty())
{
return true;
}

image->FillBuffer(0);
for (auto fit = faceList.begin(); fit != faceList.end(); ++fit)
Expand Down Expand Up @@ -112,7 +114,9 @@ NeighborhoodAlgorithmTest()

// test 1: requestToProcessRegion match the bufferedRegion
if (!ImageBoundaryFaceCalculatorTest(image.GetPointer(), region, radius))
{
return false;
}

ind.Fill(1);
size.Fill(4);
Expand All @@ -121,7 +125,9 @@ NeighborhoodAlgorithmTest()

// test 2: requestToProcessRegion is part of bufferedRegion
if (!ImageBoundaryFaceCalculatorTest(image.GetPointer(), region, radius))
{
return false;
}

ind.Fill(0);
region.SetIndex(ind);
Expand All @@ -138,7 +144,9 @@ NeighborhoodAlgorithmTest()

// test 3: requestToProcessRegion match the bufferedRegion, but all the bufferedRegion is inside the boundary
if (!ImageBoundaryFaceCalculatorTest(image.GetPointer(), region, radius))
{
return false;
}

size.Fill(5);
region.SetSize(size);
Expand All @@ -153,7 +161,9 @@ NeighborhoodAlgorithmTest()

// test 4: bufferedRegion is part of the requestToProcessRegion
if (!ImageBoundaryFaceCalculatorTest(image.GetPointer(), region, radius))
{
return false;
}

ind.Fill(0);
size.Fill(10);
Expand All @@ -170,7 +180,9 @@ NeighborhoodAlgorithmTest()
region.SetSize(size);
// test 5: requestToProcessRegion is part of boundary of bufferedRegion
if (!ImageBoundaryFaceCalculatorTest(image.GetPointer(), region, radius))
{
return false;
}

if (VDimension == 2)
{
Expand All @@ -191,7 +203,9 @@ NeighborhoodAlgorithmTest()
radius.Fill(4);
// test 6: test condition encountered by BoxMeanImageFilterTest with 24 threads
if (!ImageBoundaryFaceCalculatorTest(image.GetPointer(), region, radius))
{
return false;
}
}


Expand All @@ -202,16 +216,24 @@ int
itkNeighborhoodAlgorithmTest(int, char *[])
{
if (!NeighborhoodAlgorithmTest<int, 1>())
{
return EXIT_FAILURE;
}

if (!NeighborhoodAlgorithmTest<int, 2>())
{
return EXIT_FAILURE;
}

if (!NeighborhoodAlgorithmTest<int, 3>())
{
return EXIT_FAILURE;
}

if (!NeighborhoodAlgorithmTest<int, 4>())
{
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
2 changes: 2 additions & 0 deletions Modules/Core/Common/test/itkNumericsTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ solve_with_warning(vnl_matrix<V> const & M, vnl_matrix<V> const & B)
vnl_svd<V> svd(M, 1e-8);
// Check for rank-deficiency
if (svd.singularities() > 1)
{
std::cout << "Warning: Singular matrix, condition = " << svd.well_condition() << std::endl;
}
return svd.solve(B);
}

Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkOctreeTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ itkOctreeTest(int, char *[])
{
unsigned int val = rand() % 16384;
if (counter && counter % 8 == 0)
{
std::cerr << val << std::endl;
}
else
{
std::cerr << val << " ";
}
counter++;
ri.Set(val);
++ri;
Expand Down
6 changes: 6 additions & 0 deletions Modules/Core/Common/test/itkSparseFieldLayerTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ itkSparseFieldLayerTest(int, char *[])
while (cit != layer->End())
{
if (cit->value != i || cit->value != i)
{
return EXIT_FAILURE;
}
++cit;
--i;
}
Expand All @@ -78,10 +80,14 @@ itkSparseFieldLayerTest(int, char *[])
while (it != layer->End())
{
if (it->value != i || it->value != i)
{
return EXIT_FAILURE;
}
it->value = 32567;
if (it->value != 32567 || it->value != 32567)
{
return EXIT_FAILURE;
}
++it;
--i;
}
Expand Down
4 changes: 4 additions & 0 deletions Modules/Core/Common/test/itkSpatialFunctionTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ itkSpatialFunctionTest(int, char *[])
// The function should have returned a value of 1, since the center is inside
// the sphere
if (funcVal == 1)
{
return EXIT_SUCCESS;
}
else
{
return EXIT_FAILURE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[])
testPosition[2] = z;
functionValue = spatialFunc->Evaluate(testPosition);
if (functionValue == 1)
{
interiorPixelCounter++;
}
}
}
}
Expand Down