diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-09-13 17:40:42 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-12-18 12:23:57 +0200 |
| commit | 7cc1bdd06e68ab81612e8feee2a1dedf0e392886 (patch) | |
| tree | 99415217574312a3ac7b22a8fcb84aa27ab156fa /kms++/src | |
| parent | 2efdd2583da9575242091bb53c57a311c3eacbc6 (diff) | |
fix: Replace C-style casts with C++ static/reinterpret casts
C-style casts should be replaced with appropriate C++ cast operators
for better type safety and code clarity. This change fixes cppcheck
style warnings about C-style pointer casting by using:
- static_cast for simple pointer type conversions
- reinterpret_cast for memory buffer pointer arithmetic
The changes maintain identical functionality while following modern
C++ best practices for explicit casting.
Diffstat (limited to 'kms++/src')
| -rw-r--r-- | kms++/src/blob.cpp | 2 | ||||
| -rw-r--r-- | kms++/src/card.cpp | 2 | ||||
| -rw-r--r-- | kms++/src/dmabufframebuffer.cpp | 4 | ||||
| -rw-r--r-- | kms++/src/dumbframebuffer.cpp | 4 | ||||
| -rw-r--r-- | kms++/src/omap/omapframebuffer.cpp | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/kms++/src/blob.cpp b/kms++/src/blob.cpp index 431863a..69914f6 100644 --- a/kms++/src/blob.cpp +++ b/kms++/src/blob.cpp @@ -38,7 +38,7 @@ vector<uint8_t> Blob::data() if (!blob) throw invalid_argument("Blob data not available"); - uint8_t* data = (uint8_t*)blob->data; + uint8_t* data = static_cast<uint8_t*>(blob->data); auto v = vector<uint8_t>(data, data + blob->length); diff --git a/kms++/src/card.cpp b/kms++/src/card.cpp index 935969d..d0af8a4 100644 --- a/kms++/src/card.cpp +++ b/kms++/src/card.cpp @@ -393,7 +393,7 @@ static void page_flip_handler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void* data) { - auto handler = (PageFlipHandlerBase*)data; + auto handler = static_cast<PageFlipHandlerBase*>(data); double time = sec + usec / 1000000.0; handler->handle_page_flip(frame, time); } diff --git a/kms++/src/dmabufframebuffer.cpp b/kms++/src/dmabufframebuffer.cpp index 939c025..33d65f7 100644 --- a/kms++/src/dmabufframebuffer.cpp +++ b/kms++/src/dmabufframebuffer.cpp @@ -97,8 +97,8 @@ uint8_t* DmabufFramebuffer::map(unsigned plane) if (p.map) return p.map; - p.map = (uint8_t*)mmap(0, p.size, PROT_READ | PROT_WRITE, MAP_SHARED, - p.prime_fd, 0); + p.map = static_cast<uint8_t*>(mmap(0, p.size, PROT_READ | PROT_WRITE, MAP_SHARED, + p.prime_fd, 0)); if (p.map == MAP_FAILED) throw invalid_argument(string("mmap failed: ") + strerror(errno)); diff --git a/kms++/src/dumbframebuffer.cpp b/kms++/src/dumbframebuffer.cpp index e035061..6b623b3 100644 --- a/kms++/src/dumbframebuffer.cpp +++ b/kms++/src/dumbframebuffer.cpp @@ -119,8 +119,8 @@ uint8_t* DumbFramebuffer::map(unsigned plane) throw invalid_argument(string("DRM_IOCTL_MODE_MAP_DUMB failed: ") + strerror(errno)); /* perform actual memory mapping */ - p.map = (uint8_t*)mmap(0, p.size, PROT_READ | PROT_WRITE, MAP_SHARED, - card().fd(), mreq.offset); + p.map = static_cast<uint8_t*>(mmap(0, p.size, PROT_READ | PROT_WRITE, MAP_SHARED, + card().fd(), mreq.offset)); if (p.map == MAP_FAILED) throw invalid_argument(string("mmap failed: ") + strerror(errno)); diff --git a/kms++/src/omap/omapframebuffer.cpp b/kms++/src/omap/omapframebuffer.cpp index 9f9d7c7..4a94202 100644 --- a/kms++/src/omap/omapframebuffer.cpp +++ b/kms++/src/omap/omapframebuffer.cpp @@ -167,7 +167,7 @@ uint8_t* OmapFramebuffer::map(unsigned plane) if (p.map) return p.map; - p.map = (uint8_t*)omap_bo_map(p.omap_bo); + p.map = static_cast<uint8_t*>(omap_bo_map(p.omap_bo)); if (p.map == MAP_FAILED) throw invalid_argument(string("mmap failed: ") + strerror(errno)); |
