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:
Loïc Molinari 2025-01-31 12:34:31 +01:00
parent c855bc7af0
commit 9373e76655
10 changed files with 26 additions and 26 deletions

View file

@ -570,7 +570,7 @@ drm_output_find_plane_for_view(struct drm_output_state *state,
possible_plane_mask &= fb->plane_mask; possible_plane_mask &= fb->plane_mask;
} else { } else {
char *fr_str = bits_to_str(fb_failure_reasons, failure_reasons_to_str); 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); drm_debug(b, "\t\t\t[view] couldn't get FB for view: %s\n", fr_str);
free(fr_str); free(fr_str);
pnode->try_view_on_plane_failure_reasons |= fb_failure_reasons; 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) { } else if (!ps) {
char *fr_str = bits_to_str(pnode->try_view_on_plane_failure_reasons, char *fr_str = bits_to_str(pnode->try_view_on_plane_failure_reasons,
failure_reasons_to_str); 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 " drm_debug(b, "\t\t\t\t[view] view %p will be placed "
"on the renderer: %s\n", ev, fr_str); "on the renderer: %s\n", ev, fr_str);
free(fr_str); free(fr_str);

View file

@ -385,20 +385,20 @@ cmlcms_init(struct weston_color_manager *cm_base)
weston_compositor_add_log_scope(compositor, "color-lcms-transformations", weston_compositor_add_log_scope(compositor, "color-lcms-transformations",
"Color transformation creation and destruction.\n", "Color transformation creation and destruction.\n",
transforms_scope_new_sub, NULL, cm); 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 = cm->optimizer_scope =
weston_compositor_add_log_scope(compositor, "color-lcms-optimizer", weston_compositor_add_log_scope(compositor, "color-lcms-optimizer",
"Color transformation pipeline optimizer. It's best " \ "Color transformation pipeline optimizer. It's best " \
"used together with the color-lcms-transformations " \ "used together with the color-lcms-transformations " \
"log scope.\n", NULL, NULL, NULL); "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 = cm->profiles_scope =
weston_compositor_add_log_scope(compositor, "color-lcms-profiles", weston_compositor_add_log_scope(compositor, "color-lcms-profiles",
"Color profile creation and destruction.\n", "Color profile creation and destruction.\n",
profiles_scope_new_sub, NULL, cm); 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); cm->lcms_ctx = cmsCreateContext(NULL, cm);
if (!cm->lcms_ctx) { if (!cm->lcms_ctx) {

View file

@ -298,7 +298,7 @@ ensure_output_profile_extract(struct cmlcms_color_profile *cprof,
cprof->icc.profile, num_points, cprof->icc.profile, num_points,
err_msg); err_msg);
if (ret) if (ret)
weston_assert_ptr(compositor, cprof->extract.eotf.p); weston_assert_ptr_not_null(compositor, cprof->extract.eotf.p);
break; break;
case CMLCMS_PROFILE_TYPE_PARAMS: case CMLCMS_PROFILE_TYPE_PARAMS:
/* TODO: need to address this when we create param profiles. */ /* TODO: need to address this when we create param profiles. */

View file

@ -1255,7 +1255,7 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
chain[chain_len++] = output_profile->extract.vcgt; chain[chain_len++] = output_profile->extract.vcgt;
/* Render intent does not apply here, but need to set something. */ /* 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, render_intent = weston_render_intent_info_from(cm->base.compositor,
WESTON_RENDER_INTENT_ABSOLUTE); WESTON_RENDER_INTENT_ABSOLUTE);
break; break;
@ -1268,7 +1268,7 @@ xform_realize_chain(struct cmlcms_color_transform *xform)
} }
assert(chain_len <= ARRAY_LENGTH(chain)); 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. * Binding to our LittleCMS plug-in occurs here.

View file

@ -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 * 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. * 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. */ * 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, cm_image_desc = cm_image_desc_create(compositor->color_manager,
output->color_profile, client, output->color_profile, client,

View file

@ -167,7 +167,7 @@ cmnoop_get_surface_color_transform(struct weston_color_manager *cm_base,
cmnoop->stock_cprof); cmnoop->stock_cprof);
/* The output must have a cprof, and it has to be the stock one. */ /* 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), weston_assert_ptr_eq(compositor, to_cmnoop_cprof(output->color_profile),
cmnoop->stock_cprof); 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_color_manager_noop *cmnoop = to_cmnoop(cm_base);
struct weston_output_color_outcome *co; 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), weston_assert_ptr_eq(compositor, to_cmnoop_cprof(output->color_profile),
cmnoop->stock_cprof); cmnoop->stock_cprof);

View file

@ -101,7 +101,7 @@ weston_color_profile_param_builder_create(struct weston_compositor *compositor)
builder->err_fp = open_memstream(&builder->err_msg, builder->err_fp = open_memstream(&builder->err_msg,
&builder->err_msg_size); &builder->err_msg_size);
weston_assert_ptr(compositor, builder->err_fp); weston_assert_ptr_not_null(compositor, builder->err_fp);
return builder; return builder;
} }

View file

@ -97,7 +97,7 @@ params_add(struct wl_client *client,
} }
weston_assert_ptr_eq(buffer->compositor, buffer->params_resource, params_resource); 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) { if (plane_idx >= MAX_DMABUF_PLANES) {
wl_resource_post_error(params_resource, 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); buffer = wl_resource_get_user_data(resource);
weston_assert_ptr_eq(buffer->compositor, buffer->buffer_resource, 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) if (buffer->user_data_destroy_func)
buffer->user_data_destroy_func(buffer); 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_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 /* Switch the linux_dmabuf_buffer object from params resource to
* eventually wl_buffer resource. * eventually wl_buffer resource.
@ -971,8 +971,8 @@ linux_dmabuf_buffer_get(struct weston_compositor *compositor,
return NULL; return NULL;
buffer = wl_resource_get_user_data(resource); buffer = wl_resource_get_user_data(resource);
weston_assert_ptr(compositor, buffer); weston_assert_ptr_not_null(compositor, buffer);
weston_assert_ptr_is_null(compositor, buffer->params_resource); weston_assert_ptr_null(compositor, buffer->params_resource);
weston_assert_ptr_eq(compositor, buffer->buffer_resource, resource); weston_assert_ptr_eq(compositor, buffer->buffer_resource, resource);
return buffer; 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 /* 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. */ * 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); supported_formats = compositor->renderer->get_supported_formats(compositor);
wl_array_for_each(fmt, &supported_formats->arr) { 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; struct wl_resource *display_resource;
uint32_t id; 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); id = wl_resource_get_id(buffer->buffer_resource);
client = wl_resource_get_client(buffer->buffer_resource); client = wl_resource_get_client(buffer->buffer_resource);
display_resource = wl_client_get_object(client, 1); 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_resource_post_error(display_resource,
WL_DISPLAY_ERROR_INVALID_OBJECT, WL_DISPLAY_ERROR_INVALID_OBJECT,
"linux_dmabuf server error with " "linux_dmabuf server error with "

View file

@ -88,10 +88,10 @@ do { \
#define weston_assert_false(compositor, a) \ #define weston_assert_false(compositor, a) \
weston_assert_(compositor, a, false, bool, "%d", ==) 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", !=) 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", ==) weston_assert_(compositor, a, NULL, const void *, "%p", ==)
#define weston_assert_ptr_eq(compositor, a, b) \ #define weston_assert_ptr_eq(compositor, a, b) \

View file

@ -99,16 +99,16 @@ TEST(asserts)
ret = weston_assert_true(compositor, true && false); ret = weston_assert_true(compositor, true && false);
abort_if_not(ret == false); abort_if_not(ret == false);
ret = weston_assert_ptr(compositor, &ret); ret = weston_assert_ptr_not_null(compositor, &ret);
abort_if_not(ret); abort_if_not(ret);
ret = weston_assert_ptr(compositor, NULL); ret = weston_assert_ptr_not_null(compositor, NULL);
abort_if_not(ret == false); abort_if_not(ret == false);
ret = weston_assert_ptr_is_null(compositor, NULL); ret = weston_assert_ptr_null(compositor, NULL);
abort_if_not(ret); abort_if_not(ret);
ret = weston_assert_ptr_is_null(compositor, &ret); ret = weston_assert_ptr_null(compositor, &ret);
abort_if_not(ret == false); abort_if_not(ret == false);
ret = weston_assert_ptr_eq(compositor, &ret, &ret); ret = weston_assert_ptr_eq(compositor, &ret, &ret);