diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-09-13 18:28:25 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-12-18 12:23:57 +0200 |
| commit | de2346e9ba06d15d5839fe0a3b3f61f474c5bedb (patch) | |
| tree | ff6d2f4bd3fbbf174daba4c3e57150f2b6bb8bdf | |
| parent | 00a14befa954162723142571caf301f9679c6059 (diff) | |
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.
| -rw-r--r-- | kmscube/cube-egl.h | 2 | ||||
| -rw-r--r-- | 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"); |
