Skip to content

Commit

Permalink
Resolve clang-tidy 19.1 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaderks committed Feb 12, 2025
1 parent 2307157 commit 398c8ef
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
6 changes: 4 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) Team CharLS.
# SPDX-FileCopyrightText: © 2020 Team CharLS
# SPDX-License-Identifier: BSD-3-Clause

# The approach for using clang tidy is to enable all warnings unless it adds no practical value to the CharLS projects
Expand Down Expand Up @@ -57,6 +57,7 @@
# -altera-id-dependent-backward-branch => Does not apply (is for openCL)
# -bugprone-easily-swappable-parameters => To many do not fix warnings
# -performance-enum-size => No performance gain, enums are not used in arrays.
# -boost-use-ranges => CharLS has by design not a dependency on Boost.

---
Checks: '*,
Expand Down Expand Up @@ -112,7 +113,8 @@ Checks: '*,
-readability-function-cognitive-complexity,
-bugprone-easily-swappable-parameters,
-concurrency-mt-unsafe,
-performance-enum-size'
-performance-enum-size,
-boost-use-ranges'
WarningsAsErrors: false
HeaderFilterRegex: ''
FormatStyle: none
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
C5026 = 'type': move constructor was implicitly defined as deleted [Just informational]
C5027 = 'type': move assignment operator was implicitly defined as deleted [Just informational]
C5045 = Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified [Just informational]
C5246 = the initialization of a subobject should be wrapped in braces [prevents simple usage of std::byte]
C5246 = the initialization of a sub-object should be wrapped in braces [prevents simple usage of std::byte]
C5264 = 'const' variable is not used [reported for const in header files]
C5258 = explicit capture of '' is not required for this use [VS 2019 requires capture of constexpr]
-->
Expand Down
7 changes: 4 additions & 3 deletions samples/convert.c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ static void triplet_to_planar(const uint8_t* triplet_buffer, uint8_t* planar_buf
const size_t line_start = line * stride;
for (size_t pixel = 0; pixel < width; ++pixel)
{
const size_t column = line_start + pixel * bytes_per_rgb_pixel;
const size_t column = line_start + (pixel * bytes_per_rgb_pixel);

planar_buffer[plane_column] = triplet_buffer[column];
planar_buffer[plane_column + 1 * byte_count_plane] = triplet_buffer[column + 1];
planar_buffer[plane_column + 2 * byte_count_plane] = triplet_buffer[column + 2];
planar_buffer[plane_column + (1 * byte_count_plane)] = triplet_buffer[column + 1];
planar_buffer[plane_column + (2 * byte_count_plane)] = triplet_buffer[column + 2];
++plane_column;
}
}
Expand Down Expand Up @@ -428,6 +428,7 @@ int main(const int argc, char* argv[])
if (!convert_bottom_up_to_top_down(pixel_data, dib_header.width, (size_t)dib_header.height, stride))
{
printf("Failed to convert the pixels from bottom up to top down\n");
free(pixel_data);
return EXIT_FAILURE;
}
}
Expand Down
6 changes: 3 additions & 3 deletions samples/convert.cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ std::vector<uint8_t> triplet_to_planar(const std::vector<uint8_t>& buffer, const
const auto line_start{line * stride};
for (size_t pixel{}; pixel != width; ++pixel)
{
const auto column{line_start + pixel * bytes_per_rgb_pixel};
const auto column{line_start + (pixel * bytes_per_rgb_pixel)};
result[plane_column] = buffer[column];
result[plane_column + 1 * byte_count_plane] = buffer[column + 1];
result[plane_column + 2 * byte_count_plane] = buffer[column + 2];
result[plane_column + (1 * byte_count_plane)] = buffer[column + 1];
result[plane_column + (2 * byte_count_plane)] = buffer[column + 2];
++plane_column;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/jpeg_stream_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,19 @@ void jpeg_stream_reader::read_oversize_image_dimension()
switch (dimension_size)
{
case 2:
check_segment_size(pc_and_dimension_bytes + sizeof(uint16_t) * 2);
check_segment_size(pc_and_dimension_bytes + (sizeof(uint16_t) * 2));
height = read_uint16();
width = read_uint16();
break;

case 3:
check_segment_size(pc_and_dimension_bytes + (sizeof(uint16_t) + 1) * 2);
check_segment_size(pc_and_dimension_bytes + ((sizeof(uint16_t) + 1) * 2));
height = read_uint24();
width = read_uint24();
break;

case 4:
check_segment_size(pc_and_dimension_bytes + sizeof(uint32_t) * 2);
check_segment_size(pc_and_dimension_bytes + (sizeof(uint32_t) * 2));
height = read_uint32();
width = read_uint32();
break;
Expand Down
4 changes: 2 additions & 2 deletions src/jpeg_stream_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void jpeg_stream_writer::write_application_data_segment(const int32_t applicatio

void jpeg_stream_writer::write_jpegls_preset_parameters_segment(const jpegls_pc_parameters& preset_coding_parameters)
{
write_segment_header(jpeg_marker_code::jpegls_preset_parameters, 1 + 5 * sizeof(uint16_t));
write_segment_header(jpeg_marker_code::jpegls_preset_parameters, 1 + (5 * sizeof(uint16_t)));
write_uint8(to_underlying_type(jpegls_preset_parameters_type::preset_coding_parameters));
write_uint16(preset_coding_parameters.maximum_sample_value);
write_uint16(preset_coding_parameters.threshold1);
Expand All @@ -152,7 +152,7 @@ void jpeg_stream_writer::write_jpegls_preset_parameters_segment(const jpegls_pc_
void jpeg_stream_writer::write_jpegls_preset_parameters_segment(const uint32_t height, const uint32_t width)
{
// Format is defined in ISO/IEC 14495-1, C.2.4.1.4
write_segment_header(jpeg_marker_code::jpegls_preset_parameters, size_t{1} + 1 + 2 * sizeof(uint32_t));
write_segment_header(jpeg_marker_code::jpegls_preset_parameters, size_t{1} + 1 + (2 * sizeof(uint32_t)));
write_uint8(to_underlying_type(jpegls_preset_parameters_type::oversize_image_dimension));
write_uint8(sizeof(uint32_t)); // Wxy: number of bytes used to represent Ye and Xe [2..4]. Always 4 for simplicity.
write_uint32(height); // Ye: number of lines in the image.
Expand Down
1 change: 1 addition & 0 deletions src/quantization_lut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "quantization_lut.hpp"

#include <charls/public_types.h>

#include "jpegls_algorithm.hpp"
#include "jpegls_preset_coding_parameters.hpp"

Expand Down
6 changes: 3 additions & 3 deletions test/compliance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ void triplet2_planar(vector<byte>& buffer, const rect_size size)
const size_t byte_count{size.cx * size.cy};
for (size_t i{}; i != byte_count; ++i)
{
work_buffer[i] = buffer[i * 3 + 0];
work_buffer[i + 1 * byte_count] = buffer[i * 3 + 1];
work_buffer[i + 2 * byte_count] = buffer[i * 3 + 2];
work_buffer[i] = buffer[i * 3];
work_buffer[i + (1 * byte_count)] = buffer[(i * 3) + 1];
work_buffer[i + (2 * byte_count)] = buffer[(i * 3) + 2];
}
swap(buffer, work_buffer);
}
Expand Down

0 comments on commit 398c8ef

Please sign in to comment.