mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2025-12-20 04:40:07 +01:00
shared: Rename NULL and not NULL pointer assertions
Make the NULL assertions more explicit. weston_assert_ptr_is_null() -> weston_assert_ptr_null() weston_assert_ptr() -> weston_assert_ptr_not_null() Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
This commit is contained in:
parent
c855bc7af0
commit
9373e76655
10 changed files with 26 additions and 26 deletions
|
|
@ -570,7 +570,7 @@ drm_output_find_plane_for_view(struct drm_output_state *state,
|
|||
possible_plane_mask &= fb->plane_mask;
|
||||
} else {
|
||||
char *fr_str = bits_to_str(fb_failure_reasons, failure_reasons_to_str);
|
||||
weston_assert_ptr(b->compositor, fr_str);
|
||||
weston_assert_ptr_not_null(b->compositor, fr_str);
|
||||
drm_debug(b, "\t\t\t[view] couldn't get FB for view: %s\n", fr_str);
|
||||
free(fr_str);
|
||||
pnode->try_view_on_plane_failure_reasons |= fb_failure_reasons;
|
||||
|
|
@ -995,7 +995,7 @@ drm_output_propose_state(struct weston_output *output_base,
|
|||
} else if (!ps) {
|
||||
char *fr_str = bits_to_str(pnode->try_view_on_plane_failure_reasons,
|
||||
failure_reasons_to_str);
|
||||
weston_assert_ptr(b->compositor, fr_str);
|
||||
weston_assert_ptr_not_null(b->compositor, fr_str);
|
||||
drm_debug(b, "\t\t\t\t[view] view %p will be placed "
|
||||
"on the renderer: %s\n", ev, fr_str);
|
||||
free(fr_str);
|
||||
|
|
|
|||
|
|
@ -385,20 +385,20 @@ cmlcms_init(struct weston_color_manager *cm_base)
|
|||
weston_compositor_add_log_scope(compositor, "color-lcms-transformations",
|
||||
"Color transformation creation and destruction.\n",
|
||||
transforms_scope_new_sub, NULL, cm);
|
||||
weston_assert_ptr(compositor, cm->transforms_scope);
|
||||
weston_assert_ptr_not_null(compositor, cm->transforms_scope);
|
||||
|
||||
cm->optimizer_scope =
|
||||
weston_compositor_add_log_scope(compositor, "color-lcms-optimizer",
|
||||
"Color transformation pipeline optimizer. It's best " \
|
||||
"used together with the color-lcms-transformations " \
|
||||
"log scope.\n", NULL, NULL, NULL);
|
||||
weston_assert_ptr(compositor, cm->optimizer_scope);
|
||||
weston_assert_ptr_not_null(compositor, cm->optimizer_scope);
|
||||
|
||||
cm->profiles_scope =
|
||||
weston_compositor_add_log_scope(compositor, "color-lcms-profiles",
|
||||
"Color profile creation and destruction.\n",
|
||||
profiles_scope_new_sub, NULL, cm);
|
||||
weston_assert_ptr(compositor, cm->profiles_scope);
|
||||
weston_assert_ptr_not_null(compositor, cm->profiles_scope);
|
||||
|
||||
cm->lcms_ctx = cmsCreateContext(NULL, cm);
|
||||
if (!cm->lcms_ctx) {
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ ensure_output_profile_extract(struct cmlcms_color_profile *cprof,
|
|||
cprof->icc.profile, num_points,
|
||||
err_msg);
|
||||
if (ret)
|
||||
weston_assert_ptr(compositor, cprof->extract.eotf.p);
|
||||
weston_assert_ptr_not_null(compositor, cprof->extract.eotf.p);
|
||||
break;
|
||||
case CMLCMS_PROFILE_TYPE_PARAMS:
|
||||
/* TODO: need to address this when we create param profiles. */
|
||||
|
|
|
|||
|
|
@ -1255,7 +1255,7 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
|
|||
chain[chain_len++] = output_profile->extract.vcgt;
|
||||
|
||||
/* Render intent does not apply here, but need to set something. */
|
||||
weston_assert_ptr_is_null(cm->base.compositor, render_intent);
|
||||
weston_assert_ptr_null(cm->base.compositor, render_intent);
|
||||
render_intent = weston_render_intent_info_from(cm->base.compositor,
|
||||
WESTON_RENDER_INTENT_ABSOLUTE);
|
||||
break;
|
||||
|
|
@ -1268,7 +1268,7 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
|
|||
}
|
||||
|
||||
assert(chain_len <= ARRAY_LENGTH(chain));
|
||||
weston_assert_ptr(cm->base.compositor, render_intent);
|
||||
weston_assert_ptr_not_null(cm->base.compositor, render_intent);
|
||||
|
||||
/**
|
||||
* Binding to our LittleCMS plug-in occurs here.
|
||||
|
|
|
|||
|
|
@ -500,7 +500,7 @@ cm_output_get_image_description(struct wl_client *client,
|
|||
* object inert. We do that in weston_head_remove_global(), and the
|
||||
* cm_output_res user data (which was the head itself) is set to NULL.
|
||||
* So if we reached here, head is active and head->output != NULL. */
|
||||
weston_assert_ptr(compositor, output);
|
||||
weston_assert_ptr_not_null(compositor, output);
|
||||
|
||||
cm_image_desc = cm_image_desc_create(compositor->color_manager,
|
||||
output->color_profile, client,
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ cmnoop_get_surface_color_transform(struct weston_color_manager *cm_base,
|
|||
cmnoop->stock_cprof);
|
||||
|
||||
/* The output must have a cprof, and it has to be the stock one. */
|
||||
weston_assert_ptr(compositor, output->color_profile);
|
||||
weston_assert_ptr_not_null(compositor, output->color_profile);
|
||||
weston_assert_ptr_eq(compositor, to_cmnoop_cprof(output->color_profile),
|
||||
cmnoop->stock_cprof);
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ cmnoop_create_output_color_outcome(struct weston_color_manager *cm_base,
|
|||
struct weston_color_manager_noop *cmnoop = to_cmnoop(cm_base);
|
||||
struct weston_output_color_outcome *co;
|
||||
|
||||
weston_assert_ptr(compositor, output->color_profile);
|
||||
weston_assert_ptr_not_null(compositor, output->color_profile);
|
||||
weston_assert_ptr_eq(compositor, to_cmnoop_cprof(output->color_profile),
|
||||
cmnoop->stock_cprof);
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ weston_color_profile_param_builder_create(struct weston_compositor *compositor)
|
|||
|
||||
builder->err_fp = open_memstream(&builder->err_msg,
|
||||
&builder->err_msg_size);
|
||||
weston_assert_ptr(compositor, builder->err_fp);
|
||||
weston_assert_ptr_not_null(compositor, builder->err_fp);
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ params_add(struct wl_client *client,
|
|||
}
|
||||
|
||||
weston_assert_ptr_eq(buffer->compositor, buffer->params_resource, params_resource);
|
||||
weston_assert_ptr_is_null(buffer->compositor, buffer->buffer_resource);
|
||||
weston_assert_ptr_null(buffer->compositor, buffer->buffer_resource);
|
||||
|
||||
if (plane_idx >= MAX_DMABUF_PLANES) {
|
||||
wl_resource_post_error(params_resource,
|
||||
|
|
@ -155,7 +155,7 @@ destroy_linux_dmabuf_wl_buffer(struct wl_resource *resource)
|
|||
|
||||
buffer = wl_resource_get_user_data(resource);
|
||||
weston_assert_ptr_eq(buffer->compositor, buffer->buffer_resource, resource);
|
||||
weston_assert_ptr_is_null(buffer->compositor, buffer->params_resource);
|
||||
weston_assert_ptr_null(buffer->compositor, buffer->params_resource);
|
||||
|
||||
if (buffer->user_data_destroy_func)
|
||||
buffer->user_data_destroy_func(buffer);
|
||||
|
|
@ -185,7 +185,7 @@ params_create_common(struct wl_client *client,
|
|||
}
|
||||
|
||||
weston_assert_ptr_eq(buffer->compositor, buffer->params_resource, params_resource);
|
||||
weston_assert_ptr_is_null(buffer->compositor, buffer->buffer_resource);
|
||||
weston_assert_ptr_null(buffer->compositor, buffer->buffer_resource);
|
||||
|
||||
/* Switch the linux_dmabuf_buffer object from params resource to
|
||||
* eventually wl_buffer resource.
|
||||
|
|
@ -971,8 +971,8 @@ linux_dmabuf_buffer_get(struct weston_compositor *compositor,
|
|||
return NULL;
|
||||
|
||||
buffer = wl_resource_get_user_data(resource);
|
||||
weston_assert_ptr(compositor, buffer);
|
||||
weston_assert_ptr_is_null(compositor, buffer->params_resource);
|
||||
weston_assert_ptr_not_null(compositor, buffer);
|
||||
weston_assert_ptr_null(compositor, buffer->params_resource);
|
||||
weston_assert_ptr_eq(compositor, buffer->buffer_resource, resource);
|
||||
|
||||
return buffer;
|
||||
|
|
@ -1058,7 +1058,7 @@ bind_linux_dmabuf(struct wl_client *client,
|
|||
|
||||
/* If we got here, it means that the renderer is able to import dma-buf
|
||||
* buffers, and so it must have get_supported_formats() set. */
|
||||
weston_assert_ptr(compositor, compositor->renderer->get_supported_formats);
|
||||
weston_assert_ptr_not_null(compositor, compositor->renderer->get_supported_formats);
|
||||
supported_formats = compositor->renderer->get_supported_formats(compositor);
|
||||
|
||||
wl_array_for_each(fmt, &supported_formats->arr) {
|
||||
|
|
@ -1133,12 +1133,12 @@ linux_dmabuf_buffer_send_server_error(struct linux_dmabuf_buffer *buffer,
|
|||
struct wl_resource *display_resource;
|
||||
uint32_t id;
|
||||
|
||||
weston_assert_ptr(buffer->compositor, buffer->buffer_resource);
|
||||
weston_assert_ptr_not_null(buffer->compositor, buffer->buffer_resource);
|
||||
id = wl_resource_get_id(buffer->buffer_resource);
|
||||
client = wl_resource_get_client(buffer->buffer_resource);
|
||||
display_resource = wl_client_get_object(client, 1);
|
||||
|
||||
weston_assert_ptr(buffer->compositor, display_resource);
|
||||
weston_assert_ptr_not_null(buffer->compositor, display_resource);
|
||||
wl_resource_post_error(display_resource,
|
||||
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||||
"linux_dmabuf server error with "
|
||||
|
|
|
|||
|
|
@ -88,10 +88,10 @@ do { \
|
|||
#define weston_assert_false(compositor, a) \
|
||||
weston_assert_(compositor, a, false, bool, "%d", ==)
|
||||
|
||||
#define weston_assert_ptr(compositor, a) \
|
||||
#define weston_assert_ptr_not_null(compositor, a) \
|
||||
weston_assert_(compositor, a, NULL, const void *, "%p", !=)
|
||||
|
||||
#define weston_assert_ptr_is_null(compositor, a) \
|
||||
#define weston_assert_ptr_null(compositor, a) \
|
||||
weston_assert_(compositor, a, NULL, const void *, "%p", ==)
|
||||
|
||||
#define weston_assert_ptr_eq(compositor, a, b) \
|
||||
|
|
|
|||
|
|
@ -99,16 +99,16 @@ TEST(asserts)
|
|||
ret = weston_assert_true(compositor, true && false);
|
||||
abort_if_not(ret == false);
|
||||
|
||||
ret = weston_assert_ptr(compositor, &ret);
|
||||
ret = weston_assert_ptr_not_null(compositor, &ret);
|
||||
abort_if_not(ret);
|
||||
|
||||
ret = weston_assert_ptr(compositor, NULL);
|
||||
ret = weston_assert_ptr_not_null(compositor, NULL);
|
||||
abort_if_not(ret == false);
|
||||
|
||||
ret = weston_assert_ptr_is_null(compositor, NULL);
|
||||
ret = weston_assert_ptr_null(compositor, NULL);
|
||||
abort_if_not(ret);
|
||||
|
||||
ret = weston_assert_ptr_is_null(compositor, &ret);
|
||||
ret = weston_assert_ptr_null(compositor, &ret);
|
||||
abort_if_not(ret == false);
|
||||
|
||||
ret = weston_assert_ptr_eq(compositor, &ret, &ret);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue