diff options
author | Matt Turner <[email protected]> | 2012-09-03 20:24:35 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2012-09-05 22:28:50 -0700 |
commit | 5067506ea6ada5eeae33b1acf1c916e00121c12a (patch) | |
tree | a6b4ff2e3cf5fb6058101aee3b6f1dcd3f382c15 /src/gallium | |
parent | a9e8054fffc6e3e6a5f108a96c331858c28a5862 (diff) |
Remove useless checks for NULL before freeing
This patch has been generated by the following Coccinelle semantic
patch:
// Remove useless checks for NULL before freeing
//
// free (NULL) is a no-op, so there is no need to avoid it
@@
expression E;
@@
+ free (E);
+ E = NULL;
- if (unlikely (E != NULL)) {
- free(E);
(
- E = NULL;
|
- E = 0;
)
...
- }
@@
expression E;
type T;
@@
+ free ((T) E);
+ E = NULL;
- if (unlikely (E != NULL)) {
- free((T) E);
(
- E = NULL;
|
- E = 0;
)
...
- }
@@
expression E;
@@
+ free (E);
- if (unlikely (E != NULL)) {
- free (E);
- }
@@
expression E;
type T;
@@
+ free ((T) E);
- if (unlikely (E != NULL)) {
- free ((T) E);
- }
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r600/r600_shader.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/x11/glxinit.c | 4 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/x11/x11_screen.c | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/xm_api.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/glx/xlib/xm_st.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/shaders_cache.c | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/xvmc/subpicture.c | 3 | ||||
-rw-r--r-- | src/gallium/targets/graw-xlib/graw_xlib.c | 3 |
8 files changed, 15 insertions, 31 deletions
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index da8be0bbc17..3e797645ed9 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -4997,10 +4997,8 @@ static void fc_pushlevel(struct r600_shader_ctx *ctx, int type) static void fc_poplevel(struct r600_shader_ctx *ctx) { struct r600_cf_stack_entry *sp = &ctx->bc->fc_stack[ctx->bc->fc_sp]; - if (sp->mid) { - free(sp->mid); - sp->mid = NULL; - } + free(sp->mid); + sp->mid = NULL; sp->num_mid = 0; sp->start = NULL; sp->type = 0; diff --git a/src/gallium/state_trackers/egl/x11/glxinit.c b/src/gallium/state_trackers/egl/x11/glxinit.c index 34be89a1197..b9c51279100 100644 --- a/src/gallium/state_trackers/egl/x11/glxinit.c +++ b/src/gallium/state_trackers/egl/x11/glxinit.c @@ -217,9 +217,7 @@ __glXFreeDisplayPrivate(XExtData * extension) priv = (__GLXdisplayPrivate *) extension->private_data; FreeScreenConfigs(priv); - if (priv->serverGLXversion) - free((char *) priv->serverGLXversion); - + free((char *) priv->serverGLXversion); free((char *) priv); return 0; } diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c index 47d9a69c7dd..effac0e711d 100644 --- a/src/gallium/state_trackers/egl/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl/x11/x11_screen.c @@ -95,10 +95,8 @@ x11_screen_destroy(struct x11_screen *xscr) { if (xscr->dri_fd >= 0) close(xscr->dri_fd); - if (xscr->dri_driver) - free(xscr->dri_driver); - if (xscr->dri_device) - free(xscr->dri_device); + free(xscr->dri_driver); + free(xscr->dri_device); #ifdef GLX_DIRECT_RENDERING /* xscr->glx_dpy will be destroyed with the X display */ @@ -106,8 +104,7 @@ x11_screen_destroy(struct x11_screen *xscr) xscr->glx_dpy->xscr = NULL; #endif - if (xscr->visuals) - free(xscr->visuals); + free(xscr->visuals); FREE(xscr); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 4b81755dcfa..7e915567a43 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -168,10 +168,8 @@ xmesa_init_display( Display *display ) xmdpy->screen->destroy(xmdpy->screen); xmdpy->screen = NULL; } - if (xmdpy->smapi) { - free(xmdpy->smapi); - xmdpy->smapi = NULL; - } + free(xmdpy->smapi); + xmdpy->smapi = NULL; xmdpy->display = NULL; } diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c index ee425ec2b59..7b54df5998c 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_st.c +++ b/src/gallium/state_trackers/glx/xlib/xm_st.c @@ -278,10 +278,8 @@ xmesa_create_st_framebuffer(XMesaDisplay xmdpy, XMesaBuffer b) stfbi = CALLOC_STRUCT(st_framebuffer_iface); xstfb = CALLOC_STRUCT(xmesa_st_framebuffer); if (!stfbi || !xstfb) { - if (stfbi) - free(stfbi); - if (xstfb) - free(xstfb); + free(stfbi); + free(xstfb); return NULL; } diff --git a/src/gallium/state_trackers/vega/shaders_cache.c b/src/gallium/state_trackers/vega/shaders_cache.c index 29463843bb7..eceae54051e 100644 --- a/src/gallium/state_trackers/vega/shaders_cache.c +++ b/src/gallium/state_trackers/vega/shaders_cache.c @@ -238,12 +238,9 @@ combine_shaders(const struct shader_asm_info *shaders[SHADER_STAGES], int num_sh ureg_destroy(ureg); - if (temp) - free(temp); - if (constant) - free(constant); - if (sampler) - free(sampler); + free(temp); + free(constant); + free(sampler); return p; } diff --git a/src/gallium/state_trackers/xvmc/subpicture.c b/src/gallium/state_trackers/xvmc/subpicture.c index f9f646b7496..8e96ce66dc0 100644 --- a/src/gallium/state_trackers/xvmc/subpicture.c +++ b/src/gallium/state_trackers/xvmc/subpicture.c @@ -115,8 +115,7 @@ static Status Validate(Display *dpy, XvPortID port, int surface_type_id, int xvi subpictures = XvMCListSubpictureTypes(dpy, port, surface_type_id, &num_subpics); if (num_subpics < 1) { - if (subpictures) - free(subpictures); + free(subpictures); return BadMatch; } if (!subpictures) diff --git a/src/gallium/targets/graw-xlib/graw_xlib.c b/src/gallium/targets/graw-xlib/graw_xlib.c index 95b856815db..6138cf6c01a 100644 --- a/src/gallium/targets/graw-xlib/graw_xlib.c +++ b/src/gallium/targets/graw-xlib/graw_xlib.c @@ -157,8 +157,7 @@ fail: if (xlib_handle) FREE(xlib_handle); - if (visinfo) - free(visinfo); + free(visinfo); if (win) XDestroyWindow(graw.display, win); |