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)
int ret;
msg = async_queue_pop(queue);
if (!msg || msg->type != MSG_REPLY)
if (!msg)
return -1;
if (msg->type != MSG_REPLY)
return -1;
ret = msg->args[0];
......@@ -219,7 +221,9 @@ static void *consumer(void *arg)
printf("<timed out>\n");
}
msg = async_queue_pop(args->recv_queue);
if (!msg || msg->type != MSG_INVOKE)
if (!msg)
abort();
if (msg->type != MSG_INVOKE)
abort();
switch (msg->args[0]) {
......
......@@ -44,7 +44,7 @@ void queue_free(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)
......@@ -66,7 +66,9 @@ void *queue_pop(UQueue *queue)
UList *list;
void *data;
if (!queue || !queue->head)
if (!queue)
return NULL;
if (!queue->head)
return NULL;
list = queue->head;
......
......@@ -968,7 +968,9 @@ gl_create_framebuffer_object(
GLFramebufferObject *fbo;
GLenum status;
if (!gl_vtable || !gl_vtable->has_framebuffer_object)
if (!gl_vtable)
return NULL;
if (!gl_vtable->has_framebuffer_object)
return NULL;
fbo = calloc(1, sizeof(*fbo));
......@@ -1109,10 +1111,14 @@ gl_create_shader_object(
GLVTable * const gl_vtable = gl_get_vtable();
GLShaderObject *so;
if (!gl_vtable || !gl_vtable->has_fragment_program)
if (!gl_vtable)
return NULL;
if (!gl_vtable->has_fragment_program)
return NULL;
if (!shader_fp || !shader_fp_length)
if (!shader_fp)
return NULL;
if (!shader_fp_length)
return NULL;
so = calloc(1, sizeof(*so));
......
......@@ -702,7 +702,9 @@ xvba_EndPicture(
return VA_STATUS_ERROR_INVALID_CONTEXT;
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;
/* Send picture bits to the HW and free VA resources (buffers) */
......
......@@ -154,7 +154,9 @@ query_surface_status(
switch (obj_surface->va_surface_status) {
case VASurfaceRendering: /* Rendering (XvBA level) */
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;
if (!obj_surface->xvba_surface)
return 0;
......
......@@ -1672,7 +1672,9 @@ xvba_CopySurfaceGLX(
static void
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;
pthread_mutex_lock(&obj_output->lock);
}
......@@ -1681,7 +1683,9 @@ glx_output_surface_lock(object_glx_output_p obj_output)
static void
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;
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