diff options
author | Rahul Chaudhry | 2016-11-09 15:17:01 -0600 |
---|---|---|
committer | Tao Bao | 2016-11-16 01:24:54 -0600 |
commit | b29f23f7e7c791e7d8786de93d630a12e4250c71 (patch) | |
tree | 7c5ac472f60ca965c98eb2cf547f8685bcdd3101 /minui/resources.cpp | |
parent | 4f86f26a3da5a0a612b0d7b5305847a6c2dae195 (diff) | |
download | platform-bootable-recovery-b29f23f7e7c791e7d8786de93d630a12e4250c71.tar.gz platform-bootable-recovery-b29f23f7e7c791e7d8786de93d630a12e4250c71.tar.xz platform-bootable-recovery-b29f23f7e7c791e7d8786de93d630a12e4250c71.zip |
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
Diffstat (limited to 'minui/resources.cpp')
-rw-r--r-- | minui/resources.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/minui/resources.cpp b/minui/resources.cpp index 455ef278..34e7b8be 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp | |||
@@ -37,7 +37,7 @@ | |||
37 | 37 | ||
38 | static GRSurface* malloc_surface(size_t data_size) { | 38 | static GRSurface* malloc_surface(size_t data_size) { |
39 | size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT; | 39 | size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT; |
40 | unsigned char* temp = reinterpret_cast<unsigned char*>(malloc(size)); | 40 | unsigned char* temp = static_cast<unsigned char*>(malloc(size)); |
41 | if (temp == NULL) return NULL; | 41 | if (temp == NULL) return NULL; |
42 | GRSurface* surface = reinterpret_cast<GRSurface*>(temp); | 42 | GRSurface* surface = reinterpret_cast<GRSurface*>(temp); |
43 | surface->data = temp + sizeof(GRSurface) + | 43 | surface->data = temp + sizeof(GRSurface) + |
@@ -221,7 +221,7 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) { | |||
221 | png_set_bgr(png_ptr); | 221 | png_set_bgr(png_ptr); |
222 | #endif | 222 | #endif |
223 | 223 | ||
224 | p_row = reinterpret_cast<unsigned char*>(malloc(width * 4)); | 224 | p_row = static_cast<unsigned char*>(malloc(width * 4)); |
225 | for (y = 0; y < height; ++y) { | 225 | for (y = 0; y < height; ++y) { |
226 | png_read_row(png_ptr, p_row, NULL); | 226 | png_read_row(png_ptr, p_row, NULL); |
227 | transform_rgb_to_draw(p_row, surface->data + y * surface->row_bytes, channels, width); | 227 | 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, | |||
281 | goto exit; | 281 | goto exit; |
282 | } | 282 | } |
283 | 283 | ||
284 | surface = reinterpret_cast<GRSurface**>(calloc(*frames, sizeof(GRSurface*))); | 284 | surface = static_cast<GRSurface**>(calloc(*frames, sizeof(GRSurface*))); |
285 | if (surface == NULL) { | 285 | if (surface == NULL) { |
286 | result = -8; | 286 | result = -8; |
287 | goto exit; | 287 | goto exit; |
@@ -298,7 +298,7 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps, | |||
298 | png_set_bgr(png_ptr); | 298 | png_set_bgr(png_ptr); |
299 | #endif | 299 | #endif |
300 | 300 | ||
301 | p_row = reinterpret_cast<unsigned char*>(malloc(width * 4)); | 301 | p_row = static_cast<unsigned char*>(malloc(width * 4)); |
302 | for (y = 0; y < height; ++y) { | 302 | for (y = 0; y < height; ++y) { |
303 | png_read_row(png_ptr, p_row, NULL); | 303 | png_read_row(png_ptr, p_row, NULL); |
304 | int frame = y % *frames; | 304 | int frame = y % *frames; |