diff options
author | Matt Turner <[email protected]> | 2012-09-04 23:33:28 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2012-09-05 22:28:50 -0700 |
commit | b6109de34f04747ed2937a2e63c1f53740202d3e (patch) | |
tree | 6578024b65adc9dc2bc3bd4a23cf44f29808b3b2 /src/gallium/state_trackers | |
parent | da3282b6e2f374b88daf09f7f3ba5b05af45f51a (diff) |
Remove useless checks for NULL before freeing
Same as earlier commit, except for "FREE"
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/state_trackers')
-rw-r--r-- | src/gallium/state_trackers/egl/common/egl_g3d.c | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/drm/modeset.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/drm/native_drm.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/gdi/native_gdi.c | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/wayland/native_drm.c | 6 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/wayland/native_shm.c | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/x11/native_dri2.c | 9 | ||||
-rw-r--r-- | src/gallium/state_trackers/egl/x11/native_ximage.c | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/vega/text.c | 3 | ||||
-rw-r--r-- | src/gallium/state_trackers/wgl/stw_device.c | 3 |
10 files changed, 17 insertions, 34 deletions
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 239be6129e8..86abaebd70e 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -169,8 +169,7 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) native_connectors = gdpy->native->modeset->get_connectors(gdpy->native, &num_connectors, NULL); if (!num_connectors) { - if (native_connectors) - FREE(native_connectors); + FREE(native_connectors); return; } @@ -184,8 +183,7 @@ egl_g3d_add_screens(_EGLDriver *drv, _EGLDisplay *dpy) native_modes = gdpy->native->modeset->get_modes(gdpy->native, nconn, &num_modes); if (!num_modes) { - if (native_modes) - FREE(native_modes); + FREE(native_modes); continue; } @@ -428,8 +426,7 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) native_configs = gdpy->native->get_configs(gdpy->native, &num_configs); if (!num_configs) { - if (native_configs) - FREE(native_configs); + FREE(native_configs); return id; } diff --git a/src/gallium/state_trackers/egl/drm/modeset.c b/src/gallium/state_trackers/egl/drm/modeset.c index b33323b9d60..32c0a258c6f 100644 --- a/src/gallium/state_trackers/egl/drm/modeset.c +++ b/src/gallium/state_trackers/egl/drm/modeset.c @@ -648,10 +648,8 @@ drm_display_fini_modeset(struct native_display *ndpy) FREE(drmdpy->connectors); } - if (drmdpy->shown_surfaces) { - FREE(drmdpy->shown_surfaces); - drmdpy->shown_surfaces = NULL; - } + FREE(drmdpy->shown_surfaces); + drmdpy->shown_surfaces = NULL; if (drmdpy->saved_crtcs) { for (i = 0; i < drmdpy->resources->count_crtcs; i++) { diff --git a/src/gallium/state_trackers/egl/drm/native_drm.c b/src/gallium/state_trackers/egl/drm/native_drm.c index feb1dc045bf..23fc137b834 100644 --- a/src/gallium/state_trackers/egl/drm/native_drm.c +++ b/src/gallium/state_trackers/egl/drm/native_drm.c @@ -123,8 +123,7 @@ drm_display_destroy(struct native_display *ndpy) { struct drm_display *drmdpy = drm_display(ndpy); - if (drmdpy->config) - FREE(drmdpy->config); + FREE(drmdpy->config); drm_display_fini_modeset(&drmdpy->base); @@ -132,8 +131,7 @@ drm_display_destroy(struct native_display *ndpy) ndpy->screen = NULL; ndpy_uninit(ndpy); - if (drmdpy->device_name) - FREE(drmdpy->device_name); + FREE(drmdpy->device_name); if (drmdpy->own_gbm) { gbm_device_destroy(&drmdpy->gbmdrm->base.base); diff --git a/src/gallium/state_trackers/egl/gdi/native_gdi.c b/src/gallium/state_trackers/egl/gdi/native_gdi.c index 78dbe7cca6c..7b40108884a 100644 --- a/src/gallium/state_trackers/egl/gdi/native_gdi.c +++ b/src/gallium/state_trackers/egl/gdi/native_gdi.c @@ -358,8 +358,7 @@ gdi_display_destroy(struct native_display *ndpy) { struct gdi_display *gdpy = gdi_display(ndpy); - if (gdpy->configs) - FREE(gdpy->configs); + FREE(gdpy->configs); ndpy_uninit(ndpy); diff --git a/src/gallium/state_trackers/egl/wayland/native_drm.c b/src/gallium/state_trackers/egl/wayland/native_drm.c index c6f61978ab0..7255c8fc9e2 100644 --- a/src/gallium/state_trackers/egl/wayland/native_drm.c +++ b/src/gallium/state_trackers/egl/wayland/native_drm.c @@ -73,10 +73,8 @@ wayland_drm_display_destroy(struct native_display *ndpy) if (drmdpy->wl_drm) wl_drm_destroy(drmdpy->wl_drm); - if (drmdpy->device_name) - FREE(drmdpy->device_name); - if (drmdpy->base.configs) - FREE(drmdpy->base.configs); + FREE(drmdpy->device_name); + FREE(drmdpy->base.configs); if (drmdpy->base.own_dpy) wl_display_disconnect(drmdpy->base.dpy); diff --git a/src/gallium/state_trackers/egl/wayland/native_shm.c b/src/gallium/state_trackers/egl/wayland/native_shm.c index 574ffce4b66..643bb929af2 100644 --- a/src/gallium/state_trackers/egl/wayland/native_shm.c +++ b/src/gallium/state_trackers/egl/wayland/native_shm.c @@ -63,8 +63,7 @@ wayland_shm_display_destroy(struct native_display *ndpy) { struct wayland_shm_display *shmdpy = wayland_shm_display(ndpy); - if (shmdpy->base.configs) - FREE(shmdpy->base.configs); + FREE(shmdpy->base.configs); if (shmdpy->base.own_dpy) wl_display_disconnect(shmdpy->base.dpy); diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 70ae0f98443..a989f9e9108 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -260,8 +260,7 @@ dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask) dri2surf->server_stamp++; dri2surf->client_stamp = dri2surf->server_stamp; - if (dri2surf->last_xbufs) - FREE(dri2surf->last_xbufs); + FREE(dri2surf->last_xbufs); dri2surf->last_xbufs = xbufs; dri2surf->last_num_xbufs = num_outs; } @@ -432,8 +431,7 @@ dri2_surface_destroy(struct native_surface *nsurf) struct dri2_surface *dri2surf = dri2_surface(nsurf); int i; - if (dri2surf->last_xbufs) - FREE(dri2surf->last_xbufs); + FREE(dri2surf->last_xbufs); for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { struct pipe_resource *ptex = dri2surf->textures[i]; @@ -752,8 +750,7 @@ dri2_display_destroy(struct native_display *ndpy) { struct dri2_display *dri2dpy = dri2_display(ndpy); - if (dri2dpy->configs) - FREE(dri2dpy->configs); + FREE(dri2dpy->configs); if (dri2dpy->base.screen) dri2dpy->base.screen->destroy(dri2dpy->base.screen); diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index ae9c3b21356..4f09e4627c3 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -511,8 +511,7 @@ ximage_display_destroy(struct native_display *ndpy) { struct ximage_display *xdpy = ximage_display(ndpy); - if (xdpy->configs) - FREE(xdpy->configs); + FREE(xdpy->configs); ndpy_uninit(ndpy); diff --git a/src/gallium/state_trackers/vega/text.c b/src/gallium/state_trackers/vega/text.c index 27d461ce660..14e3cc57551 100644 --- a/src/gallium/state_trackers/vega/text.c +++ b/src/gallium/state_trackers/vega/text.c @@ -52,8 +52,7 @@ static VGboolean del_glyph(struct vg_font *font, glyph = (struct vg_glyph *) cso_hash_take(font->glyphs, (unsigned) glyphIndex); - if (glyph) - FREE(glyph); + FREE(glyph); return (glyph != NULL); } diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index e65e71dc15f..8e4459c67f7 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -117,8 +117,7 @@ stw_init(const struct stw_winsys *stw_winsys) return TRUE; error1: - if (stw_dev->smapi) - FREE(stw_dev->smapi); + FREE(stw_dev->smapi); if (stw_dev->stapi) stw_dev->stapi->destroy(stw_dev->stapi); |