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: Iaffd537784aa857108f6981fdfd82d0496eb5592
Merged-In: I151642d5a60c94f312d0611576ad0143c249ba3d
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index ab56a6f..0680c32 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -298,14 +298,14 @@
// fall back to the compiled-in font.
- gr_font = reinterpret_cast<GRFont*>(calloc(1, sizeof(*gr_font)));
- gr_font->texture = reinterpret_cast<GRSurface*>(malloc(sizeof(*gr_font->texture)));
+ gr_font = static_cast<GRFont*>(calloc(sizeof(*gr_font), 1));
+ gr_font->texture = static_cast<GRSurface*>(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<unsigned char*>(malloc(font.width * font.height));
+ unsigned char* bits = static_cast<unsigned char*>(malloc(font.width * font.height));
gr_font->texture->data = reinterpret_cast<unsigned char*>(bits);
unsigned char data;