The function calls that get the new treatment here are:
_cairo_meta_surface_replay
_cairo_surface_show_page
_cairo_array_append
all within _cairo_svg_surface_emit_meta_surface
This new test exercises every path where the user might possibly
pass in an invalid matrix. Currently the test fails if no error
is reported. Also, if an incorrect error is reported, (such as
CAIRO_STATUS_NO_MEMORY instead of CAIRO_STATUS_INVALID_MATRIX),
this is logged as a warning in invalid-matrix.log, but the test
still passes.
It would still be worthwhile to follow up quickly and fix those
cases to propagate the correct error value.
Also fix all callers to notice and propagate the error, (though
some paths will still lose the CAIRO_STATUS_INVALID_MATRIX value
due to a return value of NULL at one point).
Fixing this uncovered a leak of a CAIRO_INT_STATUS_UNSUPPORTED value
up to cairo_show_page, (and similarly to cairo_copy_page). There was
really no good reason for _cairo_surface_show_page and
_cairo_surface_copy_page to be returning cairo_int_status_t. Fix
this by simply handling the UNSUPPORTED return at the surface layer
instead of the gstate layer.
Obviously, the new name is _cairo_pdf_surface_emit_to_unicode_stream which
is consistent with the to_unicode_stream identifiers already existing in
the implementation.
This class of functions modify their argument and return it as a
*convenience* for the caller. For example, within cairo a common idiom is:
cairo_object_reference (new);
cairo_object_unreference (this->obj);
this->obj = new;
which updates the member to the new object irrespective of whether the
new object is the same as the one being replaced. Other issues arise
with subtypes, as the return type is the parent's and so require more
complicated handling to compile cleanly.
Disabling the warning is therefore preferred over adding code which
decreases readibility and reduces maintainability. We need to make the
compiler work for us, not against us...
As previously implemented, there's no essential information in the
return value from _cairo_dotostr, (the caller can simply use strlen
to recompute the same value, which is what the only caller is already
doing).
There would be real information in a return value which would return
the result from the call to snprintf for the case where the buffer is
not large enough for the number being printed.
Add a _cairo_traps_status function and use it instead of adding
error checks to callers of _cairo_traps_add_trap and
_cairo_traps_add_trap_from_points, (both of which are now given
a void return type).
Note: It looks like it would be convenient to shove a status value
into cairo_path_fixed_t to reduce this sequence of error checks.
But I tried that first, and it actually makes things worse overall
due to many things like _cairo_path_fixed_move_to called by
cairo_move_to where the result must be immediately checked anyway.
So I've already rejected that approach.
Now, the functions to add new data to a polygon all become void,
and there's a new _cairo_polygon_status call to query the status
at the end of a sequence of operations.
With this change, we fix many callerswhich were previously not
checking the return values of _cairo_polygon functions by adding
only a single call to _cairo_polygon_status rathern than several
new checks.
The cairo_image_surface_create function never returns NULL so
the previous error checks would never have triggered. The correct
approach is to check the result of cairo_surface_status().