diff options
author | Matt Turner <[email protected]> | 2012-09-03 19:44:00 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2012-09-05 22:28:50 -0700 |
commit | 2b7a972e3f36bfcdc6fbe2b59d7ffdcde49c9405 (patch) | |
tree | 4b9504b4799e9d29363690fb9083ac4bbcf78d51 /src/gallium | |
parent | 812931f602ff913a51a608a9b1b6826b7f2bfae0 (diff) |
Don't cast the return value of malloc/realloc
This patch has been generated by the following Coccinelle semantic
patch:
// Don't cast the return value of malloc/realloc.
//
// Casting the return value of malloc/realloc only stands to hide
// errors.
@@
type T;
expression E1, E2;
@@
- (T)
(
_mesa_align_calloc(E1, E2)
|
_mesa_align_malloc(E1, E2)
|
calloc(E1, E2)
|
malloc(E1)
|
realloc(E1, E2)
)
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r300/compiler/memory_pool.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_cb.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/r600/compute_memory_pool.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r600/r600_shader.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/x11/glxinit.c | 8 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/xm_api.c | 2 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/api_filters.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/polygon.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/shaders_cache.c | 6 | ||||
-rw-r--r-- | src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 4 |
10 files changed, 20 insertions, 20 deletions
diff --git a/src/gallium/drivers/r300/compiler/memory_pool.c b/src/gallium/drivers/r300/compiler/memory_pool.c index ddcdddf9e3c..a98dd709f2a 100644 --- a/src/gallium/drivers/r300/compiler/memory_pool.c +++ b/src/gallium/drivers/r300/compiler/memory_pool.c @@ -58,7 +58,7 @@ static void refill_pool(struct memory_pool * pool) if (!blocksize) blocksize = 2*POOL_LARGE_ALLOC; - newblock = (struct memory_block*)malloc(blocksize); + newblock = malloc(blocksize); newblock->next = pool->blocks; pool->blocks = newblock; @@ -85,7 +85,7 @@ void * memory_pool_malloc(struct memory_pool * pool, unsigned int bytes) return ptr; } else { - struct memory_block * block = (struct memory_block*)malloc(bytes + sizeof(struct memory_block)); + struct memory_block * block = malloc(bytes + sizeof(struct memory_block)); block->next = pool->blocks; pool->blocks = block; diff --git a/src/gallium/drivers/r300/r300_cb.h b/src/gallium/drivers/r300/r300_cb.h index b373937a1f9..e031e990bd7 100644 --- a/src/gallium/drivers/r300/r300_cb.h +++ b/src/gallium/drivers/r300/r300_cb.h @@ -82,7 +82,7 @@ do { \ assert(sizeof(*(ptr)) == sizeof(uint32_t)); \ cs_count = (size); \ - cs_ptr = (ptr) = (uint32_t*)malloc((size) * sizeof(uint32_t)); \ + cs_ptr = (ptr) = malloc((size) * sizeof(uint32_t)); \ } while (0) #define END_CB do { \ @@ -99,7 +99,7 @@ uint32_t *cs_ptr = NULL; (void) cs_ptr #define NEW_CB(ptr, size) \ - cs_ptr = (ptr) = (uint32_t*)malloc((size) * sizeof(uint32_t)) + cs_ptr = (ptr) = malloc((size) * sizeof(uint32_t)) #define BEGIN_CB(ptr, size) cs_ptr = (ptr) #define END_CB diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c index ad9099fd2f4..d612a459843 100644 --- a/src/gallium/drivers/r600/compute_memory_pool.c +++ b/src/gallium/drivers/r600/compute_memory_pool.c @@ -210,7 +210,7 @@ void compute_memory_grow_pool(struct compute_memory_pool* pool, COMPUTE_DBG(" Aligned size = %d\n", new_size_in_dw); compute_memory_shadow(pool, pipe, 1); - pool->shadow = (uint32_t*)realloc(pool->shadow, new_size_in_dw*4); + pool->shadow = realloc(pool->shadow, new_size_in_dw*4); pool->size_in_dw = new_size_in_dw; pool->screen->screen.resource_destroy( (struct pipe_screen *)pool->screen, diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 834c0b32989..da8be0bbc17 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -4981,7 +4981,7 @@ static void fc_set_mid(struct r600_shader_ctx *ctx, int fc_sp) { struct r600_cf_stack_entry *sp = &ctx->bc->fc_stack[fc_sp]; - sp->mid = (struct r600_bytecode_cf **)realloc((void *)sp->mid, + sp->mid = realloc((void *)sp->mid, sizeof(struct r600_bytecode_cf *) * (sp->num_mid + 1)); sp->mid[sp->num_mid] = ctx->bc->cf_last; sp->num_mid++; diff --git a/src/gallium/state_trackers/egl/x11/glxinit.c b/src/gallium/state_trackers/egl/x11/glxinit.c index c88d921a6cd..34be89a1197 100644 --- a/src/gallium/state_trackers/egl/x11/glxinit.c +++ b/src/gallium/state_trackers/egl/x11/glxinit.c @@ -101,7 +101,7 @@ _gl_context_modes_create(unsigned count, size_t minimum_size) next = &base; for (i = 0; i < count; i++) { - *next = (__GLcontextModes *) malloc(size); + *next = malloc(size); if (*next == NULL) { _gl_context_modes_destroy(base); base = NULL; @@ -165,7 +165,7 @@ __glXQueryServerString(Display * dpy, int opcode, CARD32 screen, CARD32 name) length = reply.length * 4; numbytes = reply.size; - buf = (char *) malloc(numbytes); + buf = malloc(numbytes); if (buf != NULL) { _XRead(dpy, buf, numbytes); length -= numbytes; @@ -619,10 +619,10 @@ __glXInitialize(Display * dpy) /* ** Allocate memory for all the pieces needed for this buffer. */ - private = (XExtData *) malloc(sizeof(XExtData)); + private = malloc(sizeof(XExtData)); if (!private) return NULL; - dpyPriv = (__GLXdisplayPrivate *) calloc(1, sizeof(__GLXdisplayPrivate)); + dpyPriv = calloc(1, sizeof(__GLXdisplayPrivate)); if (!dpyPriv) { free(private); return NULL; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 37613304bb8..4b81755dcfa 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -220,7 +220,7 @@ bits_per_pixel( XMesaVisual xmv ) /* Create a temporary XImage */ img = XCreateImage( dpy, visinfo->visual, visinfo->depth, ZPixmap, 0, /*format, offset*/ - (char*) malloc(8), /*data*/ + malloc(8), /*data*/ 1, 1, /*width, height*/ 32, /*bitmap_pad*/ 0 /*bytes_per_line*/ diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index af824d91bd2..afa5213d9a8 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -329,7 +329,7 @@ void vegaConvolve(VGImage dst, VGImage src, vg_validate_state(ctx); buffer_len = 8 + 2 * 4 * kernel_size; - buffer = (VGfloat*)malloc(buffer_len * sizeof(VGfloat)); + buffer = malloc(buffer_len * sizeof(VGfloat)); buffer[0] = 0.f; buffer[1] = 1.f; @@ -519,7 +519,7 @@ void vegaGaussianBlur(VGImage dst, VGImage src, stdDeviationX, stdDeviationY); buffer_len = 8 + 2 * 4 * kernel_size; - buffer = (VGfloat*)malloc(buffer_len * sizeof(VGfloat)); + buffer = malloc(buffer_len * sizeof(VGfloat)); buffer[0] = 0.f; buffer[1] = 1.f; diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index 3faec749e12..37f96d48347 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -83,7 +83,7 @@ static void polygon_print(struct polygon *poly) struct polygon * polygon_create(int size) { - struct polygon *poly = (struct polygon*)malloc(sizeof(struct polygon)); + struct polygon *poly = malloc(sizeof(struct polygon)); poly->data = malloc(sizeof(float) * COMPONENTS * size); poly->size = size; @@ -114,7 +114,7 @@ void polygon_destroy(struct polygon *poly) void polygon_resize(struct polygon *poly, int new_size) { - float *data = (float*)malloc(sizeof(float) * COMPONENTS * new_size); + float *data = malloc(sizeof(float) * COMPONENTS * new_size); int size = MIN2(sizeof(float) * COMPONENTS * new_size, sizeof(float) * COMPONENTS * poly->size); memcpy(data, poly->data, size); diff --git a/src/gallium/state_trackers/vega/shaders_cache.c b/src/gallium/state_trackers/vega/shaders_cache.c index dac1a7406c6..29463843bb7 100644 --- a/src/gallium/state_trackers/vega/shaders_cache.c +++ b/src/gallium/state_trackers/vega/shaders_cache.c @@ -182,7 +182,7 @@ combine_shaders(const struct shader_asm_info *shaders[SHADER_STAGES], int num_sh out = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0); if (num_consts >= 1) { - constant = (struct ureg_src *) malloc(sizeof(struct ureg_src) * end_const); + constant = malloc(sizeof(struct ureg_src) * end_const); for (i = start_const; i < end_const; i++) { constant[i] = ureg_DECL_constant(ureg, i); } @@ -190,14 +190,14 @@ combine_shaders(const struct shader_asm_info *shaders[SHADER_STAGES], int num_sh } if (num_temps >= 1) { - temp = (struct ureg_dst *) malloc(sizeof(struct ureg_dst) * end_temp); + temp = malloc(sizeof(struct ureg_dst) * end_temp); for (i = start_temp; i < end_temp; i++) { temp[i] = ureg_DECL_temporary(ureg); } } if (num_samplers >= 1) { - sampler = (struct ureg_src *) malloc(sizeof(struct ureg_src) * end_sampler); + sampler = malloc(sizeof(struct ureg_src) * end_sampler); for (i = start_sampler; i < end_sampler; i++) { sampler[i] = ureg_DECL_sampler(ureg, i); } diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c index 7e0f2f98a3b..5cd75d8e99b 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_cs.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_cs.c @@ -284,10 +284,10 @@ static unsigned radeon_add_reloc(struct radeon_cs_context *csc, csc->nrelocs += 10; size = csc->nrelocs * sizeof(struct radeon_bo*); - csc->relocs_bo = (struct radeon_bo**)realloc(csc->relocs_bo, size); + csc->relocs_bo = realloc(csc->relocs_bo, size); size = csc->nrelocs * sizeof(struct drm_radeon_cs_reloc); - csc->relocs = (struct drm_radeon_cs_reloc*)realloc(csc->relocs, size); + csc->relocs = realloc(csc->relocs, size); csc->chunks[1].chunk_data = (uint64_t)(uintptr_t)csc->relocs; } |