From 4f7faac8d705317271e1d6aa773f00f05ca70848 Mon Sep 17 00:00:00 2001 From: Rahul Chaudhry Date: Tue, 8 Nov 2016 16:06:13 -0800 Subject: Use static_cast to cast pointers returned by malloc/calloc/realloc/mmap. static_cast is preferable to reinterpret_cast when casting from void* pointers returned by malloc/calloc/realloc/mmap calls. Discovered while looking at compiler warnings (b/26936282). Test: WITH_TIDY=1 WITH_STATIC_ANALYZER=1 mma Change-Id: I151642d5a60c94f312d0611576ad0143c249ba3d --- minui/graphics.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'minui/graphics.cpp') diff --git a/minui/graphics.cpp b/minui/graphics.cpp index ab56a6fd6..d5d8d526e 100644 --- a/minui/graphics.cpp +++ b/minui/graphics.cpp @@ -265,7 +265,7 @@ unsigned int gr_get_height(GRSurface* surface) { } int gr_init_font(const char* name, GRFont** dest) { - GRFont* font = reinterpret_cast(calloc(1, sizeof(*gr_font))); + GRFont* font = static_cast(calloc(1, sizeof(*gr_font))); if (font == nullptr) { return -1; } @@ -298,14 +298,14 @@ static void gr_init_font(void) // fall back to the compiled-in font. - gr_font = reinterpret_cast(calloc(1, sizeof(*gr_font))); - gr_font->texture = reinterpret_cast(malloc(sizeof(*gr_font->texture))); + gr_font = static_cast(calloc(1, sizeof(*gr_font))); + gr_font->texture = static_cast(malloc(sizeof(*gr_font->texture))); gr_font->texture->width = font.width; gr_font->texture->height = font.height; gr_font->texture->row_bytes = font.width; gr_font->texture->pixel_bytes = 1; - unsigned char* bits = reinterpret_cast(malloc(font.width * font.height)); + unsigned char* bits = static_cast(malloc(font.width * font.height)); gr_font->texture->data = reinterpret_cast(bits); unsigned char data; -- cgit v1.2.3