From 0271a62e676d50940ec5f86d94cf66629894c25f Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 13 Sep 2025 18:23:09 +0300 Subject: fix: Replace C-style casts with C++ casts This commit addresses cppcheck warnings about C-style casts (cstyleCast) by replacing them with appropriate C++ casts. C-style casts are considered dangerous because they can perform unsafe conversions without compile-time type checking, while C++ casts are more explicit and type-safe. Changes made: - static_cast for safe type conversions (e.g., void* to struct*) - reinterpret_cast for pointer type conversions (e.g., uint8_t* to char*) - Combined static_cast and reinterpret_cast for integer-to-pointer conversions Fixed files: - kmscube/cube-gles2.cpp: GLvoid* casts for OpenGL vertex attribute pointers - kmscube/cube-wl.cpp: Wayland interface pointer casts - kmscube/cube-x11.cpp: X11 window handle conversion - utils/fbtest.cpp: mmap return value cast - utils/kmstest.cpp: Framebuffer pointer arithmetic - utils/kmsview.cpp: Framebuffer memory mapping cast --- utils/kmsview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'utils/kmsview.cpp') diff --git a/utils/kmsview.cpp b/utils/kmsview.cpp index 437d3a6..4b60bb8 100644 --- a/utils/kmsview.cpp +++ b/utils/kmsview.cpp @@ -12,7 +12,7 @@ using namespace kms; static void read_frame(ifstream& is, DumbFramebuffer* fb, Crtc* crtc, Plane* plane) { for (unsigned i = 0; i < fb->num_planes(); ++i) - is.read((char*)fb->map(i), fb->size(i)); + is.read(reinterpret_cast(fb->map(i)), fb->size(i)); unsigned w = min(crtc->width(), fb->width()); unsigned h = min(crtc->height(), fb->height()); -- cgit v1.2.3