summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/svga
diff options
context:
space:
mode:
authorEdward O'Callaghan <[email protected]>2015-12-04 22:08:22 +1100
committerMarek Olšák <[email protected]>2015-12-06 17:10:23 +0100
commit13eb5f596bc8ece3d1805b388aa53917e6158d7b (patch)
treeda4ab5c8fd897b317d7f66004fdd22cd02ebe84c /src/gallium/drivers/svga
parent150c289f6067cb1ba4572f9124948a94ef94c839 (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/svga')
-rw-r--r--src/gallium/drivers/svga/svga_cmd.c6
-rw-r--r--src/gallium/drivers/svga/svga_context.c4
-rw-r--r--src/gallium/drivers/svga/svga_draw.c8
-rw-r--r--src/gallium/drivers/svga/svga_draw_arrays.c4
-rw-r--r--src/gallium/drivers/svga/svga_draw_elements.c6
-rw-r--r--src/gallium/drivers/svga/svga_pipe_clear.c4
-rw-r--r--src/gallium/drivers/svga/svga_pipe_query.c10
-rw-r--r--src/gallium/drivers/svga/svga_pipe_streamout.c2
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer.c2
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_constants.c8
-rw-r--r--src/gallium/drivers/svga/svga_state_framebuffer.c2
-rw-r--r--src/gallium/drivers/svga/svga_state_gs.c6
-rw-r--r--src/gallium/drivers/svga/svga_state_tgsi_transform.c12
-rw-r--r--src/gallium/drivers/svga/svga_surface.c2
-rw-r--r--src/gallium/drivers/svga/svga_tgsi.c4
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_vgpu10.c2
17 files changed, 42 insertions, 42 deletions
diff --git a/src/gallium/drivers/svga/svga_cmd.c b/src/gallium/drivers/svga/svga_cmd.c
index 0e1e332d6cb..10442cb46e7 100644
--- a/src/gallium/drivers/svga/svga_cmd.c
+++ b/src/gallium/drivers/svga/svga_cmd.c
@@ -1386,7 +1386,7 @@ SVGA3D_BeginGBQuery(struct svga_winsys_context *swc,
SVGA_3D_CMD_BEGIN_GB_QUERY,
sizeof *cmd,
1);
- if(!cmd)
+ if (!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
@@ -1466,7 +1466,7 @@ SVGA3D_EndGBQuery(struct svga_winsys_context *swc,
SVGA_3D_CMD_END_GB_QUERY,
sizeof *cmd,
2);
- if(!cmd)
+ if (!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
@@ -1553,7 +1553,7 @@ SVGA3D_WaitForGBQuery(struct svga_winsys_context *swc,
SVGA_3D_CMD_WAIT_FOR_GB_QUERY,
sizeof *cmd,
2);
- if(!cmd)
+ if (!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
cmd->cid = swc->cid;
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
index f8622b96f45..d407785ddd9 100644
--- a/src/gallium/drivers/svga/svga_context.c
+++ b/src/gallium/drivers/svga/svga_context.c
@@ -134,7 +134,7 @@ struct pipe_context *svga_context_create(struct pipe_screen *screen,
enum pipe_error ret;
svga = CALLOC_STRUCT(svga_context);
- if (svga == NULL)
+ if (!svga)
goto cleanup;
LIST_INITHEAD(&svga->dirty_buffers);
@@ -340,7 +340,7 @@ void svga_context_flush( struct svga_context *svga,
PIPE_TIMEOUT_INFINITE);
}
- if(pfence)
+ if (pfence)
svgascreen->sws->fence_reference(svgascreen->sws, pfence, fence);
svgascreen->sws->fence_reference(svgascreen->sws, &fence, NULL);
diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c
index 9b6451da2f9..cca499a65c7 100644
--- a/src/gallium/drivers/svga/svga_draw.c
+++ b/src/gallium/drivers/svga/svga_draw.c
@@ -48,7 +48,7 @@ struct svga_hwtnl *
svga_hwtnl_create(struct svga_context *svga)
{
struct svga_hwtnl *hwtnl = CALLOC_STRUCT(svga_hwtnl);
- if (hwtnl == NULL)
+ if (!hwtnl)
goto fail;
hwtnl->svga = svga;
@@ -189,7 +189,7 @@ draw_vgpu9(struct svga_hwtnl *hwtnl)
for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
unsigned j = hwtnl->cmd.vdecl_buffer_index[i];
handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer);
- if (handle == NULL)
+ if (!handle)
return PIPE_ERROR_OUT_OF_MEMORY;
vb_handle[i] = handle;
@@ -198,7 +198,7 @@ draw_vgpu9(struct svga_hwtnl *hwtnl)
for (i = 0; i < hwtnl->cmd.prim_count; i++) {
if (hwtnl->cmd.prim_ib[i]) {
handle = svga_buffer_handle(svga, hwtnl->cmd.prim_ib[i]);
- if (handle == NULL)
+ if (!handle)
return PIPE_ERROR_OUT_OF_MEMORY;
}
else
@@ -491,7 +491,7 @@ draw_vgpu10(struct svga_hwtnl *hwtnl,
(void) sbuf; /* silence unused var warning */
ib_handle = svga_buffer_handle(svga, ib);
- if (ib_handle == NULL)
+ if (!ib_handle)
return PIPE_ERROR_OUT_OF_MEMORY;
}
else {
diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c
index acb2e95e747..1bf19e8522e 100644
--- a/src/gallium/drivers/svga/svga_draw_arrays.c
+++ b/src/gallium/drivers/svga/svga_draw_arrays.c
@@ -52,11 +52,11 @@ generate_indices(struct svga_hwtnl *hwtnl,
dst = pipe_buffer_create(pipe->screen, PIPE_BIND_INDEX_BUFFER,
PIPE_USAGE_IMMUTABLE, size);
- if (dst == NULL)
+ if (!dst)
goto fail;
dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &transfer);
- if (dst_map == NULL)
+ if (!dst_map)
goto fail;
generate(0, nr, dst_map);
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
index 0213409ef29..74bfebda18f 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -60,15 +60,15 @@ translate_indices(struct svga_hwtnl *hwtnl, struct pipe_resource *src,
dst = pipe_buffer_create(pipe->screen,
PIPE_BIND_INDEX_BUFFER, PIPE_USAGE_DEFAULT, size);
- if (dst == NULL)
+ if (!dst)
goto fail;
src_map = pipe_buffer_map(pipe, src, PIPE_TRANSFER_READ, &src_transfer);
- if (src_map == NULL)
+ if (!src_map)
goto fail;
dst_map = pipe_buffer_map(pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer);
- if (dst_map == NULL)
+ if (!dst_map)
goto fail;
translate((const char *) src_map + offset, 0, 0, nr, 0, dst_map);
diff --git a/src/gallium/drivers/svga/svga_pipe_clear.c b/src/gallium/drivers/svga/svga_pipe_clear.c
index bab61780610..c874726b6da 100644
--- a/src/gallium/drivers/svga/svga_pipe_clear.c
+++ b/src/gallium/drivers/svga/svga_pipe_clear.c
@@ -178,7 +178,7 @@ try_clear(struct svga_context *svga,
rtv = svga_validate_surface_view(svga,
svga_surface(fb->cbufs[i]));
- if (rtv == NULL)
+ if (!rtv)
return PIPE_ERROR_OUT_OF_MEMORY;
ret = SVGA3D_vgpu10_ClearRenderTargetView(svga->swc,
@@ -191,7 +191,7 @@ try_clear(struct svga_context *svga,
if (flags & (SVGA3D_CLEAR_DEPTH | SVGA3D_CLEAR_STENCIL)) {
struct pipe_surface *dsv =
svga_validate_surface_view(svga, svga_surface(fb->zsbuf));
- if (dsv == NULL)
+ if (!dsv)
return PIPE_ERROR_OUT_OF_MEMORY;
ret = SVGA3D_vgpu10_ClearDepthStencilView(svga->swc, dsv, flags,
diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c
index 3859050bf18..b67d56c4ccf 100644
--- a/src/gallium/drivers/svga/svga_pipe_query.c
+++ b/src/gallium/drivers/svga/svga_pipe_query.c
@@ -348,7 +348,7 @@ allocate_query_block_entry(struct svga_context *svga,
if (block_index == -1)
return NULL;
alloc_entry = CALLOC_STRUCT(svga_qmem_alloc_entry);
- if (alloc_entry == NULL)
+ if (!alloc_entry)
return NULL;
alloc_entry->block_index = block_index;
@@ -381,13 +381,13 @@ allocate_query(struct svga_context *svga,
alloc_entry = svga->gb_query_map[type];
- if (alloc_entry == NULL) {
+ if (!alloc_entry) {
/**
* No query memory block has been allocated for this query type,
* allocate one now
*/
alloc_entry = allocate_query_block_entry(svga, len);
- if (alloc_entry == NULL)
+ if (!alloc_entry)
return -1;
svga->gb_query_map[type] = alloc_entry;
}
@@ -398,7 +398,7 @@ allocate_query(struct svga_context *svga,
if (slot_index == -1) {
/* This query memory block is full, allocate another one */
alloc_entry = allocate_query_block_entry(svga, len);
- if (alloc_entry == NULL)
+ if (!alloc_entry)
return -1;
alloc_entry->next = svga->gb_query_map[type];
svga->gb_query_map[type] = alloc_entry;
@@ -753,7 +753,7 @@ svga_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
struct svga_winsys_screen *sws = svga_screen(svga->pipe.screen)->sws;
struct svga_query *sq;
- if (q == NULL) {
+ if (!q) {
destroy_gb_query_obj(svga);
return;
}
diff --git a/src/gallium/drivers/svga/svga_pipe_streamout.c b/src/gallium/drivers/svga/svga_pipe_streamout.c
index 1da63204428..3f443c44eee 100644
--- a/src/gallium/drivers/svga/svga_pipe_streamout.c
+++ b/src/gallium/drivers/svga/svga_pipe_streamout.c
@@ -75,7 +75,7 @@ svga_create_stream_output(struct svga_context *svga,
/* Allocate the streamout data structure */
streamout = CALLOC_STRUCT(svga_stream_output);
- if (streamout == NULL)
+ if (!streamout)
return NULL;
streamout->info = *info;
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c
index 449cc149a81..a8ffcc7f680 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer.c
@@ -86,7 +86,7 @@ svga_buffer_transfer_map(struct pipe_context *pipe,
assert(box->depth == 1);
transfer = CALLOC_STRUCT(pipe_transfer);
- if (transfer == NULL) {
+ if (!transfer) {
return NULL;
}
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index 81594777258..4c7aeff92e8 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -506,7 +506,7 @@ svga_texture_transfer_map(struct pipe_context *pipe,
/*
* Make sure we return NULL if the map fails
*/
- if (map == NULL) {
+ if (!map) {
FREE(st);
return map;
}
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
index c93d2a5e565..2cf41134bd6 100644
--- a/src/gallium/drivers/svga/svga_state_constants.c
+++ b/src/gallium/drivers/svga/svga_state_constants.c
@@ -459,7 +459,7 @@ emit_consts_vgpu9(struct svga_context *svga, unsigned shader)
data = (const float (*)[4])
pipe_buffer_map(&svga->pipe, svga->curr.constbufs[shader][0].buffer,
PIPE_TRANSFER_READ, &transfer);
- if (data == NULL) {
+ if (!data) {
return PIPE_ERROR_OUT_OF_MEMORY;
}
@@ -747,7 +747,7 @@ emit_fs_consts(struct svga_context *svga, unsigned dirty)
/* SVGA_NEW_FS_VARIANT
*/
- if (variant == NULL)
+ if (!variant)
return PIPE_OK;
/* SVGA_NEW_FS_CONST_BUFFER
@@ -782,7 +782,7 @@ emit_vs_consts(struct svga_context *svga, unsigned dirty)
/* SVGA_NEW_VS_VARIANT
*/
- if (variant == NULL)
+ if (!variant)
return PIPE_OK;
/* SVGA_NEW_VS_CONST_BUFFER
@@ -816,7 +816,7 @@ emit_gs_consts(struct svga_context *svga, unsigned dirty)
/* SVGA_NEW_GS_VARIANT
*/
- if (variant == NULL)
+ if (!variant)
return PIPE_OK;
/* SVGA_NEW_GS_CONST_BUFFER
diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c
index 9abacc9fa20..4b0400bf80a 100644
--- a/src/gallium/drivers/svga/svga_state_framebuffer.c
+++ b/src/gallium/drivers/svga/svga_state_framebuffer.c
@@ -196,7 +196,7 @@ emit_fb_vgpu10(struct svga_context *svga)
/* Setup depth stencil view */
if (curr->zsbuf) {
dsv = svga_validate_surface_view(svga, svga_surface(curr->zsbuf));
- if (dsv == NULL) {
+ if (!dsv) {
return PIPE_ERROR_OUT_OF_MEMORY;
}
}
diff --git a/src/gallium/drivers/svga/svga_state_gs.c b/src/gallium/drivers/svga/svga_state_gs.c
index 0b336baee86..618bec248dd 100644
--- a/src/gallium/drivers/svga/svga_state_gs.c
+++ b/src/gallium/drivers/svga/svga_state_gs.c
@@ -72,7 +72,7 @@ compile_gs(struct svga_context *svga,
enum pipe_error ret = PIPE_ERROR;
variant = translate_geometry_program(svga, gs, key);
- if (variant == NULL) {
+ if (!variant) {
/* some problem during translation, try the dummy shader */
const struct tgsi_token *dummy = get_dummy_geometry_shader();
if (!dummy) {
@@ -82,7 +82,7 @@ compile_gs(struct svga_context *svga,
FREE((void *) gs->base.tokens);
gs->base.tokens = dummy;
variant = translate_geometry_program(svga, gs, key);
- if (variant == NULL) {
+ if (!variant) {
return PIPE_ERROR;
}
}
@@ -181,7 +181,7 @@ emit_hw_gs(struct svga_context *svga, unsigned dirty)
if (svga->curr.user_gs)
assert(svga->curr.gs);
- if (gs == NULL) {
+ if (!gs) {
if (svga->state.hw_draw.gs != NULL) {
/** The previous geometry shader is made inactive.
diff --git a/src/gallium/drivers/svga/svga_state_tgsi_transform.c b/src/gallium/drivers/svga/svga_state_tgsi_transform.c
index 023c5862d27..9e643ff49a7 100644
--- a/src/gallium/drivers/svga/svga_state_tgsi_transform.c
+++ b/src/gallium/drivers/svga/svga_state_tgsi_transform.c
@@ -88,13 +88,13 @@ emulate_point_sprite(struct svga_context *svga,
key.gs.aa_point = svga->curr.rast->templ.point_smooth;
- if (orig_gs != NULL) {
+ if (orig_gs) {
/* Check if the original geometry shader has stream output and
* if position is one of the outputs.
*/
streamout = orig_gs->base.stream_output;
- if (streamout != NULL) {
+ if (streamout) {
pos_out_index = streamout->pos_out_index;
key.gs.point_pos_stream_out = pos_out_index != -1;
}
@@ -119,7 +119,7 @@ emulate_point_sprite(struct svga_context *svga,
key.gs.aa_point ?
&aa_point_coord_index : NULL);
- if (new_tokens == NULL) {
+ if (!new_tokens) {
/* if no new tokens are generated for whatever reason, just return */
return NULL;
}
@@ -134,7 +134,7 @@ emulate_point_sprite(struct svga_context *svga,
templ.tokens = new_tokens;
templ.stream_output.num_outputs = 0;
- if (streamout != NULL) {
+ if (streamout) {
templ.stream_output = streamout->info;
/* The tgsi_add_point_sprite utility adds an extra output
* for the original point position for stream output purpose.
@@ -169,7 +169,7 @@ emulate_point_sprite(struct svga_context *svga,
/* Add the new geometry shader to the head of the shader list
* pointed to by the original geometry shader.
*/
- if (orig_gs != NULL) {
+ if (orig_gs) {
gs->base.next = orig_gs->base.next;
orig_gs->base.next = &gs->base;
}
@@ -207,7 +207,7 @@ add_point_sprite_shader(struct svga_context *svga)
vs->base.info.output_semantic_name,
vs->base.info.output_semantic_index);
- if (orig_gs == NULL)
+ if (!orig_gs)
return NULL;
}
else {
diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c
index 9f09311116e..ad06a1d531e 100644
--- a/src/gallium/drivers/svga/svga_surface.c
+++ b/src/gallium/drivers/svga/svga_surface.c
@@ -357,7 +357,7 @@ create_backed_surface_view(struct svga_context *svga, struct svga_surface *s)
{
struct svga_surface *bs = s->backed;
- if (bs == NULL) {
+ if (!bs) {
struct svga_texture *tex = svga_texture(s->base.texture);
struct pipe_surface *backed_view;
diff --git a/src/gallium/drivers/svga/svga_tgsi.c b/src/gallium/drivers/svga/svga_tgsi.c
index 4c16f4313a0..c62d4d671ef 100644
--- a/src/gallium/drivers/svga/svga_tgsi.c
+++ b/src/gallium/drivers/svga/svga_tgsi.c
@@ -71,7 +71,7 @@ svga_shader_expand(struct svga_shader_emitter *emit)
else
new_buf = NULL;
- if (new_buf == NULL) {
+ if (!new_buf) {
emit->ptr = err_buf;
emit->buf = err_buf;
emit->size = sizeof(err_buf);
@@ -229,7 +229,7 @@ svga_tgsi_vgpu9_translate(struct svga_context *svga,
}
variant = svga_new_shader_variant(svga);
- if (variant == NULL)
+ if (!variant)
goto fail;
variant->shader = shader;
diff --git a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
index 9b7ab16103f..c979f4a8a56 100644
--- a/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
+++ b/src/gallium/drivers/svga/svga_tgsi_vgpu10.c
@@ -240,7 +240,7 @@ expand(struct svga_shader_emitter_v10 *emit)
else
new_buf = NULL;
- if (new_buf == NULL) {
+ if (!new_buf) {
emit->ptr = err_buf;
emit->buf = err_buf;
emit->size = sizeof(err_buf);