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/noop | |
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/noop')
-rw-r--r-- | src/gallium/drivers/noop/noop_pipe.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/noop/noop_state.c | 16 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c index e644685123e..165284a90bf 100644 --- a/src/gallium/drivers/noop/noop_pipe.c +++ b/src/gallium/drivers/noop/noop_pipe.c @@ -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; diff --git a/src/gallium/drivers/noop/noop_state.c b/src/gallium/drivers/noop/noop_state.c index 5cb37b656de..fe5b5e4696e 100644 --- a/src/gallium/drivers/noop/noop_state.c +++ b/src/gallium/drivers/noop/noop_state.c @@ -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; |