Skip to content

Commit

Permalink
Merge pull request #4637 from hjmjohnson/gcc13.2-compiler-warnings
Browse files Browse the repository at this point in the history
COMP: Gcc13.2 compiler warnings
  • Loading branch information
thewtex authored May 14, 2024
2 parents 15b98c3 + e64032a commit cdc28b0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
3 changes: 2 additions & 1 deletion Modules/Core/Common/include/itkVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class ITK_TEMPLATE_EXPORT Vector : public FixedArray<T, VVectorDimension>
return VVectorDimension;
}

/** Set a vnl_vector_ref referencing the same memory block. */
/** Copy values from the vnl_vector input to the internal memory block. The minimum of
* VVectorDimension and vnl_vector::size() elements are copied. */
void
SetVnlVector(const vnl_vector<T> &);

Expand Down
3 changes: 2 additions & 1 deletion Modules/Core/Common/include/itkVector.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ template <typename T, unsigned int TVectorDimension>
void
Vector<T, TVectorDimension>::SetVnlVector(const vnl_vector<T> & v)
{
for (unsigned int i = 0; i < v.size(); ++i)
const unsigned int elements_to_copy = std::min<unsigned int>(TVectorDimension, v.size());
for (unsigned int i = 0; i < elements_to_copy; ++i)
{
(*this)[i] = v(i);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,14 +768,14 @@ void
ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage>::ThreadedAllocateData(ThreadIdType ThreadId)
{
static constexpr float SAFETY_FACTOR = 4.0;
unsigned int i, j;

m_Data[ThreadId].m_Semaphore[0] = 0;
m_Data[ThreadId].m_Semaphore[1] = 0;

const std::size_t bufferLayerSize = 2 * m_NumberOfLayers + 1;
// Allocate the layers for the sparse field.
m_Data[ThreadId].m_Layers.reserve(2 * m_NumberOfLayers + 1);
for (i = 0; i < 2 * static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)
m_Data[ThreadId].m_Layers.reserve(bufferLayerSize);
for (unsigned int i = 0; i < 2 * static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)
{
m_Data[ThreadId].m_Layers.push_back(LayerType::New());
}
Expand All @@ -786,12 +786,13 @@ ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage>::ThreadedAlloc
}

// Layers used as buffers for transferring pixels during load balancing
m_Data[ThreadId].m_LoadTransferBufferLayers = new LayerListType[2 * m_NumberOfLayers + 1];
for (i = 0; i < 2 * static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)

m_Data[ThreadId].m_LoadTransferBufferLayers = new LayerListType[bufferLayerSize];
for (unsigned int i = 0; i < 2 * static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)
{
m_Data[ThreadId].m_LoadTransferBufferLayers[i].reserve(m_NumOfWorkUnits);

for (j = 0; j < m_NumOfWorkUnits; ++j)
for (unsigned int j = 0; j < m_NumOfWorkUnits; ++j)
{
m_Data[ThreadId].m_LoadTransferBufferLayers[i].push_back(LayerType::New());
}
Expand All @@ -803,14 +804,13 @@ ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage>::ThreadedAlloc

// The SAFETY_FACTOR simple ensures that the number of nodes created
// is larger than those required to start with for each thread.
auto nodeNum =
static_cast<unsigned int>(SAFETY_FACTOR * m_Layers[0]->Size() * (2 * m_NumberOfLayers + 1) / m_NumOfWorkUnits);
auto nodeNum = static_cast<unsigned int>(SAFETY_FACTOR * m_Layers[0]->Size() * (bufferLayerSize) / m_NumOfWorkUnits);

m_Data[ThreadId].m_LayerNodeStore->Reserve(nodeNum);
m_Data[ThreadId].m_RMSChange = m_ValueZero;

// UpLists and Downlists
for (i = 0; i < 2; ++i)
for (unsigned int i = 0; i < 2; ++i)
{
m_Data[ThreadId].UpList[i] = LayerType::New();
m_Data[ThreadId].DownList[i] = LayerType::New();
Expand All @@ -824,27 +824,23 @@ ParallelSparseFieldLevelSetImageFilter<TInputImage, TOutputImage>::ThreadedAlloc
// for the Downlists
m_Data[ThreadId].m_InterNeighborNodeTransferBufferLayers[1] = new LayerPointerType *[m_NumberOfLayers + 1];

for (i = 0; i < static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)
for (unsigned int i = 0; i < static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)
{
m_Data[ThreadId].m_InterNeighborNodeTransferBufferLayers[0][i] = new LayerPointerType[m_NumOfWorkUnits];
m_Data[ThreadId].m_InterNeighborNodeTransferBufferLayers[1][i] = new LayerPointerType[m_NumOfWorkUnits];
}

for (i = 0; i < static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)
for (unsigned int i = 0; i < static_cast<unsigned int>(m_NumberOfLayers) + 1; ++i)
{
for (j = 0; j < m_NumOfWorkUnits; ++j)
for (unsigned int j = 0; j < m_NumOfWorkUnits; ++j)
{
m_Data[ThreadId].m_InterNeighborNodeTransferBufferLayers[0][i][j] = LayerType::New();
m_Data[ThreadId].m_InterNeighborNodeTransferBufferLayers[1][i][j] = LayerType::New();
}
}

// Local histogram for every thread (used during Iterate() )
m_Data[ThreadId].m_ZHistogram = new int[m_ZSize];
for (i = 0; i < m_ZSize; ++i)
{
m_Data[ThreadId].m_ZHistogram[i] = 0;
}
// Local histogram for every thread (used during Iterate()), initialized to zeros.
m_Data[ThreadId].m_ZHistogram = new int[m_ZSize]();

// Every thread must have its own copy of the GlobalData struct.
m_Data[ThreadId].globalData = this->GetDifferenceFunction()->GetGlobalDataPointer();
Expand Down

0 comments on commit cdc28b0

Please sign in to comment.