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/glx | |
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/glx')
-rw-r--r-- | src/glx/XF86dri.c | 10 | ||||
-rw-r--r-- | src/glx/clientattrib.c | 2 | ||||
-rw-r--r-- | src/glx/glx_pbuffer.c | 2 | ||||
-rw-r--r-- | src/glx/glx_query.c | 2 | ||||
-rw-r--r-- | src/glx/glxcmds.c | 2 | ||||
-rw-r--r-- | src/glx/glxconfig.c | 2 | ||||
-rw-r--r-- | src/glx/indirect_glx.c | 2 | ||||
-rw-r--r-- | src/glx/render2.c | 8 | ||||
-rw-r--r-- | src/glx/renderpix.c | 4 | ||||
-rw-r--r-- | src/glx/singlepix.c | 6 | ||||
-rw-r--r-- | src/glx/xfont.c | 2 |
11 files changed, 21 insertions, 21 deletions
diff --git a/src/glx/XF86dri.c b/src/glx/XF86dri.c index fe3a1551fa6..b1cdc9b2865 100644 --- a/src/glx/XF86dri.c +++ b/src/glx/XF86dri.c @@ -201,7 +201,7 @@ XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, } if (rep.length) { - if (!(*busIdString = (char *) calloc(rep.busIdStringLength + 1, 1))) { + if (!(*busIdString = calloc(rep.busIdStringLength + 1, 1))) { _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); UnlockDisplay(dpy); SyncHandle(); @@ -302,7 +302,7 @@ XF86DRIGetClientDriverName(Display * dpy, int screen, if (rep.length) { if (! (*clientDriverName = - (char *) calloc(rep.clientDriverNameLength + 1, 1))) { + calloc(rep.clientDriverNameLength + 1, 1))) { _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); UnlockDisplay(dpy); SyncHandle(); @@ -521,7 +521,7 @@ XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, if (*numClipRects) { int len = sizeof(drm_clip_rect_t) * (*numClipRects); - *pClipRects = (drm_clip_rect_t *) calloc(len, 1); + *pClipRects = calloc(len, 1); if (*pClipRects) _XRead(dpy, (char *) *pClipRects, len); } @@ -532,7 +532,7 @@ XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, if (*numBackClipRects) { int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); - *pBackClipRects = (drm_clip_rect_t *) calloc(len, 1); + *pBackClipRects = calloc(len, 1); if (*pBackClipRects) _XRead(dpy, (char *) *pBackClipRects, len); } @@ -582,7 +582,7 @@ XF86DRIGetDeviceInfo(Display * dpy, int screen, drm_handle_t * hFrameBuffer, *devPrivateSize = rep.devPrivateSize; if (rep.length) { - if (!(*pDevPrivate = (void *) calloc(rep.devPrivateSize, 1))) { + if (!(*pDevPrivate = calloc(rep.devPrivateSize, 1))) { _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); UnlockDisplay(dpy); SyncHandle(); diff --git a/src/glx/clientattrib.c b/src/glx/clientattrib.c index 4721fe938fd..1b306eab120 100644 --- a/src/glx/clientattrib.c +++ b/src/glx/clientattrib.c @@ -75,7 +75,7 @@ __indirect_glPushClientAttrib(GLuint mask) if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) { if (!(sp = *spp)) { - sp = (__GLXattribute *) malloc(sizeof(__GLXattribute)); + sp = malloc(sizeof(__GLXattribute)); *spp = sp; } sp->mask = mask; diff --git a/src/glx/glx_pbuffer.c b/src/glx/glx_pbuffer.c index b5806d62e5b..e4b2c86a08d 100644 --- a/src/glx/glx_pbuffer.c +++ b/src/glx/glx_pbuffer.c @@ -326,7 +326,7 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable, length = reply.length; if (length) { num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2; - data = (CARD32 *) malloc(length * sizeof(CARD32)); + data = malloc(length * sizeof(CARD32)); if (data == NULL) { /* Throw data on the floor */ _XEatData(dpy, length); diff --git a/src/glx/glx_query.c b/src/glx/glx_query.c index bbc2b79d83d..8a7ca53f5d2 100644 --- a/src/glx/glx_query.c +++ b/src/glx/glx_query.c @@ -146,7 +146,7 @@ __glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode, length = reply.length * 4; numbytes = reply.size; - buf = (char *) malloc(numbytes); + buf = malloc(numbytes); if (buf != NULL) { _XRead(dpy, buf, numbytes); length -= numbytes; diff --git a/src/glx/glxcmds.c b/src/glx/glxcmds.c index 0b90b4255f9..ddfe12c2463 100644 --- a/src/glx/glxcmds.c +++ b/src/glx/glxcmds.c @@ -2454,7 +2454,7 @@ _X_HIDDEN char * __glXstrdup(const char *str) { char *copy; - copy = (char *) malloc(strlen(str) + 1); + copy = malloc(strlen(str) + 1); if (!copy) return NULL; strcpy(copy, str); diff --git a/src/glx/glxconfig.c b/src/glx/glxconfig.c index c3e1d5a5680..e5718b143fc 100644 --- a/src/glx/glxconfig.c +++ b/src/glx/glxconfig.c @@ -230,7 +230,7 @@ glx_config_create_list(unsigned count) next = &base; for (i = 0; i < count; i++) { - *next = (struct glx_config *) malloc(size); + *next = malloc(size); if (*next == NULL) { glx_config_destroy_list(base); base = NULL; diff --git a/src/glx/indirect_glx.c b/src/glx/indirect_glx.c index 4f23fed3b08..53d5a914db7 100644 --- a/src/glx/indirect_glx.c +++ b/src/glx/indirect_glx.c @@ -384,7 +384,7 @@ indirect_create_context(struct glx_screen *psc, */ bufSize = (XMaxRequestSize(psc->dpy) * 4) - sz_xGLXRenderReq; - gc->buf = (GLubyte *) malloc(bufSize); + gc->buf = malloc(bufSize); if (!gc->buf) { free(gc->client_state_private); free(gc); diff --git a/src/glx/render2.c b/src/glx/render2.c index 870f0611186..a33c2cf19bf 100644 --- a/src/glx/render2.c +++ b/src/glx/render2.c @@ -89,7 +89,7 @@ __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, if (stride != k) { GLubyte *buf; - buf = (GLubyte *) malloc(compsize); + buf = malloc(compsize); if (!buf) { __glXSetError(gc, GL_OUT_OF_MEMORY); return; @@ -152,7 +152,7 @@ __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, if (stride != k) { GLubyte *buf; - buf = (GLubyte *) malloc(compsize); + buf = malloc(compsize); if (!buf) { __glXSetError(gc, GL_OUT_OF_MEMORY); return; @@ -227,7 +227,7 @@ __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, if ((vstr != k) || (ustr != k * vord)) { GLdouble *buf; - buf = (GLdouble *) malloc(compsize); + buf = malloc(compsize); if (!buf) { __glXSetError(gc, GL_OUT_OF_MEMORY); return; @@ -303,7 +303,7 @@ __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, if ((vstr != k) || (ustr != k * vord)) { GLfloat *buf; - buf = (GLfloat *) malloc(compsize); + buf = malloc(compsize); if (!buf) { __glXSetError(gc, GL_OUT_OF_MEMORY); return; diff --git a/src/glx/renderpix.c b/src/glx/renderpix.c index 508a1e10459..a88b544c764 100644 --- a/src/glx/renderpix.c +++ b/src/glx/renderpix.c @@ -84,7 +84,7 @@ __glXSendLargeImage(struct glx_context * gc, GLint compsize, GLint dim, GLubyte * pc, GLubyte * modes) { /* Allocate a temporary holding buffer */ - GLubyte *buf = (GLubyte *) malloc(compsize); + GLubyte *buf = malloc(compsize); if (!buf) { __glXSetError(gc, GL_OUT_OF_MEMORY); return; @@ -178,7 +178,7 @@ __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat, pc += hdrlen; /* Allocate a temporary holding buffer */ - buf = (GLubyte *) malloc(bufsize); + buf = malloc(bufsize); if (!buf) { __glXSetError(gc, GL_OUT_OF_MEMORY); return; diff --git a/src/glx/singlepix.c b/src/glx/singlepix.c index 6348f828580..b80b2fcbd22 100644 --- a/src/glx/singlepix.c +++ b/src/glx/singlepix.c @@ -68,7 +68,7 @@ __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, heightsize = __glImageSize(height, 1, 1, format, type, 0); /* Allocate a holding buffer to transform the data from */ - rowBuf = (GLubyte *) malloc(widthsize); + rowBuf = malloc(widthsize); if (!rowBuf) { /* Throw data away */ _XEatData(dpy, compsize); @@ -82,7 +82,7 @@ __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row); free((char *) rowBuf); } - colBuf = (GLubyte *) malloc(heightsize); + colBuf = malloc(heightsize); if (!colBuf) { /* Throw data away */ _XEatData(dpy, compsize - __GLX_PAD(widthsize)); @@ -155,7 +155,7 @@ void gl_dispatch_stub_GetSeparableFilterEXT (GLenum target, GLenum format, const GLint heightsize = __glImageSize(height, 1, 1, format, type, 0); GLubyte *const buf = - (GLubyte *) malloc((widthsize > heightsize) ? widthsize : heightsize); + malloc((widthsize > heightsize) ? widthsize : heightsize); if (buf == NULL) { /* Throw data away */ diff --git a/src/glx/xfont.c b/src/glx/xfont.c index 065938f0504..f358204c0f8 100644 --- a/src/glx/xfont.c +++ b/src/glx/xfont.c @@ -245,7 +245,7 @@ DRI_glXUseXFont(struct glx_context *CC, Font font, int first, int count, int lis 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); __glXSetError(CC, GL_OUT_OF_MEMORY); |