Skip to content

Commit

Permalink
STYLE: Replace C-style cast (size_t) ConvertPixelBuffer with static_cast
Browse files Browse the repository at this point in the history
Following C++ Core Guidelines, September 23, 2022: "If you must use a cast, use
a named cast", http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast
  • Loading branch information
N-Dekker authored and dzenanz committed Nov 29, 2022
1 parent 288d87b commit 622fb69
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Modules/IO/ImageBase/include/itkConvertPixelBuffer.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::Conver
// http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html
// NOTE: The scale factors are converted to whole numbers for
// precision
InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents;
InputPixelType * endInput = inputData + size * static_cast<size_t>(inputNumberOfComponents);
while (inputData != endInput)
{
double tempval = ((2125.0 * static_cast<double>(*inputData) + 7154.0 * static_cast<double>(*(inputData + 1)) +
Expand Down Expand Up @@ -369,7 +369,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::Conver
// just skip the rest of the data
else
{
InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents;
InputPixelType * endInput = inputData + size * static_cast<size_t>(inputNumberOfComponents);
while (inputData != endInput)
{
OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData));
Expand Down Expand Up @@ -471,7 +471,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::Conver
}
else
{
InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents;
InputPixelType * endInput = inputData + size * static_cast<size_t>(inputNumberOfComponents);
while (inputData != endInput)
{
OutputConvertTraits::SetNthComponent(0, *outputData, static_cast<OutputComponentType>(*inputData));
Expand Down Expand Up @@ -597,7 +597,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::Conver
OutputPixelType * outputData,
size_t size)
{
InputPixelType * endInput = inputData + size * (size_t)inputNumberOfComponents;
InputPixelType * endInput = inputData + size * static_cast<size_t>(inputNumberOfComponents);

while (inputData != endInput)
{
Expand All @@ -616,7 +616,7 @@ ConvertPixelBuffer<InputPixelType, OutputPixelType, OutputConvertTraits>::Conver
OutputPixelType * outputData,
size_t size)
{
size_t length = size * (size_t)inputNumberOfComponents;
size_t length = size * static_cast<size_t>(inputNumberOfComponents);

for (size_t i = 0; i < length; ++i)
{
Expand Down

0 comments on commit 622fb69

Please sign in to comment.