diff options
author | Edward O'Callaghan <[email protected]> | 2015-12-04 22:08:22 +1100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2015-12-06 17:10:23 +0100 |
commit | 13eb5f596bc8ece3d1805b388aa53917e6158d7b (patch) | |
tree | da4ab5c8fd897b317d7f66004fdd22cd02ebe84c /src/gallium/drivers/radeonsi | |
parent | 150c289f6067cb1ba4572f9124948a94ef94c839 (diff) |
gallium/drivers: Sanitize NULL checks into canonical form
Use NULL tests of the form `if (ptr)' or `if (!ptr)'.
They do not depend on the definition of the symbol NULL.
Further, they provide the opportunity for the accidental
assignment, are clear and succinct.
Signed-off-by: Edward O'Callaghan <[email protected]>
Signed-off-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_descriptors.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pipe.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_pm4.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_shaders.c | 12 |
5 files changed, 19 insertions, 19 deletions
diff --git a/src/gallium/drivers/radeonsi/si_descriptors.c b/src/gallium/drivers/radeonsi/si_descriptors.c index 3fa3a9bbd6e..b3719dea252 100644 --- a/src/gallium/drivers/radeonsi/si_descriptors.c +++ b/src/gallium/drivers/radeonsi/si_descriptors.c @@ -416,7 +416,7 @@ static bool si_upload_vertex_buffer_descriptors(struct si_context *sctx) vb = &sctx->vertex_buffer[ve->vertex_buffer_index]; rbuffer = (struct r600_resource*)vb->buffer; - if (rbuffer == NULL) { + if (!rbuffer) { memset(desc, 0, 16); continue; } diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c index 81d809b6b9f..46cb035d74c 100644 --- a/src/gallium/drivers/radeonsi/si_pipe.c +++ b/src/gallium/drivers/radeonsi/si_pipe.c @@ -109,7 +109,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen, #endif int shader, i; - if (sctx == NULL) + if (!sctx) return NULL; if (sscreen->b.debug_flags & DBG_CHECK_VM) @@ -520,7 +520,7 @@ static void si_destroy_screen(struct pipe_screen* pscreen) { struct si_screen *sscreen = (struct si_screen *)pscreen; - if (sscreen == NULL) + if (!sscreen) return; if (!sscreen->b.ws->unref(sscreen->b.ws)) @@ -611,7 +611,7 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws) { struct si_screen *sscreen = CALLOC_STRUCT(si_screen); - if (sscreen == NULL) { + if (!sscreen) { return NULL; } diff --git a/src/gallium/drivers/radeonsi/si_pm4.c b/src/gallium/drivers/radeonsi/si_pm4.c index c4ef2e78c50..c3032fc45b5 100644 --- a/src/gallium/drivers/radeonsi/si_pm4.c +++ b/src/gallium/drivers/radeonsi/si_pm4.c @@ -115,7 +115,7 @@ void si_pm4_free_state(struct si_context *sctx, struct si_pm4_state *state, unsigned idx) { - if (state == NULL) + if (!state) return; if (idx != ~0 && sctx->emitted.array[idx] == state) { diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c index 5b71389c6aa..9f9f3d6610b 100644 --- a/src/gallium/drivers/radeonsi/si_state.c +++ b/src/gallium/drivers/radeonsi/si_state.c @@ -356,7 +356,7 @@ static void *si_create_blend_state_mode(struct pipe_context *ctx, uint32_t color_control = 0; - if (blend == NULL) + if (!blend) return NULL; blend->alpha_to_one = state->alpha_to_one; @@ -681,7 +681,7 @@ static void *si_create_rs_state(struct pipe_context *ctx, unsigned tmp, i; float psize_min, psize_max; - if (rs == NULL) { + if (!rs) { return NULL; } @@ -803,7 +803,7 @@ static void si_bind_rs_state(struct pipe_context *ctx, void *state) (struct si_state_rasterizer*)sctx->queued.named.rasterizer; struct si_state_rasterizer *rs = (struct si_state_rasterizer *)state; - if (state == NULL) + if (!state) return; if (sctx->framebuffer.nr_samples > 1 && @@ -897,7 +897,7 @@ static void *si_create_dsa_state(struct pipe_context *ctx, unsigned db_depth_control; uint32_t db_stencil_control = 0; - if (dsa == NULL) { + if (!dsa) { return NULL; } @@ -953,7 +953,7 @@ static void si_bind_dsa_state(struct pipe_context *ctx, void *state) struct si_context *sctx = (struct si_context *)ctx; struct si_state_dsa *dsa = state; - if (state == NULL) + if (!state) return; si_pm4_bind_state(sctx, dsa, dsa); @@ -2419,7 +2419,7 @@ si_create_sampler_view_custom(struct pipe_context *ctx, uint64_t va; unsigned last_layer = state->u.tex.last_layer; - if (view == NULL) + if (!view) return NULL; /* initialize base object */ @@ -2762,7 +2762,7 @@ static void *si_create_sampler_state(struct pipe_context *ctx, unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 2 : 0; unsigned border_color_type, border_color_index = 0; - if (rstate == NULL) { + if (!rstate) { return NULL; } @@ -3291,7 +3291,7 @@ static void si_init_config(struct si_context *sctx) struct si_pm4_state *pm4 = CALLOC_STRUCT(si_pm4_state); int i; - if (pm4 == NULL) + if (!pm4) return; si_pm4_cmd_begin(pm4, PKT3_CONTEXT_CONTROL); diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index ca6b4be3b0b..4555ca450b6 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -100,7 +100,7 @@ static void si_shader_ls(struct si_shader *shader) uint64_t va; pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state); - if (pm4 == NULL) + if (!pm4) return; va = shader->bo->gpu_address; @@ -136,7 +136,7 @@ static void si_shader_hs(struct si_shader *shader) uint64_t va; pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state); - if (pm4 == NULL) + if (!pm4) return; va = shader->bo->gpu_address; @@ -172,7 +172,7 @@ static void si_shader_es(struct si_shader *shader) pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state); - if (pm4 == NULL) + if (!pm4) return; va = shader->bo->gpu_address; @@ -229,7 +229,7 @@ static void si_shader_gs(struct si_shader *shader) pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state); - if (pm4 == NULL) + if (!pm4) return; if (gs_max_vert_out <= 128) { @@ -301,7 +301,7 @@ static void si_shader_vs(struct si_shader *shader) pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state); - if (pm4 == NULL) + if (!pm4) return; /* If this is the GS copy shader, the GS state writes this register. @@ -394,7 +394,7 @@ static void si_shader_ps(struct si_shader *shader) pm4 = shader->pm4 = CALLOC_STRUCT(si_pm4_state); - if (pm4 == NULL) + if (!pm4) return; for (i = 0; i < info->num_inputs; i++) { |