cairo/src/check-headers.sh
Chris Wilson 46eab95698 Add attribute(warn_unused_result)
This adds a compiler check that the function result is used by the caller
and enables it by default for all cairo_private functions and for public
API that returns a cairo_status_t.

It has been discussed that to extend the warnings to all functions, a
new function type could been introduced to cover static functions:
cairo_static. This has not been done at the present time in order to
minimise the churn and focus on the more common errors.

In order to reduce the warning spew generated by gcc for invalid use of
this attribute, -Wno-attributes is added to CFLAGS. This has the
unfortunate side-effect of masking future warnings for all attributes -
be warned!
2007-04-09 15:01:58 +01:00

21 lines
484 B
Bash
Executable file

#!/bin/sh
LANG=C
test -z "$srcdir" && srcdir=.
status=0
echo Checking public headers for missing cairo_public decorators
find "$srcdir" -name '*.h' ! -name '*-private.h' ! -name '*-test.h' ! -name 'cairoint.h' |
xargs grep -B 1 '^cairo_.*[ ]\+(' |
awk '
/^--$/ { context=""; public=0; next; }
/:cairo_.*[ ]+\(/ { if (!public) {print context; print; print "--";} next; }
/-cairo_public.*[ ]/ {public=1;}
{ context=$0; }
' |
sed 's/[.]h-/.h:/' |
grep . && status=1
exit $status