Skip to content

Commit

Permalink
COMP: Add "const" to IOFactoryRegisterManager implementations
Browse files Browse the repository at this point in the history
Fixed clang-tidy (LLVM 13.0.0) warnings, saying:

> variable is non-const and globally accessible, consider making it const
> [cppcoreguidelines-avoid-non-const-global-variables]

Took those global variables out of their "unnamed namespace", because
they now already have internal linkage, just because they are "const".
  • Loading branch information
N-Dekker authored and hjmjohnson committed Oct 15, 2021
1 parent 49c910a commit f56cc7e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
13 changes: 5 additions & 8 deletions CMake/itkImageIOFactoryRegisterManager.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace itk {
class ImageIOFactoryRegisterManager
{
public:
explicit ImageIOFactoryRegisterManager(void (*list[])(void))
explicit ImageIOFactoryRegisterManager(void (* const list[])(void))
{
for(;*list != nullptr; ++list)
{
Expand All @@ -45,14 +45,11 @@ class ImageIOFactoryRegisterManager
// application translation units. Note that this code will be expanded in the
// ITK-based applications and not in ITK itself.
//
namespace {

void (*ImageIOFactoryRegisterRegisterList[])(void) = {
@LIST_OF_FACTORY_NAMES@
nullptr};
ImageIOFactoryRegisterManager ImageIOFactoryRegisterManagerInstance(ImageIOFactoryRegisterRegisterList);

}
constexpr void (*ImageIOFactoryRegisterRegisterList[])(void) = {
@LIST_OF_FACTORY_NAMES@
nullptr};
const ImageIOFactoryRegisterManager ImageIOFactoryRegisterManagerInstance(ImageIOFactoryRegisterRegisterList);

}

Expand Down
13 changes: 5 additions & 8 deletions CMake/itkMeshIOFactoryRegisterManager.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace itk {
class MeshIOFactoryRegisterManager
{
public:
explicit MeshIOFactoryRegisterManager(void (*list[])(void))
explicit MeshIOFactoryRegisterManager(void (* const list[])(void))
{
for(;*list != nullptr; ++list)
{
Expand All @@ -45,14 +45,11 @@ class MeshIOFactoryRegisterManager
// application translation units. Note that this code will be expanded in the
// ITK-based applications and not in ITK itself.
//
namespace {

void (*MeshIOFactoryRegisterRegisterList[])(void) = {
@LIST_OF_FACTORY_NAMES@
nullptr};
MeshIOFactoryRegisterManager MeshIOFactoryRegisterManagerInstance(MeshIOFactoryRegisterRegisterList);

}
constexpr void (*MeshIOFactoryRegisterRegisterList[])(void) = {
@LIST_OF_FACTORY_NAMES@
nullptr};
const MeshIOFactoryRegisterManager MeshIOFactoryRegisterManagerInstance(MeshIOFactoryRegisterRegisterList);

}

Expand Down
13 changes: 5 additions & 8 deletions CMake/itkTransformIOFactoryRegisterManager.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace itk {
class TransformIOFactoryRegisterManager
{
public:
explicit TransformIOFactoryRegisterManager(void (*list[])(void))
explicit TransformIOFactoryRegisterManager(void (* const list[])(void))
{
for(;*list != nullptr; ++list)
{
Expand All @@ -45,14 +45,11 @@ class TransformIOFactoryRegisterManager
// application translation units. Note that this code will be expanded in the
// ITK-based applications and not in ITK itself.
//
namespace {

void (*TransformIOFactoryRegisterRegisterList[])(void) = {
@LIST_OF_FACTORY_NAMES@
nullptr};
TransformIOFactoryRegisterManager TransformIOFactoryRegisterManagerInstance(TransformIOFactoryRegisterRegisterList);

}
constexpr void (*TransformIOFactoryRegisterRegisterList[])(void) = {
@LIST_OF_FACTORY_NAMES@
nullptr};
const TransformIOFactoryRegisterManager TransformIOFactoryRegisterManagerInstance(TransformIOFactoryRegisterRegisterList);

}

Expand Down

0 comments on commit f56cc7e

Please sign in to comment.