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/mesa/drivers | |
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/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_state_cache.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_sanity.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_queryobj.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_sanity.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_screen.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/windows/gdi/wgl.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/windows/gdi/wmesa.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/fakeglx.c | 8 | ||||
-rw-r--r-- | src/mesa/drivers/x11/glxapi.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xfonts.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_buffer.c | 4 |
15 files changed, 21 insertions, 23 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 36672a71d73..7e81e5ee13a 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1660,7 +1660,7 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx, } if (mask & GL_DEPTH_BUFFER_BIT) { - GLuint *tmp = (GLuint *) malloc(srcW * srcH * sizeof(GLuint)); + GLuint *tmp = malloc(srcW * srcH * sizeof(GLuint)); if (tmp) { if (!blit->DepthFP) init_blit_depth_pixels(ctx); @@ -2712,7 +2712,7 @@ _mesa_meta_Bitmap(struct gl_context *ctx, return; } - bitmap8 = (GLubyte *) malloc(width * height); + bitmap8 = malloc(width * height); if (bitmap8) { memset(bitmap8, bg, width * height); _mesa_expand_bitmap(width, height, &unpackSave, bitmap1, diff --git a/src/mesa/drivers/dri/i965/brw_state_cache.c b/src/mesa/drivers/dri/i965/brw_state_cache.c index c39d589a1e9..d9cc520b62a 100644 --- a/src/mesa/drivers/dri/i965/brw_state_cache.c +++ b/src/mesa/drivers/dri/i965/brw_state_cache.c @@ -111,7 +111,7 @@ rehash(struct brw_cache *cache) GLuint size, i; size = cache->size * 3; - items = (struct brw_cache_item**) calloc(1, size * sizeof(*items)); + items = calloc(1, size * sizeof(*items)); for (i = 0; i < cache->size; i++) for (c = cache->items[i]; c; c = next) { @@ -327,7 +327,7 @@ brw_init_caches(struct brw_context *brw) cache->size = 7; cache->n_items = 0; - cache->items = (struct brw_cache_item **) + cache->items = calloc(1, cache->size * sizeof(struct brw_cache_item)); cache->bo = drm_intel_bo_alloc(intel->bufmgr, diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index f8add0f309d..cb8c040d4b4 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -235,7 +235,7 @@ GLboolean r200CreateContext( gl_api api, assert(screen); /* Allocate the R200 context */ - rmesa = (r200ContextPtr) calloc(1, sizeof(*rmesa)); + rmesa = calloc(1, sizeof(*rmesa)); if ( !rmesa ) { *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; diff --git a/src/mesa/drivers/dri/r200/r200_sanity.c b/src/mesa/drivers/dri/r200/r200_sanity.c index a439fd84ed5..eda63a2d40f 100644 --- a/src/mesa/drivers/dri/r200/r200_sanity.c +++ b/src/mesa/drivers/dri/r200/r200_sanity.c @@ -658,8 +658,7 @@ static int find_or_add_value( struct reg *reg, int val ) if (j == reg->nalloc) { reg->nalloc += 5; reg->nalloc *= 2; - reg->values = (union fi *) realloc( reg->values, - reg->nalloc * sizeof(union fi) ); + reg->values = realloc( reg->values, reg->nalloc * sizeof(union fi) ); } reg->values[reg->nvalues++].i = val; diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 2b99e36b2a3..f151747abcd 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -201,7 +201,7 @@ r100CreateContext( gl_api api, assert(screen); /* Allocate the Radeon context */ - rmesa = (r100ContextPtr) calloc(1, sizeof(*rmesa)); + rmesa = calloc(1, sizeof(*rmesa)); if ( !rmesa ) { *error = __DRI_CTX_ERROR_NO_MEMORY; return GL_FALSE; diff --git a/src/mesa/drivers/dri/radeon/radeon_queryobj.h b/src/mesa/drivers/dri/radeon/radeon_queryobj.h index 9ed61e237ed..0ad177a2c43 100644 --- a/src/mesa/drivers/dri/radeon/radeon_queryobj.h +++ b/src/mesa/drivers/dri/radeon/radeon_queryobj.h @@ -42,7 +42,7 @@ void radeon_emit_queryobj(struct gl_context *ctx, struct radeon_state_atom *atom static inline void radeon_init_query_stateobj(radeonContextPtr radeon, int SZ) { radeon->query.queryobj.cmd_size = (SZ); - radeon->query.queryobj.cmd = (uint32_t*) calloc(SZ, sizeof(uint32_t)); + radeon->query.queryobj.cmd = calloc(SZ, sizeof(uint32_t)); radeon->query.queryobj.name = "queryobj"; radeon->query.queryobj.idx = 0; radeon->query.queryobj.check = radeon_check_query_active; diff --git a/src/mesa/drivers/dri/radeon/radeon_sanity.c b/src/mesa/drivers/dri/radeon/radeon_sanity.c index 3e64be83edd..02f2e2b13b6 100644 --- a/src/mesa/drivers/dri/radeon/radeon_sanity.c +++ b/src/mesa/drivers/dri/radeon/radeon_sanity.c @@ -380,8 +380,7 @@ static int find_or_add_value( struct reg *reg, int val ) if (j == reg->nalloc) { reg->nalloc += 5; reg->nalloc *= 2; - reg->values = (union fi *) realloc( reg->values, - reg->nalloc * sizeof(union fi) ); + reg->values = realloc( reg->values, reg->nalloc * sizeof(union fi) ); } reg->values[reg->nvalues++].i = val; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index acd4cc1e2c5..237503d7708 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -488,7 +488,7 @@ radeonCreateScreen2(__DRIscreen *sPriv) uint32_t device_id = 0; /* Allocate the private area */ - screen = (radeonScreenPtr) calloc(1, sizeof(*screen)); + screen = calloc(1, sizeof(*screen)); if ( !screen ) { fprintf(stderr, "%s: Could not allocate memory for screen structure", __FUNCTION__); fprintf(stderr, "leaving here\n"); diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index d99473bb359..3458cc9f3ea 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -382,7 +382,7 @@ static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, VERIFY(GetTextMetrics(fontDevice, &metric)); - dibInfo = (BITMAPINFO *) calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1); + dibInfo = calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1); dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); dibInfo->bmiHeader.biPlanes = 1; dibInfo->bmiHeader.biBitCount = 1; diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 93da05fe70f..c610202736d 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -35,7 +35,7 @@ static WMesaFramebuffer wmesa_new_framebuffer(HDC hdc, struct gl_config *visual) { WMesaFramebuffer pwfb - = (WMesaFramebuffer) malloc(sizeof(struct wmesa_framebuffer)); + = malloc(sizeof(struct wmesa_framebuffer)); if (pwfb) { _mesa_initialize_window_framebuffer(&pwfb->Base, visual); pwfb->hDC = hdc; diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index d5a59b4566c..e6e4d7649aa 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -1249,7 +1249,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) return xmvis->vishandle; #else /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); + xmvis->vishandle = malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } @@ -1964,7 +1964,7 @@ Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements); if (*nelements > 0) { XMesaVisual *results; - results = (XMesaVisual *) malloc(*nelements * sizeof(XMesaVisual)); + results = malloc(*nelements * sizeof(XMesaVisual)); if (!results) { *nelements = 0; return NULL; @@ -1994,7 +1994,7 @@ Fake_glXChooseFBConfig( Display *dpy, int screen, xmvis = choose_visual(dpy, screen, attribList, GL_TRUE); if (xmvis) { - GLXFBConfig *config = (GLXFBConfig *) malloc(sizeof(XMesaVisual)); + GLXFBConfig *config = malloc(sizeof(XMesaVisual)); if (!config) { *nitems = 0; return NULL; @@ -2019,7 +2019,7 @@ Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) return xmvis->vishandle; #else /* create a new vishandle - the cached one may be stale */ - xmvis->vishandle = (XVisualInfo *) malloc(sizeof(XVisualInfo)); + xmvis->vishandle = malloc(sizeof(XVisualInfo)); if (xmvis->vishandle) { memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo)); } diff --git a/src/mesa/drivers/x11/glxapi.c b/src/mesa/drivers/x11/glxapi.c index 255a37bf295..959bac8fe0b 100644 --- a/src/mesa/drivers/x11/glxapi.c +++ b/src/mesa/drivers/x11/glxapi.c @@ -115,7 +115,7 @@ get_dispatch(Display *dpy) if (t) { struct display_dispatch *d; - d = (struct display_dispatch *) malloc(sizeof(struct display_dispatch)); + d = malloc(sizeof(struct display_dispatch)); if (d) { d->Dpy = dpy; d->Table = t; diff --git a/src/mesa/drivers/x11/xfonts.c b/src/mesa/drivers/x11/xfonts.c index 183de40554b..9957e8906db 100644 --- a/src/mesa/drivers/x11/xfonts.c +++ b/src/mesa/drivers/x11/xfonts.c @@ -247,7 +247,7 @@ Fake_glXUseXFont(Font font, int first, int count, int listbase) max_bm_width = (max_width + 7) / 8; max_bm_height = max_height; - bm = (GLubyte *) malloc((max_bm_width * max_bm_height) * sizeof(GLubyte)); + bm = malloc((max_bm_width * max_bm_height) * sizeof(GLubyte)); if (!bm) { XFreeFontInfo(NULL, fs, 1); _mesa_error(NULL, GL_OUT_OF_MEMORY, diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 6696f70f5b8..e838e46ebe2 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -171,7 +171,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/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index 242b6de4c26..1820d76bd46 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -203,7 +203,7 @@ alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height) _mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.\n"); return; } - b->backxrb->ximage->data = (char *) malloc(b->backxrb->ximage->height + b->backxrb->ximage->data = malloc(b->backxrb->ximage->height * b->backxrb->ximage->bytes_per_line); if (!b->backxrb->ximage->data) { _mesa_warning(NULL, "alloc_back_buffer: MALLOC failed.\n"); @@ -469,7 +469,7 @@ xmesa_MapRenderbuffer(struct gl_context *ctx, int bytes_per_line = _mesa_format_row_stride(xrb->Base.Base.Format, xrb->Base.Base.Width); - char *image = (char *) malloc(bytes_per_line * + char *image = malloc(bytes_per_line * xrb->Base.Base.Height); ximage = XCreateImage(xrb->Parent->display, xrb->Parent->xm_visual->visinfo->visual, |