[cairo] [PATCH 5/5] fallback: Silence gcc warning

Andrea Canciani ranma42 at gmail.com
Fri Mar 18 14:26:40 PDT 2011


On Fri, Mar 18, 2011 at 7:27 PM, Maarten Bosmans <mkbosmans at gmail.com> wrote:
> 2011/3/18 Andrea Canciani <ranma42 at gmail.com>:
>> gcc complains that
>>
>> cairo-surface-wrapper.c:647: warning: ignoring return value of
>> ‘_cairo_rectangle_intersect’, declared with attribute warn_unused_result
>>
>> Storing the result in a variable (which is otherwise unused) makes gcc
>> happy.
>
> Wouldn't that make GCC complain (but perhaps not in with the default
> warning settings) about a set but never read variable? At least the
> clang static code analyzer would complain for sure.

I know and this is basically what I point out in the commit message.

>
> The solution Bill gives looks more reasonable.

He suggests a behavior, but does not provide a solution.
How can be a function attributed not to report that its result is unused?
(I would be happy to have a more pleasant-looking code, but I don't know
how to un-attribute a function)

Moreover, even if Bill's suggestion it looks very reasonable, in cairo
these temporary
variables are quite common. See, for example, _cairo_gstate_int_clip_extents().

Andrea


More information about the cairo mailing list