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: Prefer c++17 [[maybe_unused]] attribute over (void) #4581

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Modules/Core/Common/CMake/itkCheckHasFenvtStructMember.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
int
main()
{
fenv_t fenv;
[[maybe_unused]] fenv_t fenv;
#if defined(ITK_CHECK_FENV_T_CONTROL)
(void)sizeof(fenv.__control);
[[maybe_unused]] const auto tempSize = sizeof(fenv.__control);
hjmjohnson marked this conversation as resolved.
Show resolved Hide resolved
#elif defined(ITK_CHECK_FENV_T_CONTROL_WORD)
(void)sizeof(fenv.__control_word);
[[maybe_unused]] const auto tempSize = sizeof(fenv.__control_word);
#elif defined(ITK_CHECK_FENV_T_CW)
(void)sizeof(fenv.__cw);
[[maybe_unused]] const auto tempSize = sizeof(fenv.__cw);
#else
(void)fenv;
# error \
"Unknown fenv_t struct member test: Make sure to specify a compile definition of the form -DITK_CHECK_FENV_T_xxx"
#endif
hjmjohnson marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ ExtractImageFilterCopyRegion(
const typename BinaryUnsignedIntDispatch<T1, T2>::FirstLessThanSecondType & firstLessThanSecond,
ImageRegion<T1> & destRegion,
const ImageRegion<T2> & srcRegion,
const ImageRegion<T1> & totalInputExtractionRegion)
const ImageRegion<T1> & itkNotUsed(totalInputExtractionRegion))
{
(void)totalInputExtractionRegion;
ImageToImageFilterDefaultCopyRegion<T1, T2>(firstLessThanSecond, destRegion, srcRegion);
}

Expand Down
4 changes: 2 additions & 2 deletions Modules/Core/Common/include/itkImageBoundaryCondition.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ class ITK_TEMPLATE_EXPORT ImageBoundaryCondition
* pixel values in the outputRequestedRegion.
*/
virtual RegionType
GetInputRequestedRegion(const RegionType & inputLargestPossibleRegion, const RegionType & outputRequestedRegion) const
GetInputRequestedRegion(const RegionType & inputLargestPossibleRegion,
[[maybe_unused]] const RegionType & itkNotUsed(outputRequestedRegion)) const
{
(void)outputRequestedRegion;
return inputLargestPossibleRegion;
}

Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/Common/include/itkObjectFactoryBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,10 @@ class ITKCommon_EXPORT ObjectFactoryBase : public Object
{};

// Factory registration, made thread-safe by "magic statics" (as introduced with C++11).
static const FactoryRegistration staticFactoryRegistration = [] {
[[maybe_unused]] static const FactoryRegistration staticFactoryRegistration = [] {
hjmjohnson marked this conversation as resolved.
Show resolved Hide resolved
RegisterFactoryInternal(TFactory::New());
return FactoryRegistration{};
}();

(void)staticFactoryRegistration;
hjmjohnson marked this conversation as resolved.
Show resolved Hide resolved
}

/** Initialize the static members of ObjectFactoryBase. */
Expand Down
9 changes: 4 additions & 5 deletions Modules/Core/Common/include/itkSingletonMacro.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@
#ifndef itkSingletonMacro_h
#define itkSingletonMacro_h

#define itkInitGlobalsMacro(VarName) \
{ \
static auto * staticGlobals = Get##VarName##Pointer(); \
(void)staticGlobals; \
hjmjohnson marked this conversation as resolved.
Show resolved Hide resolved
} \
#define itkInitGlobalsMacro(VarName) \
{ \
[[maybe_unused]] static auto * staticGlobals = Get##VarName##Pointer(); \
} \
ITK_MACROEND_NOOP_STATEMENT

#define itkGetGlobalDeclarationMacro(Type, VarName) static Type * Get##VarName##Pointer()
Expand Down
10 changes: 3 additions & 7 deletions Modules/Core/Common/include/itkVariableLengthVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,8 @@ class ITK_TEMPLATE_EXPORT VariableLengthVector
struct NeverReallocate : AllocateRootPolicy
{
bool
operator()(unsigned int newSize, unsigned int oldSize) const
operator()([[maybe_unused]] unsigned int newSize, [[maybe_unused]] unsigned int oldSize) const
{
(void)newSize;
(void)oldSize;
itkAssertInDebugAndIgnoreInReleaseMacro(newSize == oldSize &&
"SetSize is expected to never change the VariableLengthVector size...");
return true;
Expand Down Expand Up @@ -1032,9 +1030,8 @@ struct GetType
* \note the default unspecialized behaviour returns the input number \c v.
*/
static Type
Load(Type const & v, unsigned int idx)
Load(Type const & v, unsigned int itkNotUsed(idx))
{
(void)idx;
return v;
}
};
Expand All @@ -1051,9 +1048,8 @@ struct GetType
*/
template <typename TExpr1, typename TExpr2>
inline std::enable_if_t<mpl::And<mpl::IsArray<TExpr1>, mpl::IsArray<TExpr2>>::Value, unsigned int>
GetSize(TExpr1 const & lhs, TExpr2 const & rhs)
GetSize(TExpr1 const & lhs, [[maybe_unused]] TExpr2 const & rhs)
{
(void)rhs;
itkAssertInDebugAndIgnoreInReleaseMacro(lhs.Size() == rhs.Size());
return lhs.Size();
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/Core/Common/src/itkFloatingPointExceptions.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ itkFloatingPointExceptionsAbortOrExit()
}
}

void
[[maybe_unused]] void
itkFloatingPointExceptionsNotSupported()
{
std::cerr << "FloatingPointExceptions are not supported on this platform." << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ FloatingPointExceptions::Enable()
sigaction(SIGFPE, &act, nullptr);
# endif
FloatingPointExceptions::m_PimplGlobals->m_Enabled = true;
(void)itkFloatingPointExceptionsNotSupported; // avoid unused-function warning
#else
itkFloatingPointExceptionsNotSupported();
#endif
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/src/itkObjectFactoryBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ using ITK_LOAD_FUNCTION = ObjectFactoryBase * (*)();
* lower case for LibExtension values.
*/
inline bool
NameIsSharedLibrary(const char * name)
NameIsSharedLibrary([[maybe_unused]] const char * name)
{
#ifdef ITK_DYNAMIC_LOADING
std::string extension = itksys::DynamicLoader::LibExtension();
Expand All @@ -368,7 +368,6 @@ NameIsSharedLibrary(const char * name)
return true;
}
#else // ITK_DYNAMIC_LOADING
(void)name;
itkGenericExceptionMacro("ITK was not built with support for dynamic loading.");
#endif
return false;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkBitCastGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ TEST(BitCast, ResultIsBitwiseEqualToArgument)
Expect_return_value_is_bitwise_equal_to_function_argument<unsigned int>(i);
}

int value;
(void)value;
[[maybe_unused]] int value;
Expect_return_value_is_bitwise_equal_to_function_argument<intptr_t>(&value);
}
5 changes: 1 addition & 4 deletions Modules/Core/Common/test/itkCrossHelperTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@


int
itkCrossHelperTest(int argc, char * argv[])
itkCrossHelperTest(int itkNotUsed(argc), char * itkNotUsed(argv)[])
{
(void)argc;
(void)argv;

constexpr unsigned int Dimension2D = 2;
constexpr unsigned int Dimension3D = 3;
constexpr unsigned int Dimension4D = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class ITK_TEMPLATE_EXPORT GPUFiniteDifferenceFunction : public FiniteDifferenceF
PixelType
ComputeUpdate(const NeighborhoodType & itkNotUsed(neighborhood),
void * itkNotUsed(globalData),
const FloatOffsetType & itkNotUsed(offset = FloatOffsetType(0.0))) override
const FloatOffsetType & itkNotUsed(offset) = FloatOffsetType(0.0)) override
{
PixelType pix{};
return pix;
Expand Down
89 changes: 30 additions & 59 deletions Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,8 @@ class ITK_TEMPLATE_EXPORT QuadEdgeMesh : public Mesh<TPixel, VDimension, TTraits
* https://public.kitware.com/pipermail/insight-users/2005-April/012613.html
*/
void
CopyInformation(const DataObject * data) override
{
(void)data;
}
CopyInformation(const DataObject * itkNotUsed(data)) override
{}
void
Graft(const DataObject * data) override;

Expand All @@ -235,92 +233,69 @@ class ITK_TEMPLATE_EXPORT QuadEdgeMesh : public Mesh<TPixel, VDimension, TTraits
#if !defined(ITK_WRAPPING_PARSER)
/** overloaded method for backward compatibility */
void
SetBoundaryAssignments(int dimension, BoundaryAssignmentsContainer * container)
{
(void)dimension;
(void)container;
}
SetBoundaryAssignments(int itkNotUsed(dimension), BoundaryAssignmentsContainer * itkNotUsed(container))
{}

/** overloaded method for backward compatibility */
BoundaryAssignmentsContainerPointer
GetBoundaryAssignments(int dimension)
GetBoundaryAssignments(int itkNotUsed(dimension))
{
(void)dimension;
return (nullptr);
}

/** overloaded method for backward compatibility */
const BoundaryAssignmentsContainerPointer
GetBoundaryAssignments(int dimension) const
GetBoundaryAssignments(int itkNotUsed(dimension)) const
{
(void)dimension;
return (nullptr);
}

#endif

/** overloaded method for backward compatibility */
void
SetBoundaryAssignment(int dimension,
CellIdentifier cellId,
CellFeatureIdentifier featureId,
CellIdentifier boundaryId)
{
(void)dimension;
(void)cellId;
(void)featureId;
(void)boundaryId;
}
SetBoundaryAssignment(int itkNotUsed(dimension),
CellIdentifier itkNotUsed(cellId),
CellFeatureIdentifier itkNotUsed(featureId),
CellIdentifier itkNotUsed(boundaryId))
{}

/** overloaded method for backward compatibility */
bool
GetBoundaryAssignment(int dimension,
CellIdentifier cellId,
CellFeatureIdentifier featureId,
CellIdentifier * boundaryId) const
GetBoundaryAssignment(int itkNotUsed(dimension),
CellIdentifier itkNotUsed(cellId),
CellFeatureIdentifier itkNotUsed(featureId),
CellIdentifier * itkNotUsed(boundaryId))
{
(void)dimension;
(void)cellId;
(void)featureId;
(void)boundaryId;
return (false); // ALEX: is it the good way?
}

/** overloaded method for backward compatibility */
bool
RemoveBoundaryAssignment(int dimension, CellIdentifier cellId, CellFeatureIdentifier featureId)
RemoveBoundaryAssignment(int itkNotUsed(dimension),
CellIdentifier itkNotUsed(cellId),
CellFeatureIdentifier itkNotUsed(featureId))
{
(void)dimension;
(void)cellId;
(void)featureId;
return (false); // ALEX: is it the good way?
}

/** overloaded method for backward compatibility */
bool
GetCellBoundaryFeature(int dimension,
CellIdentifier cellId,
CellFeatureIdentifier featureId,
CellAutoPointer & cellAP) const
GetCellBoundaryFeature(int itkNotUsed(dimension),
CellIdentifier itkNotUsed(cellId),
CellFeatureIdentifier itkNotUsed(featureId),
CellAutoPointer & itkNotUsed(cellAP)) const
{
(void)dimension;
(void)cellId;
(void)featureId;
(void)cellAP;
return (false);
}

/** overloaded method for backward compatibility */
CellIdentifier
GetCellBoundaryFeatureNeighbors(int dimension,
CellIdentifier cellId,
CellFeatureIdentifier featureId,
std::set<CellIdentifier> * cellSet)
GetCellBoundaryFeatureNeighbors(int itkNotUsed(dimension),
CellIdentifier itkNotUsed(cellId),
CellFeatureIdentifier itkNotUsed(featureId),
std::set<CellIdentifier> * itkNotUsed(cellSet))
{
(void)dimension;
(void)cellId;
(void)featureId;
(void)cellSet;
return CellIdentifier{};
}

Expand All @@ -333,15 +308,11 @@ class ITK_TEMPLATE_EXPORT QuadEdgeMesh : public Mesh<TPixel, VDimension, TTraits

/** overloaded method for backward compatibility */
bool
GetAssignedCellBoundaryIfOneExists(int dimension,
CellIdentifier cellId,
CellFeatureIdentifier featureId,
CellAutoPointer & cellAP) const
GetAssignedCellBoundaryIfOneExists(int itkNotUsed(dimension),
CellIdentifier itkNotUsed(cellId),
CellFeatureIdentifier itkNotUsed(featureId),
CellAutoPointer & itkNotUsed(cellAP)) const
{
(void)dimension;
(void)cellId;
(void)featureId;
(void)cellAP;
return (false); // ALEX: is it the good way?
}

Expand Down
4 changes: 1 addition & 3 deletions Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMesh.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,8 @@ QuadEdgeMesh<TPixel, VDimension, TTraits>::Splice(QEPrimal * a, QEPrimal * b) ->
*/
template <typename TPixel, unsigned int VDimension, typename TTraits>
void
QuadEdgeMesh<TPixel, VDimension, TTraits>::SetCell(CellIdentifier cId, CellAutoPointer & cell)
QuadEdgeMesh<TPixel, VDimension, TTraits>::SetCell(CellIdentifier itkNotUsed(cId), CellAutoPointer & cell)
{
(void)cId;

// NOTE ALEX: should add some checking to be sure everything went fine
EdgeCellType * qe;
PolygonCellType * pe;
Expand Down
15 changes: 5 additions & 10 deletions Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshFrontIterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ class ITK_TEMPLATE_EXPORT QuadEdgeMeshFrontBaseIterator
* to the "topological metric" i.e. all edges have unit length.
*/
virtual CoordRepType
GetCost(QEType * edge)
GetCost(QEType * itkNotUsed(edge))
{
(void)edge;
return (1);
}

Expand Down Expand Up @@ -271,14 +270,10 @@ class ITK_TEMPLATE_EXPORT QuadEdgeMeshConstFrontIterator : public QuadEdgeMeshFr

public:
/** Object creation methods. */
QuadEdgeMeshConstFrontIterator(const MeshType * mesh = (MeshType *)0,
bool start = true,
QEType * seed = (QEType *)nullptr)
{
(void)mesh;
(void)start;
(void)seed;
}
QuadEdgeMeshConstFrontIterator(const MeshType * itkNotUsed(mesh) = (MeshType *)0,
bool itkNotUsed(start) = true,
QEType * itkNotUsed(seed) = (QEType *)nullptr)
{}

/** \todo do we need here a : Superclass( mesh, start, seed ) { } */
~QuadEdgeMeshConstFrontIterator() override = default;
Expand Down
Loading