diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-09-13 18:23:09 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-12-18 12:23:57 +0200 |
| commit | 0271a62e676d50940ec5f86d94cf66629894c25f (patch) | |
| tree | 6cafec033afba5469dbfacc1dd3e4c621bcdd0cc /kmscube/cube-gles2.cpp | |
| parent | bb4d48fbf9d0ad6be570d9c9b052f835f3a8b0d5 (diff) | |
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
Diffstat (limited to 'kmscube/cube-gles2.cpp')
| -rw-r--r-- | kmscube/cube-gles2.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kmscube/cube-gles2.cpp b/kmscube/cube-gles2.cpp index 854c90e..0e52a32 100644 --- a/kmscube/cube-gles2.cpp +++ b/kmscube/cube-gles2.cpp @@ -200,11 +200,11 @@ GlScene::GlScene() glBufferSubData(GL_ARRAY_BUFFER, positionsoffset, sizeof(vVertices), &vVertices[0]); glBufferSubData(GL_ARRAY_BUFFER, colorsoffset, sizeof(vColors), &vColors[0]); glBufferSubData(GL_ARRAY_BUFFER, normalsoffset, sizeof(vNormals), &vNormals[0]); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)positionsoffset); + glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<const GLvoid*>(positionsoffset)); glEnableVertexAttribArray(0); - glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)normalsoffset); + glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<const GLvoid*>(normalsoffset)); glEnableVertexAttribArray(1); - glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*)colorsoffset); + glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, reinterpret_cast<const GLvoid*>(colorsoffset)); glEnableVertexAttribArray(2); } |
