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/resources.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'minui/resources.cpp') diff --git a/minui/resources.cpp b/minui/resources.cpp index 730b05f13..c723476cc 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -37,7 +37,7 @@ static GRSurface* malloc_surface(size_t data_size) { size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT; - unsigned char* temp = reinterpret_cast(malloc(size)); + unsigned char* temp = static_cast(malloc(size)); if (temp == NULL) return NULL; GRSurface* surface = reinterpret_cast(temp); surface->data = temp + sizeof(GRSurface) + @@ -221,7 +221,7 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) { png_set_bgr(png_ptr); #endif - p_row = reinterpret_cast(malloc(width * 4)); + p_row = static_cast(malloc(width * 4)); for (y = 0; y < height; ++y) { png_read_row(png_ptr, p_row, NULL); transform_rgb_to_draw(p_row, surface->data + y * surface->row_bytes, channels, width); @@ -281,7 +281,7 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps, goto exit; } - surface = reinterpret_cast(calloc(*frames, sizeof(GRSurface*))); + surface = static_cast(calloc(*frames, sizeof(GRSurface*))); if (surface == NULL) { result = -8; goto exit; @@ -298,7 +298,7 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps, png_set_bgr(png_ptr); #endif - p_row = reinterpret_cast(malloc(width * 4)); + p_row = static_cast(malloc(width * 4)); for (y = 0; y < height; ++y) { png_read_row(png_ptr, p_row, NULL); int frame = y % *frames; -- cgit v1.2.3