summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorEdward O'Callaghan <[email protected]>2015-12-04 21:26:50 +1100
committerMarek Olšák <[email protected]>2015-12-06 17:10:23 +0100
commit150c289f6067cb1ba4572f9124948a94ef94c839 (patch)
treedd36e1c1546da77b4f539a2256b1f01b8c97936c /src/gallium/auxiliary/draw
parent147fd00bb36917f8463aacd49a26e95ca0926255 (diff)
gallium/auxiliary: 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/auxiliary/draw')
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_gs.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_llvm.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c18
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aapoint.c6
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_clip.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_cull.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_flatshade.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_offset.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_stipple.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_twoside.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_unfilled.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_util.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_validate.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_vbuf.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_line.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_point.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_fetch_emit.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_llvm.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_variant.c2
23 files changed, 35 insertions, 35 deletions
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index ee009c1fb71..16a261c14cf 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -72,7 +72,7 @@ draw_create_context(struct pipe_context *pipe, void *context,
boolean try_llvm)
{
struct draw_context *draw = CALLOC_STRUCT( draw_context );
- if (draw == NULL)
+ if (!draw)
goto err_out;
/* we need correct cpu caps for disabling denorms in draw_vbo() */
diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c
index c827a68ea0a..6b33341ce6c 100644
--- a/src/gallium/auxiliary/draw/draw_gs.c
+++ b/src/gallium/auxiliary/draw/draw_gs.c
@@ -734,7 +734,7 @@ draw_create_geometry_shader(struct draw_context *draw,
if (use_llvm) {
llvm_gs = CALLOC_STRUCT(llvm_geometry_shader);
- if (llvm_gs == NULL)
+ if (!llvm_gs)
return NULL;
gs = &llvm_gs->base;
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c
index 8435991fb6b..ee974243b3e 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -551,7 +551,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
variant = MALLOC(sizeof *variant +
shader->variant_key_size -
sizeof variant->key);
- if (variant == NULL)
+ if (!variant)
return NULL;
variant->llvm = llvm;
@@ -2224,7 +2224,7 @@ draw_gs_llvm_create_variant(struct draw_llvm *llvm,
variant = MALLOC(sizeof *variant +
shader->variant_key_size -
sizeof variant->key);
- if (variant == NULL)
+ if (!variant)
return NULL;
variant->llvm = llvm;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 85d24b7a6a1..337fb0fadda 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -429,7 +429,7 @@ aaline_create_texture(struct aaline_stage *aaline)
PIPE_TRANSFER_WRITE,
&box, &transfer);
- if (data == NULL)
+ if (!data)
return FALSE;
for (i = 0; i < size; i++) {
@@ -774,7 +774,7 @@ static struct aaline_stage *
draw_aaline_stage(struct draw_context *draw)
{
struct aaline_stage *aaline = CALLOC_STRUCT(aaline_stage);
- if (aaline == NULL)
+ if (!aaline)
return NULL;
aaline->stage.draw = draw;
@@ -824,12 +824,12 @@ aaline_create_fs_state(struct pipe_context *pipe,
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = NULL;
- if (aaline == NULL)
+ if (!aaline)
return NULL;
aafs = CALLOC_STRUCT(aaline_fragment_shader);
- if (aafs == NULL)
+ if (!aafs)
return NULL;
aafs->state.tokens = tgsi_dup_tokens(fs->tokens);
@@ -847,7 +847,7 @@ aaline_bind_fs_state(struct pipe_context *pipe, void *fs)
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
- if (aaline == NULL) {
+ if (!aaline) {
return;
}
@@ -864,11 +864,11 @@ aaline_delete_fs_state(struct pipe_context *pipe, void *fs)
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
struct aaline_fragment_shader *aafs = (struct aaline_fragment_shader *) fs;
- if (aafs == NULL) {
+ if (!aafs) {
return;
}
- if (aaline != NULL) {
+ if (aaline) {
/* pass-through */
aaline->driver_delete_fs_state(pipe, aafs->driver_fs);
@@ -889,7 +889,7 @@ aaline_bind_sampler_states(struct pipe_context *pipe, unsigned shader,
assert(start == 0);
- if (aaline == NULL) {
+ if (!aaline) {
return;
}
@@ -912,7 +912,7 @@ aaline_set_sampler_views(struct pipe_context *pipe, unsigned shader,
struct aaline_stage *aaline = aaline_stage_from_pipe(pipe);
uint i;
- if (aaline == NULL) {
+ if (!aaline) {
return;
}
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index 063e36828d7..33ef8ec1702 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -662,7 +662,7 @@ static struct aapoint_stage *
draw_aapoint_stage(struct draw_context *draw)
{
struct aapoint_stage *aapoint = CALLOC_STRUCT(aapoint_stage);
- if (aapoint == NULL)
+ if (!aapoint)
goto fail;
aapoint->stage.draw = draw;
@@ -707,7 +707,7 @@ aapoint_create_fs_state(struct pipe_context *pipe,
{
struct aapoint_stage *aapoint = aapoint_stage_from_pipe(pipe);
struct aapoint_fragment_shader *aafs = CALLOC_STRUCT(aapoint_fragment_shader);
- if (aafs == NULL)
+ if (!aafs)
return NULL;
aafs->state.tokens = tgsi_dup_tokens(fs->tokens);
@@ -767,7 +767,7 @@ draw_install_aapoint_stage(struct draw_context *draw,
* Create / install AA point drawing / prim stage
*/
aapoint = draw_aapoint_stage( draw );
- if (aapoint == NULL)
+ if (!aapoint)
return FALSE;
/* save original driver functions */
diff --git a/src/gallium/auxiliary/draw/draw_pipe_clip.c b/src/gallium/auxiliary/draw/draw_pipe_clip.c
index f2b56b017dd..35e54f4a8be 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -915,7 +915,7 @@ static void clip_destroy(struct draw_stage *stage)
struct draw_stage *draw_clip_stage(struct draw_context *draw)
{
struct clip_stage *clipper = CALLOC_STRUCT(clip_stage);
- if (clipper == NULL)
+ if (!clipper)
goto fail;
clipper->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_cull.c b/src/gallium/auxiliary/draw/draw_pipe_cull.c
index fc8293bd128..240f55190f5 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_cull.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_cull.c
@@ -251,7 +251,7 @@ static void cull_destroy( struct draw_stage *stage )
struct draw_stage *draw_cull_stage( struct draw_context *draw )
{
struct cull_stage *cull = CALLOC_STRUCT(cull_stage);
- if (cull == NULL)
+ if (!cull)
goto fail;
cull->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
index 0ea740861d6..cd285e6f97c 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
@@ -309,7 +309,7 @@ static void flatshade_destroy( struct draw_stage *stage )
struct draw_stage *draw_flatshade_stage( struct draw_context *draw )
{
struct flat_stage *flatshade = CALLOC_STRUCT(flat_stage);
- if (flatshade == NULL)
+ if (!flatshade)
goto fail;
flatshade->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index 5e0d8ce793d..f58e32b98a4 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -231,7 +231,7 @@ static void offset_destroy( struct draw_stage *stage )
struct draw_stage *draw_offset_stage( struct draw_context *draw )
{
struct offset_stage *offset = CALLOC_STRUCT(offset_stage);
- if (offset == NULL)
+ if (!offset)
goto fail;
offset->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index a51e91fe931..b58d7530783 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -577,7 +577,7 @@ static struct pstip_stage *
draw_pstip_stage(struct draw_context *draw, struct pipe_context *pipe)
{
struct pstip_stage *pstip = CALLOC_STRUCT(pstip_stage);
- if (pstip == NULL)
+ if (!pstip)
goto fail;
pstip->pipe = pipe;
@@ -742,7 +742,7 @@ draw_install_pstipple_stage(struct draw_context *draw,
* Create / install pgon stipple drawing / prim stage
*/
pstip = draw_pstip_stage( draw, pipe );
- if (pstip == NULL)
+ if (!pstip)
goto fail;
draw->pipeline.pstipple = &pstip->stage;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index 381aa41530b..dcf05aac1d9 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -235,7 +235,7 @@ stipple_destroy( struct draw_stage *stage )
struct draw_stage *draw_stipple_stage( struct draw_context *draw )
{
struct stipple_stage *stipple = CALLOC_STRUCT(stipple_stage);
- if (stipple == NULL)
+ if (!stipple)
goto fail;
stipple->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_twoside.c b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
index 7f958d9b985..52d87c6b291 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_twoside.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_twoside.c
@@ -165,7 +165,7 @@ static void twoside_destroy( struct draw_stage *stage )
struct draw_stage *draw_twoside_stage( struct draw_context *draw )
{
struct twoside_stage *twoside = CALLOC_STRUCT(twoside_stage);
- if (twoside == NULL)
+ if (!twoside)
goto fail;
twoside->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
index 8e6435cdbb4..2517d610e71 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_unfilled.c
@@ -255,7 +255,7 @@ draw_unfilled_prepare_outputs( struct draw_context *draw,
struct draw_stage *draw_unfilled_stage( struct draw_context *draw )
{
struct unfilled_stage *unfilled = CALLOC_STRUCT(unfilled_stage);
- if (unfilled == NULL)
+ if (!unfilled)
goto fail;
unfilled->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_util.c b/src/gallium/auxiliary/draw/draw_pipe_util.c
index cb8c732afe8..53a42a6a0e4 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_util.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_util.c
@@ -78,7 +78,7 @@ boolean draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
unsigned i;
ubyte *store = (ubyte *) MALLOC( MAX_VERTEX_SIZE * nr );
- if (store == NULL)
+ if (!store)
return FALSE;
stage->tmp = (struct vertex_header **) MALLOC( sizeof(struct vertex_header *) * nr );
diff --git a/src/gallium/auxiliary/draw/draw_pipe_validate.c b/src/gallium/auxiliary/draw/draw_pipe_validate.c
index e69d84a37cd..01d07593d5c 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_validate.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_validate.c
@@ -326,7 +326,7 @@ static void validate_destroy( struct draw_stage *stage )
struct draw_stage *draw_validate_stage( struct draw_context *draw )
{
struct draw_stage *stage = CALLOC_STRUCT(draw_stage);
- if (stage == NULL)
+ if (!stage)
return NULL;
stage->draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index 5cc866d7eee..f36706cee01 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -426,7 +426,7 @@ struct draw_stage *draw_vbuf_stage( struct draw_context *draw,
struct vbuf_render *render )
{
struct vbuf_stage *vbuf = CALLOC_STRUCT(vbuf_stage);
- if (vbuf == NULL)
+ if (!vbuf)
goto fail;
vbuf->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index 38ac11a9adf..ae4a00eb630 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -202,7 +202,7 @@ static void wideline_destroy( struct draw_stage *stage )
struct draw_stage *draw_wide_line_stage( struct draw_context *draw )
{
struct wideline_stage *wide = CALLOC_STRUCT(wideline_stage);
- if (wide == NULL)
+ if (!wide)
goto fail;
wide->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index 348b0e93bbc..adb6120d834 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -315,7 +315,7 @@ static void widepoint_destroy( struct draw_stage *stage )
struct draw_stage *draw_wide_point_stage( struct draw_context *draw )
{
struct widepoint_stage *wide = CALLOC_STRUCT(widepoint_stage);
- if (wide == NULL)
+ if (!wide)
goto fail;
wide->stage.draw = draw;
diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
index b6966a52ea4..c7b224a88f7 100644
--- a/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
+++ b/src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
@@ -376,7 +376,7 @@ static void fetch_emit_destroy( struct draw_pt_middle_end *middle )
struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw )
{
struct fetch_emit_middle_end *fetch_emit = CALLOC_STRUCT( fetch_emit_middle_end );
- if (fetch_emit == NULL)
+ if (!fetch_emit)
return NULL;
fetch_emit->cache = translate_cache_create();
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index 1501942eb44..438c9a6b9c4 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -200,7 +200,7 @@ draw_vs_lookup_variant( struct draw_vertex_shader *vs,
/* Else have to create a new one:
*/
variant = vs->create_variant( vs, key );
- if (variant == NULL)
+ if (!variant)
return NULL;
/* Add it to our list, could be smarter:
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 17b54b6fe74..abd64f5acd2 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -225,7 +225,7 @@ draw_create_vs_exec(struct draw_context *draw,
{
struct exec_vertex_shader *vs = CALLOC_STRUCT( exec_vertex_shader );
- if (vs == NULL)
+ if (!vs)
return NULL;
/* we make a private copy of the tokens */
diff --git a/src/gallium/auxiliary/draw/draw_vs_llvm.c b/src/gallium/auxiliary/draw/draw_vs_llvm.c
index ac3999efc68..c92e4317216 100644
--- a/src/gallium/auxiliary/draw/draw_vs_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_vs_llvm.c
@@ -86,7 +86,7 @@ draw_create_vs_llvm(struct draw_context *draw,
{
struct llvm_vertex_shader *vs = CALLOC_STRUCT( llvm_vertex_shader );
- if (vs == NULL)
+ if (!vs)
return NULL;
/* we make a private copy of the tokens */
diff --git a/src/gallium/auxiliary/draw/draw_vs_variant.c b/src/gallium/auxiliary/draw/draw_vs_variant.c
index ce3a608c1d1..af36a86674d 100644
--- a/src/gallium/auxiliary/draw/draw_vs_variant.c
+++ b/src/gallium/auxiliary/draw/draw_vs_variant.c
@@ -302,7 +302,7 @@ draw_vs_create_variant_generic( struct draw_vertex_shader *vs,
struct translate_key fetch, emit;
struct draw_vs_variant_generic *vsvg = CALLOC_STRUCT( draw_vs_variant_generic );
- if (vsvg == NULL)
+ if (!vsvg)
return NULL;
vsvg->base.key = *key;