summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2025-09-13 18:20:35 +0300
committerTomi Valkeinen <tomi.valkeinen@ideasonboard.com>2025-12-18 12:23:57 +0200
commitbb4d48fbf9d0ad6be570d9c9b052f835f3a8b0d5 (patch)
tree7feeb721a184e7e704a7a55d3c73691297b7b7ab
parentd785a753f9406bf74150e038ccf58b8b40eea932 (diff)
fix: Use const references to avoid unnecessary variable copying
This commit addresses cppcheck warnings about variables that can be declared as const references (constVariableReference). These variables were being copied unnecessarily when they could be accessed as const references, improving performance and code clarity. Fixed files: - kms++util/src/cpuframebuffer.cpp: Make plane reference const in destructor - kms++util/src/testpat.cpp: Make info and lambda parameter const references - utils/kmstest.cpp: Make loop variable const reference in output parsing
-rw-r--r--kms++util/src/cpuframebuffer.cpp2
-rw-r--r--kms++util/src/testpat.cpp4
-rw-r--r--utils/kmstest.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/kms++util/src/cpuframebuffer.cpp b/kms++util/src/cpuframebuffer.cpp
index 8eac8c4..64ad531 100644
--- a/kms++util/src/cpuframebuffer.cpp
+++ b/kms++util/src/cpuframebuffer.cpp
@@ -26,7 +26,7 @@ CPUFramebuffer::CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat form
CPUFramebuffer::~CPUFramebuffer()
{
for (unsigned i = 0; i < m_num_planes; ++i) {
- FramebufferPlane& plane = m_planes[i];
+ const FramebufferPlane& plane = m_planes[i];
delete[] plane.map;
}
diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp
index 1edf978..8444ce0 100644
--- a/kms++util/src/testpat.cpp
+++ b/kms++util/src/testpat.cpp
@@ -471,7 +471,7 @@ static void draw_test_pattern_part(IFramebuffer& fb, size_t start_y, size_t end_
void draw_test_pattern_multi(IFramebuffer& fb, const TestPatternOptions& options)
{
- auto& info = get_pixel_format_info(fb.format());
+ const auto& info = get_pixel_format_info(fb.format());
uint8_t v_sub = 0;
for (size_t p = 0; p < info.num_planes; ++p)
v_sub = max(v_sub, info.planes[p].vsub);
@@ -514,7 +514,7 @@ void draw_test_pattern_multi(IFramebuffer& fb, const TestPatternOptions& options
t.join();
auto i = std::find_if(errors.begin(), errors.end(),
- [](auto& e) { return e != nullptr; });
+ [](const auto& e) { return e != nullptr; });
if (i != errors.end())
std::rethrow_exception(*i);
}
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index 5028e7e..8340fa7 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -572,7 +572,7 @@ static vector<OutputInfo> setups_to_outputs(Card& card, ResourceManager& resman,
OutputInfo* current_output = 0;
PlaneInfo* current_plane = 0;
- for (auto& arg : output_args) {
+ for (const auto& arg : output_args) {
switch (arg.type) {
case ArgType::Connector: {
outputs.push_back(OutputInfo{});