Do not warn when ignoring the return value of _cairo_rectangle_intersect()

gcc complains that

cairo-surface-wrapper.c:647: warning: ignoring return value of
‘_cairo_rectangle_intersect’, declared with attribute warn_unused_result

It can be silenced by making _cairo_rectangle_intersect()
cairo_private_no_warn. This makes it possible to avoid unused
temporary variables in other places and reduces the dead assignments
reported by clang static analyzer from 114 to 98.
This commit is contained in:
Andrea Canciani 2011-03-18 16:57:04 +01:00
parent 628ef17aca
commit ab8c108b88
8 changed files with 19 additions and 43 deletions

View file

@ -272,14 +272,13 @@ static void
_rectangle_intersect_clip (cairo_rectangle_int_t *extents, cairo_clip_t *clip)
{
const cairo_rectangle_int_t *clip_extents;
cairo_bool_t is_empty;
clip_extents = NULL;
if (clip != NULL)
clip_extents = _cairo_clip_get_extents (clip);
if (clip_extents != NULL)
is_empty = _cairo_rectangle_intersect (extents, clip_extents);
_cairo_rectangle_intersect (extents, clip_extents);
}
static void
@ -297,7 +296,7 @@ _cairo_analysis_surface_operation_extents (cairo_analysis_surface_t *surface,
cairo_rectangle_int_t source_extents;
_cairo_pattern_get_extents (source, &source_extents);
is_empty = _cairo_rectangle_intersect (extents, &source_extents);
_cairo_rectangle_intersect (extents, &source_extents);
}
_rectangle_intersect_clip (extents, clip);
@ -343,7 +342,6 @@ _cairo_analysis_surface_mask (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_int_status_t backend_status;
cairo_rectangle_int_t extents;
cairo_bool_t is_empty;
if (surface->target->backend->mask == NULL) {
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@ -392,8 +390,7 @@ _cairo_analysis_surface_mask (void *abstract_surface,
cairo_rectangle_int_t mask_extents;
_cairo_pattern_get_extents (mask, &mask_extents);
is_empty = _cairo_rectangle_intersect (&extents, &mask_extents);
_cairo_rectangle_intersect (&extents, &mask_extents);
}
return _add_operation (surface, &extents, backend_status);
@ -414,7 +411,6 @@ _cairo_analysis_surface_stroke (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t backend_status;
cairo_rectangle_int_t extents;
cairo_bool_t is_empty;
if (surface->target->backend->stroke == NULL) {
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@ -447,7 +443,7 @@ _cairo_analysis_surface_stroke (void *abstract_surface,
if (unlikely (status))
return status;
is_empty = _cairo_rectangle_intersect (&extents, &mask_extents);
_cairo_rectangle_intersect (&extents, &mask_extents);
}
return _add_operation (surface, &extents, backend_status);
@ -466,7 +462,6 @@ _cairo_analysis_surface_fill (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t backend_status;
cairo_rectangle_int_t extents;
cairo_bool_t is_empty;
if (surface->target->backend->fill == NULL) {
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@ -493,7 +488,7 @@ _cairo_analysis_surface_fill (void *abstract_surface,
_cairo_path_fixed_fill_extents (path, fill_rule, tolerance,
&mask_extents);
is_empty = _cairo_rectangle_intersect (&extents, &mask_extents);
_cairo_rectangle_intersect (&extents, &mask_extents);
}
return _add_operation (surface, &extents, backend_status);
@ -512,7 +507,6 @@ _cairo_analysis_surface_show_glyphs (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t status, backend_status;
cairo_rectangle_int_t extents, glyph_extents;
cairo_bool_t is_empty;
/* Adapted from _cairo_surface_show_glyphs */
if (surface->target->backend->show_glyphs != NULL) {
@ -561,7 +555,7 @@ _cairo_analysis_surface_show_glyphs (void *abstract_surface,
if (unlikely (status))
return status;
is_empty = _cairo_rectangle_intersect (&extents, &glyph_extents);
_cairo_rectangle_intersect (&extents, &glyph_extents);
}
return _add_operation (surface, &extents, backend_status);
@ -592,7 +586,6 @@ _cairo_analysis_surface_show_text_glyphs (void *abstract_surface,
cairo_analysis_surface_t *surface = abstract_surface;
cairo_status_t status, backend_status;
cairo_rectangle_int_t extents, glyph_extents;
cairo_bool_t is_empty;
/* Adapted from _cairo_surface_show_glyphs */
backend_status = CAIRO_INT_STATUS_UNSUPPORTED;
@ -645,7 +638,7 @@ _cairo_analysis_surface_show_text_glyphs (void *abstract_surface,
if (unlikely (status))
return status;
is_empty = _cairo_rectangle_intersect (&extents, &glyph_extents);
_cairo_rectangle_intersect (&extents, &glyph_extents);
}
return _add_operation (surface, &extents, backend_status);

View file

@ -368,7 +368,6 @@ _cairo_clip_path_reapply_clip_path_transform (cairo_clip_t *clip,
{
cairo_status_t status;
cairo_clip_path_t *clip_path;
cairo_bool_t is_empty;
if (other_path->prev != NULL) {
status = _cairo_clip_path_reapply_clip_path_transform (clip,
@ -394,8 +393,8 @@ _cairo_clip_path_reapply_clip_path_transform (cairo_clip_t *clip,
_cairo_path_fixed_approximate_clip_extents (&clip_path->path,
&clip_path->extents);
if (clip_path->prev != NULL) {
is_empty = _cairo_rectangle_intersect (&clip_path->extents,
&clip_path->prev->extents);
_cairo_rectangle_intersect (&clip_path->extents,
&clip_path->prev->extents);
}
clip_path->fill_rule = other_path->fill_rule;
@ -1399,7 +1398,6 @@ intersect_with_boxes (cairo_composite_rectangles_t *extents,
{
cairo_rectangle_int_t rect;
cairo_box_t box;
cairo_bool_t is_empty;
box.p1.x = box.p1.y = INT_MIN;
box.p2.x = box.p2.y = INT_MAX;
@ -1416,8 +1414,8 @@ intersect_with_boxes (cairo_composite_rectangles_t *extents,
}
_cairo_box_round_to_rectangle (&box, &rect);
is_empty = _cairo_rectangle_intersect (&extents->bounded, &rect);
is_empty = _cairo_rectangle_intersect (&extents->unbounded, &rect);
_cairo_rectangle_intersect (&extents->bounded, &rect);
_cairo_rectangle_intersect (&extents->unbounded, &rect);
}
cairo_status_t

View file

@ -1511,9 +1511,7 @@ _cairo_gstate_int_clip_extents (cairo_gstate_t *gstate,
clip_extents = _cairo_clip_get_extents (&gstate->clip);
if (clip_extents != NULL) {
cairo_bool_t is_empty;
is_empty = _cairo_rectangle_intersect (extents, clip_extents);
_cairo_rectangle_intersect (extents, clip_extents);
is_bounded = TRUE;
}

View file

@ -3782,7 +3782,6 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
int tx, ty;
double pad;
cairo_bool_t is_identity;
cairo_bool_t is_empty;
cairo_bool_t is_bounded;
cairo_int_status_t status;
@ -3953,7 +3952,7 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
if ( _cairo_surface_get_extents (surface, &extents)) {
if (attr->extend == CAIRO_EXTEND_NONE) {
/* Never acquire a larger area than the source itself */
is_empty = _cairo_rectangle_intersect (&extents, &sampled_area);
_cairo_rectangle_intersect (&extents, &sampled_area);
} else {
int trim = 0;
@ -3979,13 +3978,9 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t *pat
/* source is wholly contained within extents, drop the REPEAT */
attr->extend = CAIRO_EXTEND_NONE;
}
is_empty = extents.width == 0 || extents.height == 0;
}
}
/* XXX can we use is_empty? */
status = _cairo_surface_clone_similar (dst, surface,
extents.x, extents.y,
extents.width, extents.height,

View file

@ -6309,14 +6309,12 @@ _cairo_pdf_surface_fill_stroke (void *abstract_surface,
/* use the more accurate extents */
if (extents.is_bounded) {
cairo_bool_t is_empty;
_cairo_path_fixed_fill_extents (path,
fill_rule,
fill_tolerance,
&extents.mask);
is_empty = ! _cairo_rectangle_intersect (&extents.bounded, &extents.mask);
_cairo_rectangle_intersect (&extents.bounded, &extents.mask);
}
fill_pattern_res.id = 0;
@ -6343,8 +6341,6 @@ _cairo_pdf_surface_fill_stroke (void *abstract_surface,
/* use the more accurate extents */
if (extents.is_bounded) {
cairo_bool_t is_empty;
status = _cairo_path_fixed_stroke_extents (path, stroke_style,
stroke_ctm, stroke_ctm_inverse,
stroke_tolerance,
@ -6352,7 +6348,7 @@ _cairo_pdf_surface_fill_stroke (void *abstract_surface,
if (unlikely (status))
return status;
is_empty = ! _cairo_rectangle_intersect (&extents.bounded, &extents.mask);
_cairo_rectangle_intersect (&extents.bounded, &extents.mask);
}
stroke_pattern_res.id = 0;

View file

@ -694,7 +694,7 @@ cairo_push_group_with_content (cairo_t *cr, cairo_content_t content)
is_empty = _cairo_surface_get_extents (parent_surface, &extents);
clip_extents = _cairo_clip_get_extents (_cairo_gstate_get_clip (cr->gstate));
if (clip_extents != NULL)
is_empty = _cairo_rectangle_intersect (&extents, clip_extents);
_cairo_rectangle_intersect (&extents, clip_extents);
group_surface = _cairo_surface_create_similar_solid (parent_surface,
content,

View file

@ -283,7 +283,7 @@ _cairo_unbounded_rectangle_init (cairo_rectangle_int_t *rect)
rect->height = CAIRO_RECT_INT_MAX - CAIRO_RECT_INT_MIN;
}
cairo_private cairo_bool_t
cairo_private_no_warn cairo_bool_t
_cairo_rectangle_intersect (cairo_rectangle_int_t *dst,
const cairo_rectangle_int_t *src);

View file

@ -1502,12 +1502,8 @@ sampled_area (const cairo_surface_pattern_t *pattern,
sample->width = ceil (x2 + pad) - sample->x;
sample->height = ceil (y2 + pad) - sample->y;
if (_cairo_surface_get_extents (pattern->surface, &surface_extents)) {
cairo_bool_t is_empty;
is_empty = _cairo_rectangle_intersect (sample,
&surface_extents);
}
if (_cairo_surface_get_extents (pattern->surface, &surface_extents))
_cairo_rectangle_intersect (sample, &surface_extents);
return filter;
}