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/auxiliary | |
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/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_gs.c | 4 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_exec.c | 22 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_draw_quad.c | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_format.c | 8 |
6 files changed, 13 insertions, 33 deletions
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index b2b40871af7..c5647268595 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -435,9 +435,7 @@ int draw_geometry_shader_run(struct draw_geometry_shader *shader, shader->in_prim_idx = 0; shader->input_vertex_stride = input_stride; shader->input = input; - if (shader->primitive_lengths) { - FREE(shader->primitive_lengths); - } + FREE(shader->primitive_lengths); shader->primitive_lengths = MALLOC(max_out_prims * sizeof(unsigned)); tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS, diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index fe96e5c9d49..453cf45b86e 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -287,8 +287,7 @@ if(mm->heap) u_mmDestroy(mm->heap); if(mm->map) pb_unmap(mm->buffer); - if(mm) - FREE(mm); + FREE(mm); return NULL; } diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index a8e9a34d519..67a19fe8a68 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c @@ -311,13 +311,11 @@ pool_bufmgr_create(struct pb_manager *provider, return SUPER(pool); failure: - if(pool->bufs) - FREE(pool->bufs); + FREE(pool->bufs); if(pool->map) pb_unmap(pool->buffer); if(pool->buffer) pb_reference(&pool->buffer, NULL); - if(pool) - FREE(pool); + FREE(pool); return NULL; } diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 5e23f5da65b..68bb598cf3c 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -653,15 +653,11 @@ tgsi_exec_machine_bind_shader( if (!tokens) { /* unbind and free all */ - if (mach->Declarations) { - FREE( mach->Declarations ); - } + FREE(mach->Declarations); mach->Declarations = NULL; mach->NumDeclarations = 0; - if (mach->Instructions) { - FREE( mach->Instructions ); - } + FREE(mach->Instructions); mach->Instructions = NULL; mach->NumInstructions = 0; @@ -804,15 +800,11 @@ tgsi_exec_machine_bind_shader( } tgsi_parse_free (&parse); - if (mach->Declarations) { - FREE( mach->Declarations ); - } + FREE(mach->Declarations); mach->Declarations = declarations; mach->NumDeclarations = numDeclarations; - if (mach->Instructions) { - FREE( mach->Instructions ); - } + FREE(mach->Instructions); mach->Instructions = instructions; mach->NumInstructions = numInstructions; } @@ -875,10 +867,8 @@ void tgsi_exec_machine_destroy(struct tgsi_exec_machine *mach) { if (mach) { - if (mach->Instructions) - FREE(mach->Instructions); - if (mach->Declarations) - FREE(mach->Declarations); + FREE(mach->Instructions); + FREE(mach->Declarations); align_free(mach->Inputs); align_free(mach->Outputs); diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index 469c874988d..81c4f107ea9 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -151,6 +151,5 @@ out: if (vbuf) pipe_resource_reference(&vbuf, NULL); - if (v) - FREE(v); + FREE(v); } diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c index 6f452983592..a41c468a95d 100644 --- a/src/gallium/auxiliary/util/u_format.c +++ b/src/gallium/auxiliary/util/u_format.c @@ -618,13 +618,9 @@ util_format_translate(enum pipe_format dst_format, src_row += src_step; } - if (tmp_s) { - FREE(tmp_s); - } + FREE(tmp_s); - if (tmp_z) { - FREE(tmp_z); - } + FREE(tmp_z); return; } |