Skip to content

Commit

Permalink
STYLE: Do not do return; directly after throwing an exception
Browse files Browse the repository at this point in the history
Any return statement directly after a `throw` (possibly from a call to
`itkExceptionMacro` or `itkGenericExceptionMacro`) is unreachable, by
definition.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Nov 11, 2021
1 parent ad86850 commit ad64a79
Show file tree
Hide file tree
Showing 37 changed files with 0 additions and 66 deletions.
1 change: 0 additions & 1 deletion Modules/Bridge/VTK/include/itkVTKImageImport.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ VTKImageImport<TOutputImage>::PropagateRequestedRegion(DataObject * outputPtr)
if (!output)
{
itkExceptionMacro(<< "Downcast from DataObject to my Image type failed.");
return;
}
Superclass::PropagateRequestedRegion(output);
if (m_PropagateUpdateExtentCallback)
Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/include/itkByteSwapper.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ ByteSwapper<T>::SwapRangeFromSystemToBigEndian(T * p, BufferSizeType num)
return;
default:
itkGenericExceptionMacro(<< "Cannot swap number of bytes requested");
return;
}
}

Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/include/itkImageDuplicator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ ImageDuplicator<TInputImage>::Update()
if (!m_InputImage)
{
itkExceptionMacro(<< "Input image has not been connected");
return;
}

// Update only if the input image has been modified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ ResourceProbesCollectorBase<TProbe>::Stop(const char * id)
if (pos == this->m_Probes.end())
{
itkGenericExceptionMacro(<< "The probe \"" << id << "\" does not exist. It can not be stopped.");
return;
}
pos->second.Stop();
}
Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/include/itkSmapsFileParser.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ VMMapFileParser<TVMMapDataType>::ReadFile(const std::string & mapFileLocation)
if (inputFile.is_open() == false)
{
itkGenericExceptionMacro(<< "The VMap file " << mapFileLocation << " could not be open");
return;
}
// load the file
inputFile >> this->m_MapData;
Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/include/itkStreamingImageFilter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ StreamingImageFilter<TInputImage, TOutputImage>::UpdateOutputData(DataObject * i
{
itkExceptionMacro(<< "At least " << this->GetNumberOfRequiredInputs() << " inputs are required but only " << ninputs
<< " are specified.");
return;
}

/**
Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/src/itkPlatformMultiThreaderPosix.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ PlatformMultiThreader::MultipleMethodExecute()
if (m_MultipleMethod[thread_loop] == (ThreadFunctionType) nullptr)
{
itkExceptionMacro(<< "No multiple method set for: " << thread_loop);
return;
}
}

Expand Down
1 change: 0 additions & 1 deletion Modules/Core/Common/src/itkPlatformMultiThreaderSingle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ PlatformMultiThreader::MultipleMethodExecute()
if (m_MultipleMethod[thread_loop] == (ThreadFunctionType)0)
{
itkExceptionMacro(<< "No multiple method set for: " << thread_loop);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ PlatformMultiThreader::MultipleMethodExecute()
if (m_MultipleMethod[threadCount] == nullptr)
{
itkExceptionMacro(<< "No multiple method set for: " << threadCount);
return;
}
}
// Using _beginthreadex on a PC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,6 @@ RayCastHelper<TInputImage, TCoordRep>::InitialiseVoxelPointers()
err.SetDescription("The ray traversal direction is unset "
"- InitialiseVoxelPointers().");
throw err;
return;
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions Modules/Core/Mesh/include/itkVTKPolyDataWriter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ VTKPolyDataWriter<TInputMesh>::GenerateData()
if (this->m_FileName.empty())
{
itkExceptionMacro("No FileName");
return;
}

//
Expand All @@ -85,7 +84,6 @@ VTKPolyDataWriter<TInputMesh>::GenerateData()
itkExceptionMacro("Unable to open file\n"
"outputFilename= "
<< this->m_FileName);
return;
}

outputFile.imbue(std::locale::classic());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ SpatialObjectDuplicator<TInputSpatialObject>::Update()
if (!m_Input)
{
itkExceptionMacro(<< "Input SpatialObject has not been connected");
return;
}

// Update only if the input SpatialObject has been modified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ StretchIntensityImageFilter<TInputImage, TOutputImage>::BeforeThreadedGenerateDa
if (m_OutputMinimum > m_OutputMaximum)
{
itkExceptionMacro(<< "Minimum output value cannot be greater than Maximum output value.");
return;
}

const TInputImage * inputImage = this->GetInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@ BSplineTransformInitializer<TTransform, TImage>::InitializeTransform() const
if (!this->m_Transform)
{
itkExceptionMacro(<< "Transform has not been set.");
return;
}
if (!this->m_Image)
{
itkExceptionMacro(<< "Image has not been set.");
return;
}
if (TImage::GetImageDimension() != SpaceDimension)
{
itkExceptionMacro(<< "Image dimensionality does not match the transform.");
return;
}

OriginType transformDomainOrigin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ RescaleIntensityImageFilter<TInputImage, TOutputImage>::BeforeThreadedGenerateDa
if (this->m_OutputMinimum > this->m_OutputMaximum)
{
itkExceptionMacro(<< "Minimum output value cannot be greater than Maximum output value.");
return;
}

using CalculatorType = MinimumMaximumImageCalculator<TInputImage>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ VectorRescaleIntensityImageFilter<TInputImage, TOutputImage>::BeforeThreadedGene
if (m_OutputMaximumMagnitude < NumericTraits<OutputRealType>::ZeroValue())
{
itkExceptionMacro(<< "Maximum output value cannot be negative. You are passing " << m_OutputMaximumMagnitude);
return;
}

InputImagePointer inputImage = this->GetInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ AnchorErodeDilateImageFilter<TImage, TKernel, TFunction1>::DynamicThreadedGenera
if (!this->GetKernel().GetDecomposable())
{
itkExceptionMacro("Anchor morphology only works with decomposable structuring elements");
return;
}
// TFunction1 will be < for erosions
// TFunction2 will be <=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ AnchorOpenCloseImageFilter<TImage, TKernel, TCompare1, TCompare2>::DynamicThread
if (!this->GetKernel().GetDecomposable())
{
itkExceptionMacro("Anchor morphology only works with decomposable structuring elements");
return;
}
// TFunction1 will be < for erosions
// TFunction2 will be <=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ VanHerkGilWermanErodeDilateImageFilter<TImage, TKernel, TFunction1>::DynamicThre
if (!this->GetKernel().GetDecomposable())
{
itkExceptionMacro("VanHerkGilWerman morphology only works with decomposable structuring elements");
return;
}

// TFunction1 will be < for erosions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ RecursiveGaussianImageFilter<TInputImage, TOutputImage>::SetUp(ScalarRealType sp
default:
{
itkExceptionMacro(<< "Unknown Order");
return;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ IntermodesThresholdCalculator<THistogram, TOutput>::GenerateData()
if (smIter > m_MaximumSmoothingIterations)
{
itkGenericExceptionMacro(<< "Exceeded maximum iterations for histogram smoothing.");
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ ThresholdImageFilter<TImage>::ThresholdOutside(const PixelType & lower, const Pi
if (lower > upper)
{
itkExceptionMacro(<< "Lower threshold cannot be greater than upper threshold.");
return;
}

if (Math::NotExactlyEquals(m_Lower, lower) || Math::NotExactlyEquals(m_Upper, upper))
Expand Down
4 changes: 0 additions & 4 deletions Modules/IO/ImageBase/include/itkImageFileReader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformation()
}
ImageFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
throw e;
return;
}

// Got to allocate space for the image. Determine the characteristics of
Expand Down Expand Up @@ -270,7 +269,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>::TestFileExistanceAndReadabili
msg << "The file doesn't exist. " << std::endl << "Filename = " << this->GetFileName() << std::endl;
e.SetDescription(msg.str().c_str());
throw e;
return;
}

// Test if the file can be open for reading access.
Expand All @@ -283,7 +281,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>::TestFileExistanceAndReadabili
msg << "The file couldn't be opened for reading. " << std::endl << "Filename: " << this->GetFileName() << std::endl;
ImageFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
throw e;
return;
}
readTester.close();
}
Expand Down Expand Up @@ -517,7 +514,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>::DoConvertBuffer(void * inputD
e.SetDescription(msg.str().c_str());
e.SetLocation(ITK_LOCATION);
throw e;
return;
}
#undef ITK_CONVERT_BUFFER_IF_BLOCK
}
Expand Down
1 change: 0 additions & 1 deletion Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ ImageSeriesWriter<TInputImage, TOutputImage>::WriteFiles()
{
itkExceptionMacro(<< "The number of filenames passed is " << m_FileNames.size() << " but " << expectedNumberOfFiles
<< " were expected ");
return;
}

itkDebugMacro(<< "Number of files to write = " << m_FileNames.size());
Expand Down
5 changes: 0 additions & 5 deletions Modules/IO/MeshBase/include/itkMeshFileReader.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Te
msg << "The file doesn't exist. " << std::endl << "Filename = " << m_FileName << std::endl;
e.SetDescription(msg.str().c_str());
throw e;
return;
}

// Test if the file can be open for reading access.
Expand All @@ -102,7 +101,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Te
msg << "The file couldn't be opened for reading. " << std::endl << "Filename: " << m_FileName << std::endl;
MeshFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
throw e;
return;
}
readTester.close();
}
Expand Down Expand Up @@ -509,7 +507,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Ge

MeshFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
throw e;
return;
}
}

Expand Down Expand Up @@ -859,7 +856,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Co
e.SetDescription(msg.str().c_str());
e.SetLocation(ITK_LOCATION);
throw e;
return;
}
#undef ITK_CONVERT_POINT_PIXEL_BUFFER_IF_BLOCK
}
Expand Down Expand Up @@ -931,7 +927,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Co
e.SetDescription(msg.str().c_str());
e.SetLocation(ITK_LOCATION);
throw e;
return;
}
#undef ITK_CONVERT_CELL_PIXEL_BUFFER_IF_BLOCK
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
if (normAB2 < 1e-10)
{
itkExceptionMacro("||AB||^2 = " << normAB2 << "\nRisk of division by zero");
return;
}

double E[3];
Expand Down Expand Up @@ -338,19 +337,16 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
if (normAB2 < 1e-10)
{
itkExceptionMacro("normAB2 " << normAB2);
return;
}

if (normBC2 < 1e-10)
{
itkExceptionMacro("normBC2 " << normBC2);
return;
}

if (normCA2 < 1e-10)
{
itkExceptionMacro("normCA2 " << normCA2);
return;
}

normAB = std::sqrt(normAB2);
Expand All @@ -368,19 +364,16 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
if (cosABC <= -1.0 || cosABC >= 1.0)
{
itkExceptionMacro("cosABC= " << cosABC);
return;
}

if (cosBCA <= -1.0 || cosBCA >= 1.0)
{
itkExceptionMacro("cosBCA= " << cosBCA);
return;
}

if (cosCAB <= -1.0 || cosCAB >= 1.0)
{
itkExceptionMacro("cosCAB= " << cosCAB);
return;
}

sinABC = std::sqrt(1.0 - cosABC * cosABC);
Expand All @@ -390,19 +383,16 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
if (sinABC < 1e-10)
{
itkExceptionMacro("sinABC= " << sinABC);
return;
}

if (sinBCA < 1e-10)
{
itkExceptionMacro("sinBCA= " << sinBCA);
return;
}

if (sinCAB < 1e-10)
{
itkExceptionMacro("sinCAB= " << sinCAB);
return;
}

cotgABC = cosABC / sinABC;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>::StartOptimiz
if (this->m_Metric.IsNull())
{
itkExceptionMacro("m_Metric must be set.");
return;
}

/* Estimate the parameter scales if requested. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ BSplineTransformParametersAdaptor<TTransform>::AdaptTransformParameters()
if (!this->m_Transform)
{
itkExceptionMacro("Transform has not been set.");
return;
}

if (this->m_RequiredFixedParameters == this->m_Transform->GetFixedParameters())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,14 @@ CenteredTransformInitializer<TTransform, TFixedImage, TMovingImage>::InitializeT
if (!m_FixedImage)
{
itkExceptionMacro("Fixed Image has not been set");
return;
}
if (!m_MovingImage)
{
itkExceptionMacro("Moving Image has not been set");
return;
}
if (!m_Transform)
{
itkExceptionMacro("Transform has not been set");
return;
}

// If images come from filters, then update those filters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ ConstantVelocityFieldTransformParametersAdaptor<TTransform>::AdaptTransformParam
if (!this->m_Transform)
{
itkExceptionMacro("Transform has not been set.");
return;
}

if (this->m_RequiredFixedParameters == this->m_Transform->GetFixedParameters())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ DisplacementFieldTransformParametersAdaptor<TTransform>::AdaptTransformParameter
if (!this->m_Transform)
{
itkExceptionMacro("Transform has not been set.");
return;
}

if (this->m_RequiredFixedParameters == this->m_Transform->GetFixedParameters())
Expand Down
Loading

0 comments on commit ad64a79

Please sign in to comment.