From de2346e9ba06d15d5839fe0a3b3f61f474c5bedb Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 13 Sep 2025 18:28:25 +0300 Subject: fix: Add explicit keyword to single-argument constructors This commit addresses cppcheck warnings about constructors with single arguments that are not marked as explicit (noExplicitConstructor). Single-argument constructors can perform implicit type conversions which may lead to unexpected behavior and bugs. Marking them as explicit prevents these implicit conversions and makes the code more predictable. Changes made: - kmscube/cube-egl.h: Added explicit keyword to EglState constructor - kmscube/cube-gbm.cpp: Added explicit keyword to GbmDevice constructor These changes improve type safety by requiring explicit construction calls and preventing unintended implicit conversions. --- kmscube/cube-egl.h | 2 +- kmscube/cube-gbm.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kmscube/cube-egl.h b/kmscube/cube-egl.h index 73e3ab1..873e756 100644 --- a/kmscube/cube-egl.h +++ b/kmscube/cube-egl.h @@ -5,7 +5,7 @@ class EglState { public: - EglState(void* native_display); + explicit EglState(void* native_display); EglState(void* native_display, EGLint native_visual_id); ~EglState(); diff --git a/kmscube/cube-gbm.cpp b/kmscube/cube-gbm.cpp index f18ae60..80a7024 100644 --- a/kmscube/cube-gbm.cpp +++ b/kmscube/cube-gbm.cpp @@ -26,7 +26,7 @@ static bool s_support_planes; class GbmDevice { public: - GbmDevice(Card& card) + explicit GbmDevice(Card& card) { m_dev = gbm_create_device(card.fd()); FAIL_IF(!m_dev, "failed to create gbm device"); -- cgit v1.2.3