[cairo] [PATCH 15/72] image: typecasting helpers

Enrico Weigelt, metux IT consult enrico.weigelt at gr13.net
Tue Dec 29 07:38:59 PST 2015

On 29.12.2015 15:52, Chris Wilson wrote:
>> +static cairo_always_inline cairo_image_surface_t *
>> +_cairo_surface_cast_image ( cairo_surface_t *surface )
>> +{
>> +    assert (surface != NULL);
> The assert here is pretty pointless. *NULL are easy enough to spot, all
> incoming surfaces are defined (either real or error surfaces, and we
> have said that anything else is undefined), so that leaves the internal
> surface passing for which we sometimes use a temporary NULL for
> unsupported.

Okay, at that specific point, the assert can be dropped.

I only added it, because quite recently we talked about adding more
asserts whereever some assumptions are made.

> I would rather see an attribute((nonnull)) annotations rather than
> assert (the attribute would need to be propagated back through the
> function pointers etc).

Yes, of course, but that probably would be a bigger changeset.

OTOH, I already planned a similar big change, replace void* by
cairo_surface_t ... should we do it that way (and also add nunnull
attribute ?


Enrico Weigelt,
metux IT consulting

More information about the cairo mailing list