Commit 8ae2becd authored by Jean-Paul Saman's avatar Jean-Paul Saman

Split check for if-clause

The boolean operator || requires an evaluation of both expressions.
If the expressions evaluates pointers, then care must be taken that
both expressions have valid pointer. In this case it cannot be guaranteed,
thus splitting the check is needed.
parent 5930ef22
...@@ -191,7 +191,9 @@ static int msg_wait_for_reply(UAsyncQueue *queue) ...@@ -191,7 +191,9 @@ static int msg_wait_for_reply(UAsyncQueue *queue)
int ret; int ret;
msg = async_queue_pop(queue); msg = async_queue_pop(queue);
if (!msg || msg->type != MSG_REPLY) if (!msg)
return -1;
if (msg->type != MSG_REPLY)
return -1; return -1;
ret = msg->args[0]; ret = msg->args[0];
...@@ -219,7 +221,9 @@ static void *consumer(void *arg) ...@@ -219,7 +221,9 @@ static void *consumer(void *arg)
printf("<timed out>\n"); printf("<timed out>\n");
} }
msg = async_queue_pop(args->recv_queue); msg = async_queue_pop(args->recv_queue);
if (!msg || msg->type != MSG_INVOKE) if (!msg)
abort();
if (msg->type != MSG_INVOKE)
abort(); abort();
switch (msg->args[0]) { switch (msg->args[0]) {
......
...@@ -44,7 +44,7 @@ void queue_free(UQueue *queue) ...@@ -44,7 +44,7 @@ void queue_free(UQueue *queue)
int queue_is_empty(UQueue *queue) int queue_is_empty(UQueue *queue)
{ {
return !queue || queue->size == 0; return queue ? (queue->size == 0) : 0;
} }
UQueue *queue_push(UQueue *queue, void *data) UQueue *queue_push(UQueue *queue, void *data)
...@@ -66,7 +66,9 @@ void *queue_pop(UQueue *queue) ...@@ -66,7 +66,9 @@ void *queue_pop(UQueue *queue)
UList *list; UList *list;
void *data; void *data;
if (!queue || !queue->head) if (!queue)
return NULL;
if (!queue->head)
return NULL; return NULL;
list = queue->head; list = queue->head;
......
...@@ -968,7 +968,9 @@ gl_create_framebuffer_object( ...@@ -968,7 +968,9 @@ gl_create_framebuffer_object(
GLFramebufferObject *fbo; GLFramebufferObject *fbo;
GLenum status; GLenum status;
if (!gl_vtable || !gl_vtable->has_framebuffer_object) if (!gl_vtable)
return NULL;
if (!gl_vtable->has_framebuffer_object)
return NULL; return NULL;
fbo = calloc(1, sizeof(*fbo)); fbo = calloc(1, sizeof(*fbo));
...@@ -1109,10 +1111,14 @@ gl_create_shader_object( ...@@ -1109,10 +1111,14 @@ gl_create_shader_object(
GLVTable * const gl_vtable = gl_get_vtable(); GLVTable * const gl_vtable = gl_get_vtable();
GLShaderObject *so; GLShaderObject *so;
if (!gl_vtable || !gl_vtable->has_fragment_program) if (!gl_vtable)
return NULL;
if (!gl_vtable->has_fragment_program)
return NULL; return NULL;
if (!shader_fp || !shader_fp_length) if (!shader_fp)
return NULL;
if (!shader_fp_length)
return NULL; return NULL;
so = calloc(1, sizeof(*so)); so = calloc(1, sizeof(*so));
......
...@@ -702,7 +702,9 @@ xvba_EndPicture( ...@@ -702,7 +702,9 @@ xvba_EndPicture(
return VA_STATUS_ERROR_INVALID_CONTEXT; return VA_STATUS_ERROR_INVALID_CONTEXT;
object_surface_p obj_surface = XVBA_SURFACE(obj_context->current_render_target); object_surface_p obj_surface = XVBA_SURFACE(obj_context->current_render_target);
if (!obj_surface || !obj_surface->xvba_surface) if (!obj_surface)
return VA_STATUS_ERROR_INVALID_SURFACE;
if (!obj_surface->xvba_surface)
return VA_STATUS_ERROR_INVALID_SURFACE; return VA_STATUS_ERROR_INVALID_SURFACE;
/* Send picture bits to the HW and free VA resources (buffers) */ /* Send picture bits to the HW and free VA resources (buffers) */
......
...@@ -154,7 +154,9 @@ query_surface_status( ...@@ -154,7 +154,9 @@ query_surface_status(
switch (obj_surface->va_surface_status) { switch (obj_surface->va_surface_status) {
case VASurfaceRendering: /* Rendering (XvBA level) */ case VASurfaceRendering: /* Rendering (XvBA level) */
ASSERT(obj_surface->used_for_decoding); ASSERT(obj_surface->used_for_decoding);
if (!obj_context || !obj_context->xvba_decoder) if (!obj_context)
return 0;
if (!obj_context->xvba_decoder)
return 0; return 0;
if (!obj_surface->xvba_surface) if (!obj_surface->xvba_surface)
return 0; return 0;
......
...@@ -1672,7 +1672,9 @@ xvba_CopySurfaceGLX( ...@@ -1672,7 +1672,9 @@ xvba_CopySurfaceGLX(
static void static void
glx_output_surface_lock(object_glx_output_p obj_output) glx_output_surface_lock(object_glx_output_p obj_output)
{ {
if (!obj_output || !obj_output->render_thread_ok) if (!obj_output)
return;
if (!obj_output->render_thread_ok)
return; return;
pthread_mutex_lock(&obj_output->lock); pthread_mutex_lock(&obj_output->lock);
} }
...@@ -1681,7 +1683,9 @@ glx_output_surface_lock(object_glx_output_p obj_output) ...@@ -1681,7 +1683,9 @@ glx_output_surface_lock(object_glx_output_p obj_output)
static void static void
glx_output_surface_unlock(object_glx_output_p obj_output) glx_output_surface_unlock(object_glx_output_p obj_output)
{ {
if (!obj_output || !obj_output->render_thread_ok) if (!obj_output)
return;
if (!obj_output->render_thread_ok)
return; return;
pthread_mutex_unlock(&obj_output->lock); pthread_mutex_unlock(&obj_output->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment