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 <eocallaghan@alterapraxis.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Edward O'Callaghan
2015-12-04 22:08:22 +11:00
committed by Marek Olšák
parent 150c289f60
commit 13eb5f596b
54 changed files with 132 additions and 132 deletions

View File

@@ -160,7 +160,7 @@ i915_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
struct i915_context *i915;
i915 = CALLOC_STRUCT(i915_context);
if (i915 == NULL)
if (!i915)
return NULL;
i915->iws = i915_screen(screen)->iws;

View File

@@ -72,7 +72,7 @@ i915_buffer_transfer_map(struct pipe_context *pipe,
struct i915_buffer *buffer = i915_buffer(resource);
struct pipe_transfer *transfer = util_slab_alloc(&i915->transfer_pool);
if (transfer == NULL)
if (!transfer)
return NULL;
transfer->resource = resource;

View File

@@ -728,7 +728,7 @@ i915_texture_transfer_map(struct pipe_context *pipe,
unsigned offset;
char *map;
if (transfer == NULL)
if (!transfer)
return NULL;
transfer->b.resource = resource;
@@ -774,7 +774,7 @@ i915_texture_transfer_map(struct pipe_context *pipe,
map = iws->buffer_map(iws, tex->buffer,
(transfer->b.usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
if (map == NULL) {
if (!map) {
pipe_resource_reference(&transfer->staging_texture, NULL);
FREE(transfer);
return NULL;

View File

@@ -337,7 +337,7 @@ lp_scene_new_data_block( struct lp_scene *scene )
}
else {
struct data_block *block = MALLOC_STRUCT(data_block);
if (block == NULL)
if (!block)
return NULL;
scene->scene_size += sizeof *block;

View File

@@ -60,7 +60,7 @@ struct lp_scene_queue *
lp_scene_queue_create(void)
{
struct lp_scene_queue *queue = CALLOC_STRUCT(lp_scene_queue);
if (queue == NULL)
if (!queue)
return NULL;
queue->ring = util_ringbuffer_create( MAX_SCENE_QUEUE *

View File

@@ -96,7 +96,7 @@ lp_setup_alloc_triangle(struct lp_scene *scene,
plane_sz);
tri = lp_scene_alloc_aligned( scene, *tri_size, 16 );
if (tri == NULL)
if (!tri)
return NULL;
tri->inputs.stride = input_array_sz;

View File

@@ -47,7 +47,7 @@ llvmpipe_create_gs_state(struct pipe_context *pipe,
struct lp_geometry_shader *state;
state = CALLOC_STRUCT(lp_geometry_shader);
if (state == NULL )
if (!state)
goto no_state;
/* debug */

View File

@@ -64,7 +64,7 @@ llvmpipe_create_rasterizer_state(struct pipe_context *pipe,
* handle, and what we'll look after ourselves.
*/
struct lp_rast_state *state = MALLOC_STRUCT(lp_rast_state);
if (state == NULL)
if (!state)
return NULL;
memcpy(&state->draw_state, rast, sizeof *rast);

View File

@@ -723,7 +723,7 @@ generate_setup_variant(struct lp_setup_variant_key *key,
goto fail;
variant = CALLOC_STRUCT(lp_setup_variant);
if (variant == NULL)
if (!variant)
goto fail;
variant->no = setup_no++;

View File

@@ -46,7 +46,7 @@ llvmpipe_create_vs_state(struct pipe_context *pipe,
struct draw_vertex_shader *vs;
vs = draw_create_vertex_shader(llvmpipe->draw, templ);
if (vs == NULL) {
if (!vs) {
return NULL;
}

View File

@@ -96,7 +96,7 @@ static struct pipe_resource *noop_resource_create(struct pipe_screen *screen,
unsigned stride;
nresource = CALLOC_STRUCT(noop_resource);
if (nresource == NULL)
if (!nresource)
return NULL;
stride = util_format_get_stride(templ->format, templ->width0);
@@ -158,7 +158,7 @@ static void *noop_transfer_map(struct pipe_context *pipe,
struct noop_resource *nresource = (struct noop_resource *)resource;
transfer = CALLOC_STRUCT(pipe_transfer);
if (transfer == NULL)
if (!transfer)
return NULL;
pipe_resource_reference(&transfer->resource, resource);
transfer->level = level;
@@ -265,7 +265,7 @@ static struct pipe_context *noop_create_context(struct pipe_screen *screen,
{
struct pipe_context *ctx = CALLOC_STRUCT(pipe_context);
if (ctx == NULL)
if (!ctx)
return NULL;
ctx->screen = screen;
ctx->priv = priv;
@@ -374,7 +374,7 @@ struct pipe_screen *noop_screen_create(struct pipe_screen *oscreen)
}
noop_screen = CALLOC_STRUCT(noop_pipe_screen);
if (noop_screen == NULL) {
if (!noop_screen) {
return NULL;
}
noop_screen->oscreen = oscreen;

View File

@@ -44,7 +44,7 @@ static void *noop_create_blend_state(struct pipe_context *ctx,
{
struct pipe_blend_state *nstate = CALLOC_STRUCT(pipe_blend_state);
if (nstate == NULL) {
if (!nstate) {
return NULL;
}
*nstate = *state;
@@ -56,7 +56,7 @@ static void *noop_create_dsa_state(struct pipe_context *ctx,
{
struct pipe_depth_stencil_alpha_state *nstate = CALLOC_STRUCT(pipe_depth_stencil_alpha_state);
if (nstate == NULL) {
if (!nstate) {
return NULL;
}
*nstate = *state;
@@ -68,7 +68,7 @@ static void *noop_create_rs_state(struct pipe_context *ctx,
{
struct pipe_rasterizer_state *nstate = CALLOC_STRUCT(pipe_rasterizer_state);
if (nstate == NULL) {
if (!nstate) {
return NULL;
}
*nstate = *state;
@@ -80,7 +80,7 @@ static void *noop_create_sampler_state(struct pipe_context *ctx,
{
struct pipe_sampler_state *nstate = CALLOC_STRUCT(pipe_sampler_state);
if (nstate == NULL) {
if (!nstate) {
return NULL;
}
*nstate = *state;
@@ -93,7 +93,7 @@ static struct pipe_sampler_view *noop_create_sampler_view(struct pipe_context *c
{
struct pipe_sampler_view *sampler_view = CALLOC_STRUCT(pipe_sampler_view);
if (sampler_view == NULL)
if (!sampler_view)
return NULL;
/* initialize base object */
pipe_resource_reference(&sampler_view->texture, texture);
@@ -108,7 +108,7 @@ static struct pipe_surface *noop_create_surface(struct pipe_context *ctx,
{
struct pipe_surface *surface = CALLOC_STRUCT(pipe_surface);
if (surface == NULL)
if (!surface)
return NULL;
pipe_reference_init(&surface->reference, 1);
pipe_resource_reference(&surface->texture, texture);
@@ -228,7 +228,7 @@ static void *noop_create_vertex_elements(struct pipe_context *ctx,
{
struct pipe_vertex_element *nstate = CALLOC_STRUCT(pipe_vertex_element);
if (nstate == NULL) {
if (!nstate) {
return NULL;
}
*nstate = *state;
@@ -240,7 +240,7 @@ static void *noop_create_shader_state(struct pipe_context *ctx,
{
struct pipe_shader_state *nstate = CALLOC_STRUCT(pipe_shader_state);
if (nstate == NULL) {
if (!nstate) {
return NULL;
}
*nstate = *state;

View File

@@ -168,7 +168,7 @@ main(int argc, char *argv[])
else
f = fopen(filename, "r");
if (f == NULL) {
if (!f) {
_debug_printf("Error opening file '%s': %s\n", filename, strerror(errno));
return 1;
}

View File

@@ -497,9 +497,9 @@ nv84_decoder_vp_mpeg12(struct nv84_decoder *dec,
STATIC_ASSERT(sizeof(struct mpeg12_header) == 0x100);
if (ref1 == NULL)
if (!ref1)
ref1 = dest;
if (ref2 == NULL)
if (!ref2)
ref2 = dest;
bo_refs[1].bo = ref1->interlaced;
bo_refs[2].bo = ref2->interlaced;

View File

@@ -847,7 +847,7 @@ static void rc_emulate_negative_addressing(struct radeon_compiler *compiler, voi
if (inst->U.I.SrcReg[i].RelAddr &&
inst->U.I.SrcReg[i].Index < 0) {
/* ARL must precede any indirect addressing. */
if (lastARL == NULL) {
if (!lastARL) {
rc_error(&c->Base, "Vertex shader: Found relative addressing without ARL/ARR.");
return;
}

View File

@@ -129,7 +129,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
map = rws->buffer_map(rbuf->cs_buf, r300->cs, usage);
if (map == NULL) {
if (!map) {
util_slab_free(&r300->pool_transfers, transfer);
return NULL;
}

View File

@@ -1125,7 +1125,7 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
struct r300_context* r300 = r300_context(pipe);
struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader;
if (fs == NULL) {
if (!fs) {
r300->fs.state = NULL;
return;
}
@@ -1950,7 +1950,7 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe,
struct r300_context *r300 = r300_context(pipe);
struct r300_vertex_element_state *velems = state;
if (velems == NULL) {
if (!velems) {
return;
}
@@ -1996,7 +1996,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader)
struct r300_context* r300 = r300_context(pipe);
struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader;
if (vs == NULL) {
if (!vs) {
r300->vs_state.state = NULL;
return;
}

View File

@@ -51,7 +51,7 @@ struct compute_memory_pool* compute_memory_pool_new(
{
struct compute_memory_pool* pool = (struct compute_memory_pool*)
CALLOC(sizeof(struct compute_memory_pool), 1);
if (pool == NULL)
if (!pool)
return NULL;
COMPUTE_DBG(rscreen, "* compute_memory_pool_new()\n");
@@ -399,7 +399,7 @@ int compute_memory_promote_item(struct compute_memory_pool *pool,
list_addtail(&item->link, pool->item_list);
item->start_in_dw = start_in_dw;
if (src != NULL) {
if (src) {
u_box_1d(0, item->size_in_dw * 4, &box);
rctx->b.b.resource_copy_region(pipe,
@@ -630,7 +630,7 @@ struct compute_memory_item* compute_memory_alloc(
new_item = (struct compute_memory_item *)
CALLOC(sizeof(struct compute_memory_item), 1);
if (new_item == NULL)
if (!new_item)
return NULL;
new_item->size_in_dw = size_in_dw;

View File

@@ -404,7 +404,7 @@ static void *evergreen_create_dsa_state(struct pipe_context *ctx,
unsigned db_depth_control, alpha_test_control, alpha_ref;
struct r600_dsa_state *dsa = CALLOC_STRUCT(r600_dsa_state);
if (dsa == NULL) {
if (!dsa) {
return NULL;
}
@@ -461,7 +461,7 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
float psize_min, psize_max;
struct r600_rasterizer_state *rs = CALLOC_STRUCT(r600_rasterizer_state);
if (rs == NULL) {
if (!rs) {
return NULL;
}
@@ -558,7 +558,7 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx,
struct r600_pipe_sampler_state *ss = CALLOC_STRUCT(r600_pipe_sampler_state);
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 2 : 0;
if (ss == NULL) {
if (!ss) {
return NULL;
}
@@ -669,7 +669,7 @@ evergreen_create_sampler_view_custom(struct pipe_context *ctx,
unsigned dim, last_layer;
uint64_t va;
if (view == NULL)
if (!view)
return NULL;
/* initialize base object */

View File

@@ -55,7 +55,7 @@ static struct r600_bytecode_cf *r600_bytecode_cf(void)
{
struct r600_bytecode_cf *cf = CALLOC_STRUCT(r600_bytecode_cf);
if (cf == NULL)
if (!cf)
return NULL;
LIST_INITHEAD(&cf->list);
LIST_INITHEAD(&cf->alu);
@@ -68,7 +68,7 @@ static struct r600_bytecode_alu *r600_bytecode_alu(void)
{
struct r600_bytecode_alu *alu = CALLOC_STRUCT(r600_bytecode_alu);
if (alu == NULL)
if (!alu)
return NULL;
LIST_INITHEAD(&alu->list);
return alu;
@@ -78,7 +78,7 @@ static struct r600_bytecode_vtx *r600_bytecode_vtx(void)
{
struct r600_bytecode_vtx *vtx = CALLOC_STRUCT(r600_bytecode_vtx);
if (vtx == NULL)
if (!vtx)
return NULL;
LIST_INITHEAD(&vtx->list);
return vtx;
@@ -88,7 +88,7 @@ static struct r600_bytecode_tex *r600_bytecode_tex(void)
{
struct r600_bytecode_tex *tex = CALLOC_STRUCT(r600_bytecode_tex);
if (tex == NULL)
if (!tex)
return NULL;
LIST_INITHEAD(&tex->list);
return tex;
@@ -157,7 +157,7 @@ int r600_bytecode_add_cf(struct r600_bytecode *bc)
{
struct r600_bytecode_cf *cf = r600_bytecode_cf();
if (cf == NULL)
if (!cf)
return -ENOMEM;
LIST_ADDTAIL(&cf->list, &bc->cf);
if (bc->cf_last) {
@@ -1148,7 +1148,7 @@ int r600_bytecode_add_alu_type(struct r600_bytecode *bc,
struct r600_bytecode_alu *lalu;
int i, r;
if (nalu == NULL)
if (!nalu)
return -ENOMEM;
memcpy(nalu, alu, sizeof(struct r600_bytecode_alu));
@@ -1309,7 +1309,7 @@ int r600_bytecode_add_vtx(struct r600_bytecode *bc, const struct r600_bytecode_v
struct r600_bytecode_vtx *nvtx = r600_bytecode_vtx();
int r;
if (nvtx == NULL)
if (!nvtx)
return -ENOMEM;
memcpy(nvtx, vtx, sizeof(struct r600_bytecode_vtx));
@@ -1361,7 +1361,7 @@ int r600_bytecode_add_tex(struct r600_bytecode *bc, const struct r600_bytecode_t
struct r600_bytecode_tex *ntex = r600_bytecode_tex();
int r;
if (ntex == NULL)
if (!ntex)
return -ENOMEM;
memcpy(ntex, tex, sizeof(struct r600_bytecode_tex));
@@ -2420,7 +2420,7 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
&format, &num_format, &format_comp, &endian);
desc = util_format_description(elements[i].src_format);
if (desc == NULL) {
if (!desc) {
r600_bytecode_clear(&bc);
R600_ERR("unknown format %d\n", elements[i].src_format);
return NULL;

View File

@@ -115,7 +115,7 @@ static struct pipe_context *r600_create_context(struct pipe_screen *screen,
struct r600_screen* rscreen = (struct r600_screen *)screen;
struct radeon_winsys *ws = rscreen->b.ws;
if (rctx == NULL)
if (!rctx)
return NULL;
rctx->b.b.screen = screen;
@@ -527,7 +527,7 @@ static void r600_destroy_screen(struct pipe_screen* pscreen)
{
struct r600_screen *rscreen = (struct r600_screen *)pscreen;
if (rscreen == NULL)
if (!rscreen)
return;
if (!rscreen->b.ws->unref(rscreen->b.ws))
@@ -554,7 +554,7 @@ struct pipe_screen *r600_screen_create(struct radeon_winsys *ws)
{
struct r600_screen *rscreen = CALLOC_STRUCT(r600_screen);
if (rscreen == NULL) {
if (!rscreen) {
return NULL;
}

View File

@@ -390,7 +390,7 @@ static void *r600_create_dsa_state(struct pipe_context *ctx,
unsigned db_depth_control, alpha_test_control, alpha_ref;
struct r600_dsa_state *dsa = CALLOC_STRUCT(r600_dsa_state);
if (dsa == NULL) {
if (!dsa) {
return NULL;
}
@@ -446,7 +446,7 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
float psize_min, psize_max;
struct r600_rasterizer_state *rs = CALLOC_STRUCT(r600_rasterizer_state);
if (rs == NULL) {
if (!rs) {
return NULL;
}
@@ -559,7 +559,7 @@ static void *r600_create_sampler_state(struct pipe_context *ctx,
struct r600_pipe_sampler_state *ss = CALLOC_STRUCT(r600_pipe_sampler_state);
unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 4 : 0;
if (ss == NULL) {
if (!ss) {
return NULL;
}
@@ -642,7 +642,7 @@ r600_create_sampler_view_custom(struct pipe_context *ctx,
unsigned char swizzle[4], array_mode = 0;
unsigned width, height, depth, offset_level, last_level;
if (view == NULL)
if (!view)
return NULL;
/* initialize base object */

View File

@@ -192,7 +192,7 @@ static void r600_bind_blend_state(struct pipe_context *ctx, void *state)
struct r600_context *rctx = (struct r600_context *)ctx;
struct r600_blend_state *blend = (struct r600_blend_state *)state;
if (blend == NULL) {
if (!blend) {
r600_set_cso_state_with_cb(rctx, &rctx->blend_state, NULL, NULL);
return;
}
@@ -299,7 +299,7 @@ static void r600_bind_dsa_state(struct pipe_context *ctx, void *state)
struct r600_dsa_state *dsa = state;
struct r600_stencil_ref ref;
if (state == NULL) {
if (!state) {
r600_set_cso_state_with_cb(rctx, &rctx->dsa_state, NULL, NULL);
return;
}
@@ -339,7 +339,7 @@ static void r600_bind_rs_state(struct pipe_context *ctx, void *state)
struct r600_rasterizer_state *rs = (struct r600_rasterizer_state *)state;
struct r600_context *rctx = (struct r600_context *)ctx;
if (state == NULL)
if (!state)
return;
rctx->rasterizer = rs;

View File

@@ -318,7 +318,7 @@ void r600_context_add_resource_size(struct pipe_context *ctx, struct pipe_resour
struct r600_common_context *rctx = (struct r600_common_context *)ctx;
struct r600_resource *rr = (struct r600_resource *)r;
if (r == NULL) {
if (!r) {
return;
}

View File

@@ -202,7 +202,7 @@ static struct pipe_query *r600_query_sw_create(struct pipe_context *ctx,
struct r600_query_sw *query;
query = CALLOC_STRUCT(r600_query_sw);
if (query == NULL)
if (!query)
return NULL;
query->b.type = query_type;

View File

@@ -699,7 +699,7 @@ r600_texture_create_object(struct pipe_screen *screen,
struct r600_common_screen *rscreen = (struct r600_common_screen*)screen;
rtex = CALLOC_STRUCT(r600_texture);
if (rtex == NULL)
if (!rtex)
return NULL;
resource = &rtex->resource;
@@ -1039,7 +1039,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
}
trans = CALLOC_STRUCT(r600_transfer);
if (trans == NULL)
if (!trans)
return NULL;
trans->transfer.resource = texture;
trans->transfer.level = level;
@@ -1115,7 +1115,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
/* Create the temporary texture. */
staging = (struct r600_texture*)ctx->screen->resource_create(ctx->screen, &resource);
if (staging == NULL) {
if (!staging) {
R600_ERR("failed to create temporary texture to hold untiled copy\n");
FREE(trans);
return NULL;
@@ -1192,7 +1192,7 @@ struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,
{
struct r600_surface *surface = CALLOC_STRUCT(r600_surface);
if (surface == NULL)
if (!surface)
return NULL;
assert(templ->u.tex.first_layer <= util_max_layer(texture, templ->u.tex.level));

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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);

View File

@@ -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++) {

View File

@@ -207,7 +207,7 @@ softpipe_create_vs_state(struct pipe_context *pipe,
struct sp_vertex_shader *state;
state = CALLOC_STRUCT(sp_vertex_shader);
if (state == NULL )
if (!state)
goto fail;
/* copy shader tokens, the ones passed in will go away.
@@ -269,7 +269,7 @@ softpipe_create_gs_state(struct pipe_context *pipe,
struct sp_geometry_shader *state;
state = CALLOC_STRUCT(sp_geometry_shader);
if (state == NULL )
if (!state)
goto fail;
state->shader = *templ;

View File

@@ -435,7 +435,7 @@ softpipe_transfer_map(struct pipe_context *pipe,
map = spr->data;
}
if (map == NULL) {
if (!map) {
pipe_resource_reference(&pt->resource, NULL);
FREE(spt);
return NULL;

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -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.

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -207,7 +207,7 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
vc4_debug &= ~VC4_DEBUG_SHADERDB;
vc4 = rzalloc(NULL, struct vc4_context);
if (vc4 == NULL)
if (!vc4)
return NULL;
struct pipe_context *pctx = &vc4->base;

View File

@@ -63,7 +63,7 @@ static void *virgl_buffer_transfer_map(struct pipe_context *ctx,
ctx->flush(ctx, NULL, 0);
trans = util_slab_alloc(&vctx->texture_transfer_pool);
if (trans == NULL)
if (!trans)
return NULL;
trans->base.resource = resource;

View File

@@ -198,7 +198,7 @@ static struct pipe_surface *virgl_create_surface(struct pipe_context *ctx,
uint32_t handle;
surf = CALLOC_STRUCT(virgl_surface);
if (surf == NULL)
if (!surf)
return NULL;
res->clean = FALSE;
@@ -669,7 +669,7 @@ static struct pipe_sampler_view *virgl_create_sampler_view(struct pipe_context *
uint32_t handle;
struct virgl_resource *res;
if (state == NULL)
if (!state)
return NULL;
grview = CALLOC_STRUCT(virgl_sampler_view);

View File

@@ -146,7 +146,7 @@ static void *virgl_texture_transfer_map(struct pipe_context *ctx,
ctx->flush(ctx, NULL, 0);
trans = util_slab_alloc(&vctx->texture_transfer_pool);
if (trans == NULL)
if (!trans)
return NULL;
trans->base.resource = resource;