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/x11 | |
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/x11')
-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 |
5 files changed, 9 insertions, 9 deletions
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, |