Skip to content

Commit ad64a79

Browse files
N-Dekkerhjmjohnson
authored andcommitted
STYLE: Do not do return; directly after throwing an exception
Any return statement directly after a `throw` (possibly from a call to `itkExceptionMacro` or `itkGenericExceptionMacro`) is unreachable, by definition.
1 parent ad86850 commit ad64a79

File tree

37 files changed

+0
-66
lines changed

37 files changed

+0
-66
lines changed

Modules/Bridge/VTK/include/itkVTKImageImport.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ VTKImageImport<TOutputImage>::PropagateRequestedRegion(DataObject * outputPtr)
125125
if (!output)
126126
{
127127
itkExceptionMacro(<< "Downcast from DataObject to my Image type failed.");
128-
return;
129128
}
130129
Superclass::PropagateRequestedRegion(output);
131130
if (m_PropagateUpdateExtentCallback)

Modules/Core/Common/include/itkByteSwapper.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ ByteSwapper<T>::SwapRangeFromSystemToBigEndian(T * p, BufferSizeType num)
129129
return;
130130
default:
131131
itkGenericExceptionMacro(<< "Cannot swap number of bytes requested");
132-
return;
133132
}
134133
}
135134

Modules/Core/Common/include/itkImageDuplicator.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ ImageDuplicator<TInputImage>::Update()
4040
if (!m_InputImage)
4141
{
4242
itkExceptionMacro(<< "Input image has not been connected");
43-
return;
4443
}
4544

4645
// Update only if the input image has been modified

Modules/Core/Common/include/itkResourceProbesCollectorBase.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ ResourceProbesCollectorBase<TProbe>::Stop(const char * id)
4444
if (pos == this->m_Probes.end())
4545
{
4646
itkGenericExceptionMacro(<< "The probe \"" << id << "\" does not exist. It can not be stopped.");
47-
return;
4847
}
4948
pos->second.Stop();
5049
}

Modules/Core/Common/include/itkSmapsFileParser.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ VMMapFileParser<TVMMapDataType>::ReadFile(const std::string & mapFileLocation)
149149
if (inputFile.is_open() == false)
150150
{
151151
itkGenericExceptionMacro(<< "The VMap file " << mapFileLocation << " could not be open");
152-
return;
153152
}
154153
// load the file
155154
inputFile >> this->m_MapData;

Modules/Core/Common/include/itkStreamingImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ StreamingImageFilter<TInputImage, TOutputImage>::UpdateOutputData(DataObject * i
120120
{
121121
itkExceptionMacro(<< "At least " << this->GetNumberOfRequiredInputs() << " inputs are required but only " << ninputs
122122
<< " are specified.");
123-
return;
124123
}
125124

126125
/**

Modules/Core/Common/src/itkPlatformMultiThreaderPosix.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ PlatformMultiThreader::MultipleMethodExecute()
6060
if (m_MultipleMethod[thread_loop] == (ThreadFunctionType) nullptr)
6161
{
6262
itkExceptionMacro(<< "No multiple method set for: " << thread_loop);
63-
return;
6463
}
6564
}
6665

Modules/Core/Common/src/itkPlatformMultiThreaderSingle.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ PlatformMultiThreader::MultipleMethodExecute()
4949
if (m_MultipleMethod[thread_loop] == (ThreadFunctionType)0)
5050
{
5151
itkExceptionMacro(<< "No multiple method set for: " << thread_loop);
52-
return;
5352
}
5453
}
5554

Modules/Core/Common/src/itkPlatformMultiThreaderWindows.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ PlatformMultiThreader::MultipleMethodExecute()
5454
if (m_MultipleMethod[threadCount] == nullptr)
5555
{
5656
itkExceptionMacro(<< "No multiple method set for: " << threadCount);
57-
return;
5857
}
5958
}
6059
// Using _beginthreadex on a PC

Modules/Core/ImageFunction/include/itkRayCastInterpolateImageFunction.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,6 @@ RayCastHelper<TInputImage, TCoordRep>::InitialiseVoxelPointers()
11971197
err.SetDescription("The ray traversal direction is unset "
11981198
"- InitialiseVoxelPointers().");
11991199
throw err;
1200-
return;
12011200
}
12021201
}
12031202
}

Modules/Core/Mesh/include/itkVTKPolyDataWriter.hxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ VTKPolyDataWriter<TInputMesh>::GenerateData()
7272
if (this->m_FileName.empty())
7373
{
7474
itkExceptionMacro("No FileName");
75-
return;
7675
}
7776

7877
//
@@ -85,7 +84,6 @@ VTKPolyDataWriter<TInputMesh>::GenerateData()
8584
itkExceptionMacro("Unable to open file\n"
8685
"outputFilename= "
8786
<< this->m_FileName);
88-
return;
8987
}
9088

9189
outputFile.imbue(std::locale::classic());

Modules/Core/SpatialObjects/include/itkSpatialObjectDuplicator.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ SpatialObjectDuplicator<TInputSpatialObject>::Update()
5959
if (!m_Input)
6060
{
6161
itkExceptionMacro(<< "Input SpatialObject has not been connected");
62-
return;
6362
}
6463

6564
// Update only if the input SpatialObject has been modified

Modules/Core/TestKernel/include/itkTestingStretchIntensityImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ StretchIntensityImageFilter<TInputImage, TOutputImage>::BeforeThreadedGenerateDa
6060
if (m_OutputMinimum > m_OutputMaximum)
6161
{
6262
itkExceptionMacro(<< "Minimum output value cannot be greater than Maximum output value.");
63-
return;
6463
}
6564

6665
const TInputImage * inputImage = this->GetInput();

Modules/Core/Transform/include/itkBSplineTransformInitializer.hxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,14 @@ BSplineTransformInitializer<TTransform, TImage>::InitializeTransform() const
4747
if (!this->m_Transform)
4848
{
4949
itkExceptionMacro(<< "Transform has not been set.");
50-
return;
5150
}
5251
if (!this->m_Image)
5352
{
5453
itkExceptionMacro(<< "Image has not been set.");
55-
return;
5654
}
5755
if (TImage::GetImageDimension() != SpaceDimension)
5856
{
5957
itkExceptionMacro(<< "Image dimensionality does not match the transform.");
60-
return;
6158
}
6259

6360
OriginType transformDomainOrigin;

Modules/Filtering/ImageIntensity/include/itkRescaleIntensityImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ RescaleIntensityImageFilter<TInputImage, TOutputImage>::BeforeThreadedGenerateDa
5252
if (this->m_OutputMinimum > this->m_OutputMaximum)
5353
{
5454
itkExceptionMacro(<< "Minimum output value cannot be greater than Maximum output value.");
55-
return;
5655
}
5756

5857
using CalculatorType = MinimumMaximumImageCalculator<TInputImage>;

Modules/Filtering/ImageIntensity/include/itkVectorRescaleIntensityImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ VectorRescaleIntensityImageFilter<TInputImage, TOutputImage>::BeforeThreadedGene
4949
if (m_OutputMaximumMagnitude < NumericTraits<OutputRealType>::ZeroValue())
5050
{
5151
itkExceptionMacro(<< "Maximum output value cannot be negative. You are passing " << m_OutputMaximumMagnitude);
52-
return;
5352
}
5453

5554
InputImagePointer inputImage = this->GetInput();

Modules/Filtering/MathematicalMorphology/include/itkAnchorErodeDilateImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ AnchorErodeDilateImageFilter<TImage, TKernel, TFunction1>::DynamicThreadedGenera
4040
if (!this->GetKernel().GetDecomposable())
4141
{
4242
itkExceptionMacro("Anchor morphology only works with decomposable structuring elements");
43-
return;
4443
}
4544
// TFunction1 will be < for erosions
4645
// TFunction2 will be <=

Modules/Filtering/MathematicalMorphology/include/itkAnchorOpenCloseImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ AnchorOpenCloseImageFilter<TImage, TKernel, TCompare1, TCompare2>::DynamicThread
4242
if (!this->GetKernel().GetDecomposable())
4343
{
4444
itkExceptionMacro("Anchor morphology only works with decomposable structuring elements");
45-
return;
4645
}
4746
// TFunction1 will be < for erosions
4847
// TFunction2 will be <=

Modules/Filtering/MathematicalMorphology/include/itkVanHerkGilWermanErodeDilateImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ VanHerkGilWermanErodeDilateImageFilter<TImage, TKernel, TFunction1>::DynamicThre
4242
if (!this->GetKernel().GetDecomposable())
4343
{
4444
itkExceptionMacro("VanHerkGilWerman morphology only works with decomposable structuring elements");
45-
return;
4645
}
4746

4847
// TFunction1 will be < for erosions

Modules/Filtering/Smoothing/include/itkRecursiveGaussianImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ RecursiveGaussianImageFilter<TInputImage, TOutputImage>::SetUp(ScalarRealType sp
202202
default:
203203
{
204204
itkExceptionMacro(<< "Unknown Order");
205-
return;
206205
}
207206
}
208207
}

Modules/Filtering/Thresholding/include/itkIntermodesThresholdCalculator.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ IntermodesThresholdCalculator<THistogram, TOutput>::GenerateData()
9595
if (smIter > m_MaximumSmoothingIterations)
9696
{
9797
itkGenericExceptionMacro(<< "Exceeded maximum iterations for histogram smoothing.");
98-
return;
9998
}
10099
}
101100

Modules/Filtering/Thresholding/include/itkThresholdImageFilter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ ThresholdImageFilter<TImage>::ThresholdOutside(const PixelType & lower, const Pi
8181
if (lower > upper)
8282
{
8383
itkExceptionMacro(<< "Lower threshold cannot be greater than upper threshold.");
84-
return;
8584
}
8685

8786
if (Math::NotExactlyEquals(m_Lower, lower) || Math::NotExactlyEquals(m_Upper, upper))

Modules/IO/ImageBase/include/itkImageFileReader.hxx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformation()
132132
}
133133
ImageFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
134134
throw e;
135-
return;
136135
}
137136

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

276274
// Test if the file can be open for reading access.
@@ -283,7 +281,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>::TestFileExistanceAndReadabili
283281
msg << "The file couldn't be opened for reading. " << std::endl << "Filename: " << this->GetFileName() << std::endl;
284282
ImageFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
285283
throw e;
286-
return;
287284
}
288285
readTester.close();
289286
}
@@ -517,7 +514,6 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>::DoConvertBuffer(void * inputD
517514
e.SetDescription(msg.str().c_str());
518515
e.SetLocation(ITK_LOCATION);
519516
throw e;
520-
return;
521517
}
522518
#undef ITK_CONVERT_BUFFER_IF_BLOCK
523519
}

Modules/IO/ImageBase/include/itkImageSeriesWriter.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ ImageSeriesWriter<TInputImage, TOutputImage>::WriteFiles()
244244
{
245245
itkExceptionMacro(<< "The number of filenames passed is " << m_FileNames.size() << " but " << expectedNumberOfFiles
246246
<< " were expected ");
247-
return;
248247
}
249248

250249
itkDebugMacro(<< "Number of files to write = " << m_FileNames.size());

Modules/IO/MeshBase/include/itkMeshFileReader.hxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Te
8989
msg << "The file doesn't exist. " << std::endl << "Filename = " << m_FileName << std::endl;
9090
e.SetDescription(msg.str().c_str());
9191
throw e;
92-
return;
9392
}
9493

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

510508
MeshFileReaderException e(__FILE__, __LINE__, msg.str().c_str(), ITK_LOCATION);
511509
throw e;
512-
return;
513510
}
514511
}
515512

@@ -859,7 +856,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Co
859856
e.SetDescription(msg.str().c_str());
860857
e.SetLocation(ITK_LOCATION);
861858
throw e;
862-
return;
863859
}
864860
#undef ITK_CONVERT_POINT_PIXEL_BUFFER_IF_BLOCK
865861
}
@@ -931,7 +927,6 @@ MeshFileReader<TOutputMesh, ConvertPointPixelTraits, ConvertCellPixelTraits>::Co
931927
e.SetDescription(msg.str().c_str());
932928
e.SetLocation(ITK_LOCATION);
933929
throw e;
934-
return;
935930
}
936931
#undef ITK_CONVERT_CELL_PIXEL_BUFFER_IF_BLOCK
937932
}

Modules/Nonunit/Review/include/itkConformalFlatteningMeshFilter.hxx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
210210
if (normAB2 < 1e-10)
211211
{
212212
itkExceptionMacro("||AB||^2 = " << normAB2 << "\nRisk of division by zero");
213-
return;
214213
}
215214

216215
double E[3];
@@ -338,19 +337,16 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
338337
if (normAB2 < 1e-10)
339338
{
340339
itkExceptionMacro("normAB2 " << normAB2);
341-
return;
342340
}
343341

344342
if (normBC2 < 1e-10)
345343
{
346344
itkExceptionMacro("normBC2 " << normBC2);
347-
return;
348345
}
349346

350347
if (normCA2 < 1e-10)
351348
{
352349
itkExceptionMacro("normCA2 " << normCA2);
353-
return;
354350
}
355351

356352
normAB = std::sqrt(normAB2);
@@ -368,19 +364,16 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
368364
if (cosABC <= -1.0 || cosABC >= 1.0)
369365
{
370366
itkExceptionMacro("cosABC= " << cosABC);
371-
return;
372367
}
373368

374369
if (cosBCA <= -1.0 || cosBCA >= 1.0)
375370
{
376371
itkExceptionMacro("cosBCA= " << cosBCA);
377-
return;
378372
}
379373

380374
if (cosCAB <= -1.0 || cosCAB >= 1.0)
381375
{
382376
itkExceptionMacro("cosCAB= " << cosCAB);
383-
return;
384377
}
385378

386379
sinABC = std::sqrt(1.0 - cosABC * cosABC);
@@ -390,19 +383,16 @@ ConformalFlatteningMeshFilter<TInputMesh, TOutputMesh>::GenerateData()
390383
if (sinABC < 1e-10)
391384
{
392385
itkExceptionMacro("sinABC= " << sinABC);
393-
return;
394386
}
395387

396388
if (sinBCA < 1e-10)
397389
{
398390
itkExceptionMacro("sinBCA= " << sinBCA);
399-
return;
400391
}
401392

402393
if (sinCAB < 1e-10)
403394
{
404395
itkExceptionMacro("sinCAB= " << sinCAB);
405-
return;
406396
}
407397

408398
cotgABC = cosABC / sinABC;

Modules/Numerics/Optimizersv4/src/itkObjectToObjectOptimizerBase.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ ObjectToObjectOptimizerBaseTemplate<TInternalComputationValueType>::StartOptimiz
110110
if (this->m_Metric.IsNull())
111111
{
112112
itkExceptionMacro("m_Metric must be set.");
113-
return;
114113
}
115114

116115
/* Estimate the parameter scales if requested. */

Modules/Registration/Common/include/itkBSplineTransformParametersAdaptor.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ BSplineTransformParametersAdaptor<TTransform>::AdaptTransformParameters()
203203
if (!this->m_Transform)
204204
{
205205
itkExceptionMacro("Transform has not been set.");
206-
return;
207206
}
208207

209208
if (this->m_RequiredFixedParameters == this->m_Transform->GetFixedParameters())

Modules/Registration/Common/include/itkCenteredTransformInitializer.hxx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,14 @@ CenteredTransformInitializer<TTransform, TFixedImage, TMovingImage>::InitializeT
3030
if (!m_FixedImage)
3131
{
3232
itkExceptionMacro("Fixed Image has not been set");
33-
return;
3433
}
3534
if (!m_MovingImage)
3635
{
3736
itkExceptionMacro("Moving Image has not been set");
38-
return;
3937
}
4038
if (!m_Transform)
4139
{
4240
itkExceptionMacro("Transform has not been set");
43-
return;
4441
}
4542

4643
// If images come from filters, then update those filters.

Modules/Registration/Common/include/itkConstantVelocityFieldTransformParametersAdaptor.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ ConstantVelocityFieldTransformParametersAdaptor<TTransform>::AdaptTransformParam
185185
if (!this->m_Transform)
186186
{
187187
itkExceptionMacro("Transform has not been set.");
188-
return;
189188
}
190189

191190
if (this->m_RequiredFixedParameters == this->m_Transform->GetFixedParameters())

Modules/Registration/Common/include/itkDisplacementFieldTransformParametersAdaptor.hxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ DisplacementFieldTransformParametersAdaptor<TTransform>::AdaptTransformParameter
181181
if (!this->m_Transform)
182182
{
183183
itkExceptionMacro("Transform has not been set.");
184-
return;
185184
}
186185

187186
if (this->m_RequiredFixedParameters == this->m_Transform->GetFixedParameters())

0 commit comments

Comments
 (0)