diff options
| author | Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> | 2025-10-15 11:25:23 -0400 |
|---|---|---|
| committer | Marge Bot <marge-bot@fdo.invalid> | 2025-10-15 23:01:33 +0000 |
| commit | 84d8e6824bec126074ebcab5b0857b629d49e70a (patch) | |
| tree | 33a23955fc18ca6f26ed3623eff44b694b60b74e | |
| parent | 543c9be87abcbaf99c192ec80cce3d90be0a4fc5 (diff) | |
treewide: don't check before free
This was something that came up in the slop MR. Not sure it's actually a
good idea or not but kind of curious what people think, given we have a
sound tool (Coccinelle) to do the transform. Saves a redundant branch
but means extra noninlined function calls.. likely no actual perf impact
but saves some code.
Via Coccinelle patches:
@@
expression ptr;
@@
-if (ptr) {
-free(ptr);
-}
+free(ptr);
@@
expression ptr;
@@
-if (ptr) {
-FREE(ptr);
-}
+FREE(ptr);
@@
expression ptr;
@@
-if (ptr) {
-ralloc_free(ptr);
-}
+ralloc_free(ptr);
@@
expression ptr;
@@
-if (ptr != NULL) {
-free(ptr);
-}
-
+free(ptr);
@@
expression ptr;
@@
-if (ptr != NULL) {
-FREE(ptr);
-}
-
+FREE(ptr);
@@
expression ptr;
@@
-if (ptr != NULL) {
-ralloc_free(ptr);
-}
-
+ralloc_free(ptr);
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> [v3d]
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org> [venus]
Reviewed-by: Frank Binns <frank.binns@imgtec.com> [powervr]
Reviewed-by: Janne Grunau <j@jannau.net> [asahi]
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> [radv]
Reviewed-by: Job Noorman <jnoorman@igalia.com> [ir3]
Acked-by: Marek Olšák <maraeo@gmail.com>
Acked-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Acked-by: Job Noorman <jnoorman@igalia.com>
Acked-by: Yonggang Luo <luoyonggang@gmail.com>
Acked-by: Christian Gmeiner <cgmeiner@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37892>
53 files changed, 84 insertions, 183 deletions
diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index fe828239d21..8c064d96f78 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2997,8 +2997,7 @@ radv_graphics_pipeline_state_finish(struct radv_device *device, struct radv_grap for (uint32_t i = 0; i < MESA_VULKAN_SHADER_STAGES; i++) ralloc_free(gfx_state->stages[i].nir); - if (gfx_state->stages[MESA_SHADER_GEOMETRY].gs_copy_shader) - ralloc_free(gfx_state->stages[MESA_SHADER_GEOMETRY].gs_copy_shader); + ralloc_free(gfx_state->stages[MESA_SHADER_GEOMETRY].gs_copy_shader); free(gfx_state->stages); } diff --git a/src/amd/vulkan/radv_shader_object.c b/src/amd/vulkan/radv_shader_object.c index 496444704d0..f4190d31420 100644 --- a/src/amd/vulkan/radv_shader_object.c +++ b/src/amd/vulkan/radv_shader_object.c @@ -167,8 +167,7 @@ radv_shader_object_init_graphics(struct radv_shader_object *shader_obj, struct r binary = binaries[stage]; ralloc_free(stages[stage].nir); - if (stages[MESA_SHADER_GEOMETRY].gs_copy_shader) - ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader); + ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader); shader_obj->shader = shader; shader_obj->binary = binary; @@ -196,8 +195,7 @@ radv_shader_object_init_graphics(struct radv_shader_object *shader_obj, struct r binary = binaries[stage]; ralloc_free(stages[stage].nir); - if (stages[MESA_SHADER_GEOMETRY].gs_copy_shader) - ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader); + ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader); if (stage == MESA_SHADER_VERTEX) { if (next_stage == MESA_SHADER_TESS_CTRL) { @@ -549,8 +547,7 @@ radv_shader_object_create_linked(VkDevice _device, uint32_t createInfoCount, con pShaders[i] = radv_shader_object_to_handle(shader_obj); } - if (stages[MESA_SHADER_GEOMETRY].gs_copy_shader) - ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader); + ralloc_free(stages[MESA_SHADER_GEOMETRY].gs_copy_shader); return VK_SUCCESS; } diff --git a/src/asahi/compiler/agx_liveness.c b/src/asahi/compiler/agx_liveness.c index fc4b8c8be0a..dc84ee370c4 100644 --- a/src/asahi/compiler/agx_liveness.c +++ b/src/asahi/compiler/agx_liveness.c @@ -46,11 +46,8 @@ agx_compute_liveness(agx_context *ctx) unsigned words = BITSET_WORDS(ctx->alloc); agx_foreach_block(ctx, block) { - if (block->live_in) - ralloc_free(block->live_in); - - if (block->live_out) - ralloc_free(block->live_out); + ralloc_free(block->live_in); + ralloc_free(block->live_out); block->live_in = rzalloc_array(block, BITSET_WORD, words); block->live_out = rzalloc_array(block, BITSET_WORD, words); diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 22833d8c661..de8d4a2b674 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -123,8 +123,7 @@ v3dv_destroy_pipeline(struct v3dv_pipeline *pipeline, pipeline->default_attribute_values = NULL; } - if (pipeline->executables.mem_ctx) - ralloc_free(pipeline->executables.mem_ctx); + ralloc_free(pipeline->executables.mem_ctx); if (pipeline->layout) v3dv_pipeline_layout_unref(device, pipeline->layout, pAllocator); diff --git a/src/compiler/nir/nir_gather_output_deps.c b/src/compiler/nir/nir_gather_output_deps.c index 2fa689b8c7f..41ab1f4960f 100644 --- a/src/compiler/nir/nir_gather_output_deps.c +++ b/src/compiler/nir/nir_gather_output_deps.c @@ -338,8 +338,7 @@ nir_free_output_dependencies(nir_output_deps *deps) { for (unsigned i = 0; i < ARRAY_SIZE(deps->output); i++) { assert(!!deps->output[i].instr_list == !!deps->output[i].num_instr); - if (deps->output[i].instr_list) - free(deps->output[i].instr_list); + free(deps->output[i].instr_list); } } diff --git a/src/compiler/nir/nir_loop_analyze.c b/src/compiler/nir/nir_loop_analyze.c index 8c9752b30b7..aa7369c4058 100644 --- a/src/compiler/nir/nir_loop_analyze.c +++ b/src/compiler/nir/nir_loop_analyze.c @@ -1382,8 +1382,7 @@ get_loop_info(loop_info_state *state, nir_function_impl *impl) static void initialize_loop_info(nir_loop *loop) { - if (loop->info) - ralloc_free(loop->info); + ralloc_free(loop->info); loop->info = rzalloc(loop, nir_loop_info); loop->info->induction_vars = _mesa_pointer_hash_table_create(loop->info); diff --git a/src/freedreno/common/freedreno_rd_output.c b/src/freedreno/common/freedreno_rd_output.c index adb446a271c..de196f5b6cb 100644 --- a/src/freedreno/common/freedreno_rd_output.c +++ b/src/freedreno/common/freedreno_rd_output.c @@ -190,8 +190,7 @@ fd_rd_output_init(struct fd_rd_output *output, const char* output_name) void fd_rd_output_fini(struct fd_rd_output *output) { - if (output->name != NULL) - free(output->name); + free(output->name); if (output->file != NULL) { assert(output->combine); diff --git a/src/freedreno/ir3/ir3_lower_parallelcopy.c b/src/freedreno/ir3/ir3_lower_parallelcopy.c index 687fe710ec6..5441fef27b4 100644 --- a/src/freedreno/ir3/ir3_lower_parallelcopy.c +++ b/src/freedreno/ir3/ir3_lower_parallelcopy.c @@ -608,6 +608,5 @@ ir3_lower_copies(struct ir3_shader_variant *v) } } - if (copies) - ralloc_free(copies); + ralloc_free(copies); } diff --git a/src/freedreno/ir3/ir3_shared_ra.c b/src/freedreno/ir3/ir3_shared_ra.c index 7f98b3a4452..6c7c4d5ea4d 100644 --- a/src/freedreno/ir3/ir3_shared_ra.c +++ b/src/freedreno/ir3/ir3_shared_ra.c @@ -1498,8 +1498,7 @@ ir3_ra_shared(struct ir3_shader_variant *v, struct ir3_liveness **live_ptr) lower_pcopy(v->ir, &ctx); for (unsigned i = 0; i < live->block_count; i++) { - if (ctx.blocks[i].live_out) - ralloc_free(ctx.blocks[i].live_out); + ralloc_free(ctx.blocks[i].live_out); } ralloc_free(ctx.intervals); diff --git a/src/freedreno/vulkan/tu_device.cc b/src/freedreno/vulkan/tu_device.cc index b21eda366cb..40b4934f971 100644 --- a/src/freedreno/vulkan/tu_device.cc +++ b/src/freedreno/vulkan/tu_device.cc @@ -3121,9 +3121,7 @@ tu_DestroyDevice(VkDevice _device, const VkAllocationCallbacks *pAllocator) tu_cs_finish(&device->sub_cs); - if (device->perfcntrs_pass_cs_entries) { - free(device->perfcntrs_pass_cs_entries); - } + free(device->perfcntrs_pass_cs_entries); if (device->dbg_cmdbuf_stomp_cs) { tu_cs_finish(device->dbg_cmdbuf_stomp_cs); diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 2d0053ab0b9..8bf477b1d67 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -2252,8 +2252,7 @@ draw_llvm_destroy_variant(struct draw_llvm_variant *variant) variant->shader->variants_cached--; list_del(&variant->list_item_global.list); llvm->nr_variants--; - if(variant->function_name) - FREE(variant->function_name); + FREE(variant->function_name); FREE(variant); } @@ -2582,8 +2581,7 @@ draw_gs_llvm_destroy_variant(struct draw_gs_llvm_variant *variant) variant->shader->variants_cached--; list_del(&variant->list_item_global.list); llvm->nr_gs_variants--; - if(variant->function_name) - FREE(variant->function_name); + FREE(variant->function_name); FREE(variant); } @@ -3257,8 +3255,7 @@ draw_tcs_llvm_destroy_variant(struct draw_tcs_llvm_variant *variant) variant->shader->variants_cached--; list_del(&variant->list_item_global.list); llvm->nr_tcs_variants--; - if(variant->function_name) - FREE(variant->function_name); + FREE(variant->function_name); FREE(variant); } @@ -3797,8 +3794,7 @@ draw_tes_llvm_destroy_variant(struct draw_tes_llvm_variant *variant) variant->shader->variants_cached--; list_del(&variant->list_item_global.list); llvm->nr_tes_variants--; - if(variant->function_name) - FREE(variant->function_name); + FREE(variant->function_name); FREE(variant); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 749890aa0a6..a76a790a85d 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -730,9 +730,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle, FREE(gs_vert_info[i].verts); } - if (patch_lengths) { - FREE(patch_lengths); - } + FREE(patch_lengths); if (free_prim_info) { FREE(tes_elts_out); diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c index 7c3e6f4ea81..af0079c80d2 100644 --- a/src/gallium/auxiliary/draw/draw_vs_llvm.c +++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c @@ -76,8 +76,7 @@ vs_llvm_delete(struct draw_vertex_shader *dvs) } assert(shader->variants_cached == 0); - if (dvs->state.ir.nir) - ralloc_free(dvs->state.ir.nir); + ralloc_free(dvs->state.ir.nir); FREE((void*) dvs->state.tokens); FREE(dvs); } diff --git a/src/gallium/drivers/asahi/agx_batch.c b/src/gallium/drivers/asahi/agx_batch.c index 9b3dd959939..892b3d9c0fb 100644 --- a/src/gallium/drivers/asahi/agx_batch.c +++ b/src/gallium/drivers/asahi/agx_batch.c @@ -976,8 +976,7 @@ agx_batch_submit(struct agx_context *ctx, struct agx_batch *batch, util_dynarray_fini(&cmdbuf); agx_batch_mark_submitted(batch); - if (virt.extres) - free(virt.extres); + free(virt.extres); /* Record the last syncobj for fence creation */ ctx->syncobj = batch->syncobj; diff --git a/src/gallium/drivers/lima/ir/pp/codegen.c b/src/gallium/drivers/lima/ir/pp/codegen.c index 6c8d40c4f94..dd04c4b1e05 100644 --- a/src/gallium/drivers/lima/ir/pp/codegen.c +++ b/src/gallium/drivers/lima/ir/pp/codegen.c @@ -888,8 +888,7 @@ bool ppir_codegen_prog(ppir_compiler *comp) } } - if (comp->prog->shader) - ralloc_free(comp->prog->shader); + ralloc_free(comp->prog->shader); comp->prog->shader = prog; comp->prog->state.shader_size = size * sizeof(uint32_t); diff --git a/src/gallium/drivers/lima/ir/pp/regalloc.c b/src/gallium/drivers/lima/ir/pp/regalloc.c index 2423aa73344..8d7916cc974 100644 --- a/src/gallium/drivers/lima/ir/pp/regalloc.c +++ b/src/gallium/drivers/lima/ir/pp/regalloc.c @@ -527,17 +527,14 @@ static void ppir_regalloc_reset_liveness_info(ppir_compiler *comp) continue; list_for_each_entry(ppir_instr, instr, &block->instr_list, list) { - if (instr->live_mask) - ralloc_free(instr->live_mask); + ralloc_free(instr->live_mask); instr->live_mask = rzalloc_array(comp, uint8_t, reg_mask_size(comp->reg_num)); - if (instr->live_set) - ralloc_free(instr->live_set); + ralloc_free(instr->live_set); instr->live_set = rzalloc_array(comp, BITSET_WORD, comp->reg_num); - if (instr->live_internal) - ralloc_free(instr->live_internal); + ralloc_free(instr->live_internal); instr->live_internal = rzalloc_array(comp, BITSET_WORD, comp->reg_num); } diff --git a/src/gallium/drivers/lima/lima_resource.c b/src/gallium/drivers/lima/lima_resource.c index ba282495514..bb1a314272e 100644 --- a/src/gallium/drivers/lima/lima_resource.c +++ b/src/gallium/drivers/lima/lima_resource.c @@ -304,11 +304,9 @@ lima_resource_destroy(struct pipe_screen *pscreen, struct pipe_resource *pres) if (res->scanout) renderonly_scanout_destroy(res->scanout, screen->ro); - if (res->damage.region) - FREE(res->damage.region); + FREE(res->damage.region); - if (res->index_cache) - FREE(res->index_cache); + FREE(res->index_cache); FREE(res); } @@ -778,8 +776,7 @@ lima_transfer_unmap(struct pipe_context *pctx, struct pipe_box box; u_box_2d(0, 0, ptrans->box.width, ptrans->box.height, &box); lima_transfer_flush_region(pctx, ptrans, &box); - if (trans->staging) - free(trans->staging); + free(trans->staging); if (ptrans->usage & PIPE_MAP_WRITE) { pan_minmax_cache_invalidate(res->index_cache, util_format_get_blocksize(res->base.format), diff --git a/src/gallium/drivers/llvmpipe/lp_state_cs.c b/src/gallium/drivers/llvmpipe/lp_state_cs.c index 916cf362c2e..ea00ab9d988 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_cs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_cs.c @@ -1069,8 +1069,7 @@ llvmpipe_remove_cs_shader_variant(struct llvmpipe_context *lp, lp->nr_cs_variants--; lp->nr_cs_instrs -= variant->nr_instrs; - if(variant->function_name) - FREE(variant->function_name); + FREE(variant->function_name); FREE(variant); } diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 5e1384210b8..889cd7c7ab0 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -4215,12 +4215,9 @@ llvmpipe_destroy_shader_variant(struct llvmpipe_context *lp, { gallivm_destroy(variant->gallivm); lp_fs_reference(lp, &variant->shader, NULL); - if (variant->function_name[RAST_EDGE_TEST]) - FREE(variant->function_name[RAST_EDGE_TEST]); - if (variant->function_name[RAST_WHOLE]) - FREE(variant->function_name[RAST_WHOLE]); - if (variant->linear_function_name) - FREE(variant->linear_function_name); + FREE(variant->function_name[RAST_EDGE_TEST]); + FREE(variant->function_name[RAST_WHOLE]); + FREE(variant->linear_function_name); FREE(variant); } diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 1d406e4a341..dca5513baa5 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -464,8 +464,7 @@ panfrost_set_resource_label(UNUSED struct pipe_screen *pscreen, return; char *old_label = (char *)panfrost_bo_set_label(rsrc->bo, new_label); - if (old_label) - free(old_label); + free(old_label); } static bool diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index 951e8ca684d..731041f4ad1 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -158,8 +158,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx, { glsl_type_singleton_init_or_ref(); if (sel->ir_type == PIPE_SHADER_IR_TGSI) { - if (sel->nir) - ralloc_free(sel->nir); + ralloc_free(sel->nir); if (sel->nir_blob) { free(sel->nir_blob); sel->nir_blob = NULL; @@ -311,8 +310,7 @@ void r600_pipe_shader_destroy(struct pipe_context *ctx UNUSED, struct r600_pipe_ r600_bytecode_clear(&shader->shader.bc); r600_release_command_buffer(&shader->command_buffer); - if (shader->shader.arrays) - free(shader->shader.arrays); + free(shader->shader.arrays); } struct r600_shader_ctx { diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c index 06845b85238..93d1160e5e4 100644 --- a/src/gallium/drivers/r600/r600_state_common.c +++ b/src/gallium/drivers/r600/r600_state_common.c @@ -1157,13 +1157,11 @@ void r600_delete_shader_selector(struct pipe_context *ctx, if (sel->ir_type == PIPE_SHADER_IR_TGSI) { free(sel->tokens); /* We might have converted the TGSI shader to a NIR shader */ - if (sel->nir) - ralloc_free(sel->nir); + ralloc_free(sel->nir); } else if (sel->ir_type == PIPE_SHADER_IR_NIR) ralloc_free(sel->nir); - if (sel->nir_blob) - free(sel->nir_blob); + free(sel->nir_blob); free(sel); } diff --git a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c index 8fdfe3583ee..7b3b7eb90c9 100644 --- a/src/gallium/drivers/radeonsi/radeon_vcn_dec.c +++ b/src/gallium/drivers/radeonsi/radeon_vcn_dec.c @@ -3186,10 +3186,8 @@ error: si_vid_destroy_buffer(&dec->sessionctx); err: - if (dec->jcs) - FREE(dec->jcs); - if (dec->jctx) - FREE(dec->jctx); + FREE(dec->jcs); + FREE(dec->jctx); FREE(dec); return NULL; diff --git a/src/gallium/drivers/radeonsi/si_sqtt.c b/src/gallium/drivers/radeonsi/si_sqtt.c index 4d252ca0570..8ad7e747be1 100644 --- a/src/gallium/drivers/radeonsi/si_sqtt.c +++ b/src/gallium/drivers/radeonsi/si_sqtt.c @@ -370,8 +370,7 @@ void si_destroy_sqtt(struct si_context *sctx) struct pb_buffer_lean *bo = sctx->sqtt->bo; radeon_bo_reference(sctx->screen->ws, &bo, NULL); - if (sctx->sqtt->trigger_file) - free(sctx->sqtt->trigger_file); + free(sctx->sqtt->trigger_file); for (int i = 0; i < ARRAY_SIZE(sctx->sqtt->start_cs); i++) { sscreen->ws->cs_destroy(sctx->sqtt->start_cs[i]); diff --git a/src/gallium/drivers/radeonsi/si_vpe.c b/src/gallium/drivers/radeonsi/si_vpe.c index fd1e227f12a..8a327fa7347 100644 --- a/src/gallium/drivers/radeonsi/si_vpe.c +++ b/src/gallium/drivers/radeonsi/si_vpe.c @@ -891,8 +891,7 @@ si_vpe_processor_destroy(struct pipe_video_codec *codec) vpe_destroy(&vpeproc->vpe_handle); if (vpeproc->vpe_build_param) { - if (vpeproc->vpe_build_param->streams) - FREE(vpeproc->vpe_build_param->streams); + FREE(vpeproc->vpe_build_param->streams); FREE(vpeproc->vpe_build_param); } @@ -906,14 +905,11 @@ si_vpe_processor_destroy(struct pipe_video_codec *codec) if (vpeproc->gm_handle) tm_destroy(&vpeproc->gm_handle); - if (vpeproc->lut_data) - FREE(vpeproc->lut_data); + FREE(vpeproc->lut_data); - if (vpeproc->geometric_scaling_ratios) - FREE(vpeproc->geometric_scaling_ratios); + FREE(vpeproc->geometric_scaling_ratios); - if (vpeproc->lanczos_info) - FREE(vpeproc->lanczos_info); + FREE(vpeproc->lanczos_info); if (vpeproc->geometric_buf[0]) vpeproc->geometric_buf[0]->destroy(vpeproc->geometric_buf[0]); diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index 44775527c9a..85e9b96ccb9 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -1113,10 +1113,8 @@ svga_texture_create(struct pipe_screen *screen, return &tex->b; fail: - if (tex->dirty) - FREE(tex->dirty); - if (tex->defined) - FREE(tex->defined); + FREE(tex->dirty); + FREE(tex->defined); FREE(tex); fail_notex: SVGA_STATS_TIME_POP(svgascreen->sws); diff --git a/src/gallium/drivers/svga/svga_state_tgsi_transform.c b/src/gallium/drivers/svga/svga_state_tgsi_transform.c index 0497de7a4c5..5c3737eb9a9 100644 --- a/src/gallium/drivers/svga/svga_state_tgsi_transform.c +++ b/src/gallium/drivers/svga/svga_state_tgsi_transform.c @@ -192,8 +192,7 @@ transform_dynamic_indexing(struct svga_context *svga, } transform_shader->token_key = key; bind_shader(svga, info->processor, transform_shader); - if (new_tokens) - FREE(new_tokens); + FREE(new_tokens); } diff --git a/src/gallium/drivers/v3d/v3d_query.c b/src/gallium/drivers/v3d/v3d_query.c index 797e1677b60..2a77b6aef87 100644 --- a/src/gallium/drivers/v3d/v3d_query.c +++ b/src/gallium/drivers/v3d/v3d_query.c @@ -223,9 +223,7 @@ multisync_set(struct v3d_context *v3d, struct drm_v3d_multi_sync *ms, out: fprintf(stderr, "Multisync Set Failed\n"); - if (in_syncs) { - free(in_syncs); - } + free(in_syncs); } static void diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c index d5646e9660b..ce4e9f67659 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c @@ -1726,8 +1726,7 @@ static struct pb_buffer_lean *amdgpu_bo_from_handle(struct radeon_winsys *rws, error: simple_mtx_unlock(&aws->bo_export_table_lock); - if (bo) - FREE(bo); + FREE(bo); if (va_handle) ac_drm_va_range_free(va_handle); ac_drm_bo_free(aws->dev, result.bo); diff --git a/src/imagination/vulkan/pvr_device.c b/src/imagination/vulkan/pvr_device.c index 37495983e17..bfb499ab2d8 100644 --- a/src/imagination/vulkan/pvr_device.c +++ b/src/imagination/vulkan/pvr_device.c @@ -947,8 +947,7 @@ static void pvr_physical_device_destroy(struct vk_physical_device *vk_pdevice) * before freeing or that the freeing functions accept NULL pointers. */ - if (pdevice->pco_ctx) - ralloc_free(pdevice->pco_ctx); + ralloc_free(pdevice->pco_ctx); pvr_wsi_finish(pdevice); diff --git a/src/imagination/vulkan/pvr_pipeline.c b/src/imagination/vulkan/pvr_pipeline.c index 3cca3d95ca4..7bd98284380 100644 --- a/src/imagination/vulkan/pvr_pipeline.c +++ b/src/imagination/vulkan/pvr_pipeline.c @@ -1204,9 +1204,9 @@ pvr_CreateComputePipelines(VkDevice _device, static void pvr_pipeline_destroy_shader_data(pco_data *data) { - for (unsigned u = 0; u < ARRAY_SIZE(data->common.desc_sets); ++u) - if (data->common.desc_sets[u].bindings) - ralloc_free(data->common.desc_sets[u].bindings); + for (unsigned u = 0; u < ARRAY_SIZE(data->common.desc_sets); ++u) { + ralloc_free(data->common.desc_sets[u].bindings); + } } static void diff --git a/src/intel/compiler/brw/brw_asm_tool.c b/src/intel/compiler/brw/brw_asm_tool.c index 3716e261d42..d9d7aad2a8d 100644 --- a/src/intel/compiler/brw/brw_asm_tool.c +++ b/src/intel/compiler/brw/brw_asm_tool.c @@ -267,8 +267,7 @@ end: ralloc_free(mem_ctx); - if (devinfo) - free(devinfo); + free(devinfo); exit(result); } diff --git a/src/intel/compiler/elk/elk_asm_tool.c b/src/intel/compiler/elk/elk_asm_tool.c index d1949cfd1bd..6ac87a94bf3 100644 --- a/src/intel/compiler/elk/elk_asm_tool.c +++ b/src/intel/compiler/elk/elk_asm_tool.c @@ -375,11 +375,9 @@ end: if (output) fclose(output); - if (p) - ralloc_free(p); + ralloc_free(p); - if (devinfo) - free(devinfo); + free(devinfo); exit(result); } diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c index f7e78e3ac53..570f4d90fc2 100644 --- a/src/intel/tools/aubinator_error_decode.c +++ b/src/intel/tools/aubinator_error_decode.c @@ -866,8 +866,7 @@ main(int argc, char *argv[]) close(1); wait(NULL); - if (xml_path) - free(xml_path); + free(xml_path); return EXIT_SUCCESS; } diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c index e466d4e9053..e93d9fcd270 100644 --- a/src/mesa/main/pipelineobj.c +++ b/src/mesa/main/pipelineobj.c @@ -866,8 +866,7 @@ _mesa_validate_program_pipeline(struct gl_context* ctx, /* Release and reset the info log. */ - if (pipe->InfoLog != NULL) - ralloc_free(pipe->InfoLog); + ralloc_free(pipe->InfoLog); pipe->InfoLog = NULL; diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 6c13c2060cd..7abe295d029 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1614,9 +1614,7 @@ validate_program(struct gl_context *ctx, GLuint program) shProg->data->Validated = validate_shader_program(shProg, errMsg); if (!shProg->data->Validated) { /* update info log */ - if (shProg->data->InfoLog) { - ralloc_free(shProg->data->InfoLog); - } + ralloc_free(shProg->data->InfoLog); shProg->data->InfoLog = ralloc_strdup(shProg->data, errMsg); } } diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index c7821b1241d..fe8c7674db9 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -259,22 +259,10 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog) _mesa_free_parameter_list(prog->Parameters); } - if (prog->nir) { - ralloc_free(prog->nir); - } - - if (prog->sh.BindlessSamplers) { - ralloc_free(prog->sh.BindlessSamplers); - } - - if (prog->sh.BindlessImages) { - ralloc_free(prog->sh.BindlessImages); - } - - if (prog->driver_cache_blob) { - ralloc_free(prog->driver_cache_blob); - } - + ralloc_free(prog->nir); + ralloc_free(prog->sh.BindlessSamplers); + ralloc_free(prog->sh.BindlessImages); + ralloc_free(prog->driver_cache_blob); ralloc_free(prog); } diff --git a/src/mesa/program/program_parse.y b/src/mesa/program/program_parse.y index 736adfae8b4..15c46e830e3 100644 --- a/src/mesa/program/program_parse.y +++ b/src/mesa/program/program_parse.y @@ -2530,9 +2530,7 @@ yyerror(YYLTYPE *locp, struct asm_parser_state *state, const char *s) locp->first_line, locp->first_column, s); _mesa_set_program_error(state->ctx, locp->position, err_str); - if (err_str) { - free(err_str); - } + free(err_str); } diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c index ec43765c85a..3632411307b 100644 --- a/src/mesa/vbo/vbo_save.c +++ b/src/mesa/vbo/vbo_save.c @@ -72,8 +72,7 @@ void vbo_save_destroy( struct gl_context *ctx ) save->vertex_store = NULL; } - if (save->copied.buffer) - free(save->copied.buffer); + free(save->copied.buffer); _mesa_reference_buffer_object(ctx, &save->current_bo, NULL); } diff --git a/src/panfrost/compiler/bi_liveness.c b/src/panfrost/compiler/bi_liveness.c index e5271c54551..e0d9a2b884b 100644 --- a/src/panfrost/compiler/bi_liveness.c +++ b/src/panfrost/compiler/bi_liveness.c @@ -51,11 +51,8 @@ bi_compute_liveness_ssa(bi_context *ctx) unsigned words = BITSET_WORDS(ctx->ssa_alloc); bi_foreach_block(ctx, block) { - if (block->ssa_live_in) - ralloc_free(block->ssa_live_in); - - if (block->ssa_live_out) - ralloc_free(block->ssa_live_out); + ralloc_free(block->ssa_live_in); + ralloc_free(block->ssa_live_out); block->ssa_live_in = rzalloc_array(block, BITSET_WORD, words); block->ssa_live_out = rzalloc_array(block, BITSET_WORD, words); diff --git a/src/panfrost/compiler/bi_ra.c b/src/panfrost/compiler/bi_ra.c index fe981c3a0e8..362bee4fdb7 100644 --- a/src/panfrost/compiler/bi_ra.c +++ b/src/panfrost/compiler/bi_ra.c @@ -255,11 +255,8 @@ bi_compute_liveness_ra(bi_context *ctx) bi_worklist_init(ctx, &worklist); bi_foreach_block(ctx, block) { - if (block->live_in) - ralloc_free(block->live_in); - - if (block->live_out) - ralloc_free(block->live_out); + ralloc_free(block->live_in); + ralloc_free(block->live_out); block->live_in = rzalloc_array(block, uint8_t, ctx->ssa_alloc); block->live_out = rzalloc_array(block, uint8_t, ctx->ssa_alloc); diff --git a/src/panfrost/midgard/midgard_liveness.c b/src/panfrost/midgard/midgard_liveness.c index d1d5f37edb8..abd0df89191 100644 --- a/src/panfrost/midgard/midgard_liveness.c +++ b/src/panfrost/midgard/midgard_liveness.c @@ -117,11 +117,9 @@ mir_free_liveness(compiler_context *ctx) { mir_foreach_block(ctx, _block) { midgard_block *block = (midgard_block *)_block; - if (block->live_in) - ralloc_free(block->live_in); - if (block->live_out) - ralloc_free(block->live_out); + ralloc_free(block->live_in); + ralloc_free(block->live_out); block->live_in = NULL; block->live_out = NULL; diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c index 147f4136f34..d86153a8a43 100644 --- a/src/util/disk_cache.c +++ b/src/util/disk_cache.c @@ -208,8 +208,7 @@ disk_cache_type_create(const char *gpu_name, return cache; fail: - if (cache) - ralloc_free(cache); + ralloc_free(cache); ralloc_free(local); return NULL; diff --git a/src/util/disk_cache_os.c b/src/util/disk_cache_os.c index 5310e342e02..41de13d9f10 100644 --- a/src/util/disk_cache_os.c +++ b/src/util/disk_cache_os.c @@ -624,8 +624,7 @@ parse_and_validate_cache_item(struct disk_cache *cache, void *cache_item, return uncompressed_data; fail: - if (uncompressed_data) - free(uncompressed_data); + free(uncompressed_data); return NULL; } @@ -664,10 +663,8 @@ disk_cache_load_item(struct disk_cache *cache, char *filename, size_t *size) return uncompressed_data; fail: - if (data) - free(data); - if (filename) - free(filename); + free(data); + free(filename); if (fd != -1) close(fd); diff --git a/src/util/hash_table.c b/src/util/hash_table.c index 9cf2e2c37f1..e6bd3b9e3b7 100644 --- a/src/util/hash_table.c +++ b/src/util/hash_table.c @@ -936,8 +936,7 @@ _mesa_hash_table_u64_delete_key(struct hash_entry *entry) struct hash_key_u64 *_key = (struct hash_key_u64 *)entry->key; - if (_key) - FREE(_key); + FREE(_key); } void diff --git a/src/util/mesa_cache_db.c b/src/util/mesa_cache_db.c index 74ed9499153..fd06ccb158a 100644 --- a/src/util/mesa_cache_db.c +++ b/src/util/mesa_cache_db.c @@ -928,8 +928,7 @@ fail_fatal: fail: mesa_db_unlock(db); - if (hash_entry) - ralloc_free(hash_entry); + ralloc_free(hash_entry); return false; } diff --git a/src/util/u_idalloc.c b/src/util/u_idalloc.c index 29e3fe07fdd..d116802822a 100644 --- a/src/util/u_idalloc.c +++ b/src/util/u_idalloc.c @@ -65,8 +65,7 @@ util_idalloc_init(struct util_idalloc *buf, unsigned initial_num_ids) void util_idalloc_fini(struct util_idalloc *buf) { - if (buf->data) - free(buf->data); + free(buf->data); } unsigned diff --git a/src/util/u_process.c b/src/util/u_process.c index 404936de508..6846acd2e0b 100644 --- a/src/util/u_process.c +++ b/src/util/u_process.c @@ -79,9 +79,7 @@ __getProgramName() if (name) program_name = strdup(name + 1); } - if (path) { - free(path); - } + free(path); if (!program_name) { program_name = strdup(arg+1); } diff --git a/src/util/u_range_remap.c b/src/util/u_range_remap.c index 1fd292a58d8..01e4e116de2 100644 --- a/src/util/u_range_remap.c +++ b/src/util/u_range_remap.c @@ -207,8 +207,7 @@ util_create_range_remap() struct range_remap * util_reset_range_remap(struct range_remap *r_remap) { - if (r_remap) - ralloc_free(r_remap); + ralloc_free(r_remap); return util_create_range_remap(); } diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c index a2b55d7af56..f8a39894947 100644 --- a/src/util/xmlconfig.c +++ b/src/util/xmlconfig.c @@ -1284,9 +1284,7 @@ driDestroyOptionInfo(driOptionCache *info) if (info->info) { uint32_t i, size = 1 << info->tableSize; for (i = 0; i < size; ++i) { - if (info->info[i].name) { - free(info->info[i].name); - } + free(info->info[i].name); } free(info->info); } diff --git a/src/virtio/vulkan/vn_cs.c b/src/virtio/vulkan/vn_cs.c index f1a2b27ee15..16d55962de2 100644 --- a/src/virtio/vulkan/vn_cs.c +++ b/src/virtio/vulkan/vn_cs.c @@ -167,8 +167,7 @@ vn_cs_encoder_fini(struct vn_cs_encoder *enc) for (uint32_t i = 0; i < enc->buffer_count; i++) vn_renderer_shmem_unref(enc->instance->renderer, enc->buffers[i].shmem); - if (enc->buffers) - free(enc->buffers); + free(enc->buffers); } /** diff --git a/src/vulkan/runtime/vk_shader.c b/src/vulkan/runtime/vk_shader.c index 7d2ae1f982c..e2fbce35759 100644 --- a/src/vulkan/runtime/vk_shader.c +++ b/src/vulkan/runtime/vk_shader.c @@ -580,8 +580,7 @@ vk_common_CreateShadersEXT(VkDevice _device, } } else { for (uint32_t l = 0; l < linked_count; l++) { - if (infos[l].nir != NULL) - ralloc_free(infos[l].nir); + ralloc_free(infos[l].nir); } } diff --git a/src/vulkan/screenshot-layer/screenshot.cpp b/src/vulkan/screenshot-layer/screenshot.cpp index c6f9becb0f7..f2a258e91ab 100644 --- a/src/vulkan/screenshot-layer/screenshot.cpp +++ b/src/vulkan/screenshot-layer/screenshot.cpp @@ -878,10 +878,8 @@ cleanup: png_destroy_write_struct(&png, &info); if (file) fclose(file); - if (filename) - free(filename); - if (tmpFilename) - free(tmpFilename); + free(filename); + free(tmpFilename); return nullptr; } |