[cairo] Add attribute(warn_unused_result)
Chris Wilson
chris at chris-wilson.co.uk
Wed Mar 21 09:51:34 PDT 2007
By adding the gcc warn_unused_result attribute to the function
definitions, we can catch the a common mistake of forgetting to check
for an error returned from a function at compile time.
As could be expected from the coverage and testing pattern this method
found far more mistakes than the random malloc-failure method, but it
also failed to detect some of logic errors that the failure mode testing
revealed.
-------------- next part --------------
>From 1947a07fed338d723eaf5c258dbacb4aa1a838ba Mon Sep 17 00:00:00 2001
From: Chris Wilson <chris at chris-wilson.co.uk>
Date: Wed, 21 Mar 2007 13:04:53 +0000
Subject: [PATCH] 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.
Unfortunately, I have found no way to disable the spurious warnings from
gcc when applying the attribute to variables or functions returning void.
To placate gcc, new function types have been introduced to manually avoid
the warning. So we now have cairo_public_warn/cairo_public and
cairo_private/cairo_private_no_warn - choosen as the majority of internal
functions should be checking for errors!, whereas only a minority of the
public API requires an immediate error check.
To extend the warning to all functions, a new function type has been
introduced to cover static functions: cairo_static/cairo_static_no_warn.
---
configure.in | 10 ++
src/cairo-arc-private.h | 4 +-
src/cairo-cache-private.h | 8 +-
src/cairo-clip-private.h | 12 +-
src/cairo-freelist-private.h | 6 +-
src/cairo-ft-private.h | 2 +-
src/cairo-hash-private.h | 6 +-
src/cairo-output-stream-private.h | 14 +-
src/cairo-output-stream.c | 4 +-
src/cairo-paginated-surface.c | 4 +-
src/cairo-path-private.h | 2 +-
src/cairo-scaled-font-subsets-private.h | 10 +-
src/cairo-skiplist-private.h | 8 +-
src/cairo.h | 40 +++---
src/cairoint.h | 205 ++++++++++++++++---------------
src/check-headers.sh | 2 +-
16 files changed, 178 insertions(+), 159 deletions(-)
diff --git a/configure.in b/configure.in
index 0b3e9fa..500f121 100644
--- a/configure.in
+++ b/configure.in
@@ -823,9 +823,19 @@ AC_CONFIG_COMMANDS([src/cairo-features.h],
# define CAIRO_END_DECLS
#endif
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#define CAIRO_WARN_UNUSED_RESULT \
+ __attribute__((__warn_unused_result__))
+#else
+#define CAIRO_WARN_UNUSED_RESULT
+#endif /* __GNUC__ */
+
#ifndef cairo_public
# define cairo_public
#endif
+#ifndef cairo_public_warn
+# define cairo_public_warn CAIRO_WARN_UNUSED_RESULT
+#endif
#define CAIRO_VERSION_MAJOR $CAIRO_VERSION_MAJOR
#define CAIRO_VERSION_MINOR $CAIRO_VERSION_MINOR
diff --git a/src/cairo-arc-private.h b/src/cairo-arc-private.h
index 633fbfa..6885103 100644
--- a/src/cairo-arc-private.h
+++ b/src/cairo-arc-private.h
@@ -38,7 +38,7 @@
#include "cairoint.h"
-cairo_private void
+cairo_private_no_warn void
_cairo_arc_path (cairo_t *cr,
double xc,
double yc,
@@ -46,7 +46,7 @@ _cairo_arc_path (cairo_t *cr,
double angle1,
double angle2);
-cairo_private void
+cairo_private_no_warn void
_cairo_arc_path_negative (cairo_t *cr,
double xc,
double yc,
diff --git a/src/cairo-cache-private.h b/src/cairo-cache-private.h
index 566dbe2..836963f 100644
--- a/src/cairo-cache-private.h
+++ b/src/cairo-cache-private.h
@@ -99,13 +99,13 @@ _cairo_cache_create (cairo_cache_keys_equal_func_t keys_equal,
cairo_destroy_func_t entry_destroy,
unsigned long max_size);
-cairo_private void
+cairo_private_no_warn void
_cairo_cache_destroy (cairo_cache_t *cache);
-cairo_private void
+cairo_private_no_warn void
_cairo_cache_freeze (cairo_cache_t *cache);
-cairo_private void
+cairo_private_no_warn void
_cairo_cache_thaw (cairo_cache_t *cache);
cairo_private cairo_bool_t
@@ -117,7 +117,7 @@ cairo_private cairo_status_t
_cairo_cache_insert (cairo_cache_t *cache,
cairo_cache_entry_t *entry);
-cairo_private void
+cairo_private_no_warn void
_cairo_cache_foreach (cairo_cache_t *cache,
cairo_cache_callback_func_t cache_callback,
void *closure);
diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index 3c4ff0d..c2d2036 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -38,7 +38,7 @@
#include "cairo-path-fixed-private.h"
-extern cairo_private const cairo_rectangle_list_t _cairo_rectangles_nil;
+extern const cairo_private_no_warn cairo_rectangle_list_t _cairo_rectangles_nil;
struct _cairo_clip_path {
unsigned int ref_count;
@@ -80,16 +80,16 @@ struct _cairo_clip {
cairo_clip_path_t *path;
};
-cairo_private void
+cairo_private_no_warn void
_cairo_clip_init (cairo_clip_t *clip, cairo_surface_t *target);
-cairo_private void
+cairo_private_no_warn void
_cairo_clip_fini (cairo_clip_t *clip);
-cairo_private void
+cairo_private_no_warn void
_cairo_clip_init_copy (cairo_clip_t *clip, cairo_clip_t *other);
-cairo_private void
+cairo_private_no_warn void
_cairo_clip_init_deep_copy (cairo_clip_t *clip,
cairo_clip_t *other,
cairo_surface_t *target);
@@ -121,7 +121,7 @@ _cairo_clip_combine_to_surface (cairo_clip_t *clip,
int dst_y,
const cairo_rectangle_int16_t *extents);
-cairo_private void
+cairo_private_no_warn void
_cairo_clip_translate (cairo_clip_t *clip,
cairo_fixed_t tx,
cairo_fixed_t ty);
diff --git a/src/cairo-freelist-private.h b/src/cairo-freelist-private.h
index 41855f7..0631c9c 100644
--- a/src/cairo-freelist-private.h
+++ b/src/cairo-freelist-private.h
@@ -43,11 +43,11 @@ struct _cairo_freelist {
/* Initialise a freelist that will be responsible for allocating
* nodes of size nodesize. */
-cairo_private void
+cairo_private_no_warn void
_cairo_freelist_init (cairo_freelist_t *freelist, unsigned nodesize);
/* Deallocate any nodes in the freelist. */
-cairo_private void
+cairo_private_no_warn void
_cairo_freelist_fini (cairo_freelist_t *freelist);
/* Allocate a new node from the freelist. If the freelist contains no
@@ -67,7 +67,7 @@ _cairo_freelist_calloc (cairo_freelist_t *freelist);
/* Return a node to the freelist. This does not deallocate the memory,
* but makes it available for later reuse by
* _cairo_freelist_alloc(). */
-cairo_private void
+cairo_private_no_warn void
_cairo_freelist_free (cairo_freelist_t *freelist, void *node);
#endif /* CAIRO_FREELIST_H */
diff --git a/src/cairo-ft-private.h b/src/cairo-ft-private.h
index 3e28f5e..53b03b9 100644
--- a/src/cairo-ft-private.h
+++ b/src/cairo-ft-private.h
@@ -61,7 +61,7 @@ _cairo_ft_scaled_font_get_unscaled_font (cairo_scaled_font_t *scaled_font);
cairo_private FT_Face
_cairo_ft_unscaled_font_lock_face (cairo_ft_unscaled_font_t *unscaled);
-cairo_private void
+cairo_private_no_warn void
_cairo_ft_unscaled_font_unlock_face (cairo_ft_unscaled_font_t *unscaled);
cairo_private cairo_bool_t
diff --git a/src/cairo-hash-private.h b/src/cairo-hash-private.h
index 617b841..68b4cff 100644
--- a/src/cairo-hash-private.h
+++ b/src/cairo-hash-private.h
@@ -97,7 +97,7 @@ typedef void
cairo_private cairo_hash_table_t *
_cairo_hash_table_create (cairo_hash_keys_equal_func_t keys_equal);
-cairo_private void
+cairo_private_no_warn void
_cairo_hash_table_destroy (cairo_hash_table_t *hash_table);
cairo_private cairo_bool_t
@@ -113,11 +113,11 @@ cairo_private cairo_status_t
_cairo_hash_table_insert (cairo_hash_table_t *hash_table,
cairo_hash_entry_t *entry);
-cairo_private void
+cairo_private_no_warn void
_cairo_hash_table_remove (cairo_hash_table_t *hash_table,
cairo_hash_entry_t *key);
-cairo_private void
+cairo_private_no_warn void
_cairo_hash_table_foreach (cairo_hash_table_t *hash_table,
cairo_hash_callback_func_t hash_callback,
void *closure);
diff --git a/src/cairo-output-stream-private.h b/src/cairo-output-stream-private.h
index d68fbb4..7ed5cf4 100644
--- a/src/cairo-output-stream-private.h
+++ b/src/cairo-output-stream-private.h
@@ -53,9 +53,9 @@ struct _cairo_output_stream {
cairo_bool_t closed;
};
-extern const cairo_private cairo_output_stream_t cairo_output_stream_nil;
+extern const cairo_private_no_warn cairo_output_stream_t cairo_output_stream_nil;
-cairo_private void
+cairo_private_no_warn void
_cairo_output_stream_init (cairo_output_stream_t *stream,
cairo_output_stream_write_func_t write_func,
cairo_output_stream_close_func_t close_func);
@@ -98,11 +98,11 @@ _cairo_output_stream_close (cairo_output_stream_t *stream);
cairo_private cairo_status_t
_cairo_output_stream_destroy (cairo_output_stream_t *stream);
-cairo_private void
+cairo_private_no_warn void
_cairo_output_stream_write (cairo_output_stream_t *stream,
const void *data, size_t length);
-cairo_private void
+cairo_private_no_warn void
_cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
const char *data,
size_t length);
@@ -110,11 +110,11 @@ _cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
cairo_private int
_cairo_dtostr (char *buffer, size_t size, double d);
-cairo_private void
+cairo_private_no_warn void
_cairo_output_stream_vprintf (cairo_output_stream_t *stream,
const char *fmt, va_list ap);
-cairo_private void
+cairo_private_no_warn void
_cairo_output_stream_printf (cairo_output_stream_t *stream,
const char *fmt, ...);
@@ -148,7 +148,7 @@ _cairo_output_stream_create_for_file (FILE *file);
cairo_private cairo_output_stream_t *
_cairo_memory_stream_create (void);
-cairo_private void
+cairo_private_no_warn void
_cairo_memory_stream_copy (cairo_output_stream_t *base,
cairo_output_stream_t *dest);
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index df3ae4d..8a6cacf 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -45,7 +45,7 @@
#endif /* _MSC_VER */
-cairo_private void
+void
_cairo_output_stream_init (cairo_output_stream_t *stream,
cairo_output_stream_write_func_t write_func,
cairo_output_stream_close_func_t close_func)
@@ -57,7 +57,7 @@ _cairo_output_stream_init (cairo_output_stream_t *stream,
stream->closed = FALSE;
}
-cairo_private cairo_status_t
+cairo_status_t
_cairo_output_stream_fini (cairo_output_stream_t *stream)
{
return _cairo_output_stream_close (stream);
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c
index c8e4612..64a9cbf 100644
--- a/src/cairo-paginated-surface.c
+++ b/src/cairo-paginated-surface.c
@@ -75,7 +75,7 @@ typedef struct _cairo_paginated_surface {
} cairo_paginated_surface_t;
-const cairo_private cairo_surface_backend_t cairo_paginated_surface_backend;
+static const cairo_surface_backend_t cairo_paginated_surface_backend;
static cairo_int_status_t
_cairo_paginated_surface_show_page (void *abstract_surface);
@@ -517,7 +517,7 @@ _cairo_paginated_surface_snapshot (void *abstract_other)
#endif
}
-const cairo_surface_backend_t cairo_paginated_surface_backend = {
+static const cairo_surface_backend_t cairo_paginated_surface_backend = {
CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
_cairo_paginated_surface_create_similar,
_cairo_paginated_surface_finish,
diff --git a/src/cairo-path-private.h b/src/cairo-path-private.h
index d855c19..9e505c0 100644
--- a/src/cairo-path-private.h
+++ b/src/cairo-path-private.h
@@ -39,7 +39,7 @@
#include "cairoint.h"
-extern const cairo_private cairo_path_t _cairo_path_nil;
+extern const cairo_private_no_warn cairo_path_t _cairo_path_nil;
cairo_private cairo_path_t *
_cairo_path_create (cairo_path_fixed_t *path,
diff --git a/src/cairo-scaled-font-subsets-private.h b/src/cairo-scaled-font-subsets-private.h
index 5104340..ba70875 100644
--- a/src/cairo-scaled-font-subsets-private.h
+++ b/src/cairo-scaled-font-subsets-private.h
@@ -77,7 +77,7 @@ _cairo_scaled_font_subsets_create (int max_glyphs_unscaled_per_subset,
*
* Destroys @font_subsets and all resources associated with it.
**/
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_font_subsets_destroy (cairo_scaled_font_subsets_t *font_subsets);
/**
@@ -250,7 +250,7 @@ _cairo_cff_subset_init (cairo_cff_subset_t *cff_subset,
* call, @cff_subset should not be used again without a
* subsequent call to _cairo_cff_subset_init() again first.
**/
-cairo_private void
+cairo_private_no_warn void
_cairo_cff_subset_fini (cairo_cff_subset_t *cff_subset);
typedef struct _cairo_truetype_subset {
@@ -292,7 +292,7 @@ _cairo_truetype_subset_init (cairo_truetype_subset_t *truetype_subset,
* call, @truetype_subset should not be used again without a
* subsequent call to _cairo_truetype_subset_init() again first.
**/
-cairo_private void
+cairo_private_no_warn void
_cairo_truetype_subset_fini (cairo_truetype_subset_t *truetype_subset);
@@ -338,7 +338,7 @@ _cairo_type1_subset_init (cairo_type1_subset_t *type_subset,
* @type1_subset should not be used again without a subsequent call to
* _cairo_truetype_type1_init() again first.
**/
-cairo_private void
+cairo_private_no_warn void
_cairo_type1_subset_fini (cairo_type1_subset_t *subset);
/**
@@ -391,7 +391,7 @@ _cairo_type1_fallback_init_hex (cairo_type1_subset_t *type_subset,
* @type1_subset should not be used again without a subsequent call to
* _cairo_truetype_type1_init() again first.
**/
-cairo_private void
+cairo_private_no_warn void
_cairo_type1_fallback_fini (cairo_type1_subset_t *subset);
/**
diff --git a/src/cairo-skiplist-private.h b/src/cairo-skiplist-private.h
index b152f4b..505f7fe 100644
--- a/src/cairo-skiplist-private.h
+++ b/src/cairo-skiplist-private.h
@@ -64,7 +64,7 @@ typedef struct _skip_list {
* sizeof) is passed for elt_size. Note that the structure used for
* list elements must have as its final member a skip_elt_t
*/
-cairo_private void
+cairo_private_no_warn void
_cairo_skip_list_init (cairo_skip_list_t *list,
cairo_skip_list_compare_t compare,
size_t elt_size);
@@ -73,7 +73,7 @@ _cairo_skip_list_init (cairo_skip_list_t *list,
/* Deallocate resources associated with a skip list and all elements
* in it. (XXX: currently this simply deletes all elements.)
*/
-cairo_private void
+cairo_private_no_warn void
_cairo_skip_list_fini (cairo_skip_list_t *list);
/* Insert a new element into the list at the correct sort order as
@@ -89,11 +89,11 @@ cairo_private void *
_cairo_skip_list_find (cairo_skip_list_t *list, void *data);
/* Delete an element which compare considers equal to <data> */
-cairo_private void
+cairo_private_no_warn void
_cairo_skip_list_delete (cairo_skip_list_t *list, void *data);
/* Delete the given element from the list. */
-cairo_private void
+cairo_private_no_warn void
_cairo_skip_list_delete_given (cairo_skip_list_t *list, skip_elt_t *given);
#endif
diff --git a/src/cairo.h b/src/cairo.h
index a80efde..5fc05e3 100644
--- a/src/cairo.h
+++ b/src/cairo.h
@@ -313,7 +313,7 @@ cairo_public void *
cairo_get_user_data (cairo_t *cr,
const cairo_user_data_key_t *key);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_set_user_data (cairo_t *cr,
const cairo_user_data_key_t *key,
void *user_data,
@@ -972,7 +972,7 @@ cairo_font_options_copy (const cairo_font_options_t *original);
cairo_public void
cairo_font_options_destroy (cairo_font_options_t *options);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_font_options_status (cairo_font_options_t *options);
cairo_public void
@@ -1088,7 +1088,7 @@ cairo_font_face_destroy (cairo_font_face_t *font_face);
cairo_public unsigned int
cairo_font_face_get_reference_count (cairo_font_face_t *font_face);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_font_face_status (cairo_font_face_t *font_face);
/**
@@ -1141,7 +1141,7 @@ cairo_public void *
cairo_font_face_get_user_data (cairo_font_face_t *font_face,
const cairo_user_data_key_t *key);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_font_face_set_user_data (cairo_font_face_t *font_face,
const cairo_user_data_key_t *key,
void *user_data,
@@ -1164,7 +1164,7 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font);
cairo_public unsigned int
cairo_scaled_font_get_reference_count (cairo_scaled_font_t *scaled_font);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_scaled_font_status (cairo_scaled_font_t *scaled_font);
cairo_public cairo_font_type_t
@@ -1174,7 +1174,7 @@ cairo_public void *
cairo_scaled_font_get_user_data (cairo_scaled_font_t *scaled_font,
const cairo_user_data_key_t *key);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_scaled_font_set_user_data (cairo_scaled_font_t *scaled_font,
const cairo_user_data_key_t *key,
void *user_data,
@@ -1392,7 +1392,7 @@ cairo_path_destroy (cairo_path_t *path);
/* Error status queries */
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_status (cairo_t *cr);
cairo_public const char *
@@ -1418,7 +1418,7 @@ cairo_surface_destroy (cairo_surface_t *surface);
cairo_public unsigned int
cairo_surface_get_reference_count (cairo_surface_t *surface);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_surface_status (cairo_surface_t *surface);
/**
@@ -1482,11 +1482,11 @@ cairo_surface_get_content (cairo_surface_t *surface);
#if CAIRO_HAS_PNG_FUNCTIONS
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_surface_write_to_png (cairo_surface_t *surface,
const char *filename);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_surface_write_to_png_stream (cairo_surface_t *surface,
cairo_write_func_t write_func,
void *closure);
@@ -1497,7 +1497,7 @@ cairo_public void *
cairo_surface_get_user_data (cairo_surface_t *surface,
const cairo_user_data_key_t *key);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_surface_set_user_data (cairo_surface_t *surface,
const cairo_user_data_key_t *key,
void *user_data,
@@ -1642,14 +1642,14 @@ cairo_pattern_destroy (cairo_pattern_t *pattern);
cairo_public unsigned int
cairo_pattern_get_reference_count (cairo_pattern_t *pattern);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_status (cairo_pattern_t *pattern);
cairo_public void *
cairo_pattern_get_user_data (cairo_pattern_t *pattern,
const cairo_user_data_key_t *key);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_set_user_data (cairo_pattern_t *pattern,
const cairo_user_data_key_t *key,
void *user_data,
@@ -1758,32 +1758,32 @@ cairo_pattern_set_filter (cairo_pattern_t *pattern, cairo_filter_t filter);
cairo_public cairo_filter_t
cairo_pattern_get_filter (cairo_pattern_t *pattern);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_get_rgba (cairo_pattern_t *pattern,
double *red, double *green,
double *blue, double *alpha);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_get_surface (cairo_pattern_t *pattern,
cairo_surface_t **surface);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_get_color_stop_rgba (cairo_pattern_t *pattern,
int index, double *offset,
double *red, double *green,
double *blue, double *alpha);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_get_color_stop_count (cairo_pattern_t *pattern,
int *count);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_get_linear_points (cairo_pattern_t *pattern,
double *x0, double *y0,
double *x1, double *y1);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_pattern_get_radial_circles (cairo_pattern_t *pattern,
double *x0, double *y0, double *r0,
double *x1, double *y1, double *r1);
@@ -1820,7 +1820,7 @@ cairo_matrix_scale (cairo_matrix_t *matrix, double sx, double sy);
cairo_public void
cairo_matrix_rotate (cairo_matrix_t *matrix, double radians);
-cairo_public cairo_status_t
+cairo_public_warn cairo_status_t
cairo_matrix_invert (cairo_matrix_t *matrix);
cairo_public void
diff --git a/src/cairoint.h b/src/cairoint.h
index c31f1dc..3f25eca 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -80,7 +80,7 @@ CAIRO_BEGIN_DECLS
# define slim_hidden_proto1(name, internal) \
extern __typeof (name) name \
__asm__ (slim_hidden_asmname (internal)) \
- cairo_private
+ cairo_private_no_warn
# define slim_hidden_def1(name, internal) \
extern __typeof (name) EXT_##name __asm__(slim_hidden_asmname(name)) \
__attribute__((__alias__(slim_hidden_asmname(internal))))
@@ -103,13 +103,22 @@ CAIRO_BEGIN_DECLS
/* slim_internal.h */
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__)
-#define cairo_private __attribute__((__visibility__("hidden")))
+#define cairo_private __attribute__((__visibility__("hidden"),__warn_unused_result__))
+#define cairo_private_no_warn __attribute__((__visibility__("hidden")))
#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
-#define cairo_private __hidden
+#define cairo_private __hidden CAIRO_WARN_UNUSED_RESULT
+#define cairo_private_no_warn __hidden
#else /* not gcc >= 3.3 and not Sun Studio >= 8 */
-#define cairo_private
+#define cairo_private CAIRO_WARN_UNUSED_RESULT
+#define cairo_private_no_warn
#endif
+/* This allows us to conditionally expose internals during debugging,
+ and forces propagation of return values.
+*/
+#define cairo_static static CAIRO_WARN_UNUSED_RESULT
+#define cairo_static_no_warn static
+
/* This macro allow us to deprecate a function by providing an alias
for the old function name to the new function name. With this
macro, binary compatibility is preserved. The macro only works on
@@ -188,8 +197,8 @@ typedef HMTX cairo_mutex_t;
#endif
#if !defined(CAIRO_MUTEX_DECLARE) && defined CAIRO_HAS_BEOS_SURFACE
-cairo_private void _cairo_beos_lock(void*);
-cairo_private void _cairo_beos_unlock(void*);
+cairo_private_no_warn void _cairo_beos_lock(void*);
+cairo_private_no_warn void _cairo_beos_unlock(void*);
/* the real initialization takes place in a global constructor */
# define CAIRO_MUTEX_DECLARE(name) extern void* name;
# define CAIRO_MUTEX_DECLARE_GLOBAL(name) extern void* name;
@@ -463,10 +472,10 @@ typedef struct _cairo_image_surface cairo_image_surface_t;
typedef struct _cairo_surface_backend cairo_surface_backend_t;
-cairo_private void
+cairo_private_no_warn void
_cairo_box_round_to_rectangle (cairo_box_t *box, cairo_rectangle_int16_t *rectangle);
-cairo_private void
+cairo_private_no_warn void
_cairo_rectangle_intersect (cairo_rectangle_int16_t *dest, cairo_rectangle_int16_t *src);
/* cairo_array.c structures and functions */
@@ -481,20 +490,20 @@ struct _cairo_array {
cairo_bool_t is_snapshot;
};
-cairo_private void
+cairo_private_no_warn void
_cairo_array_init (cairo_array_t *array, int element_size);
-cairo_private void
+cairo_private_no_warn void
_cairo_array_init_snapshot (cairo_array_t *array,
const cairo_array_t *other);
-cairo_private void
+cairo_private_no_warn void
_cairo_array_fini (cairo_array_t *array);
cairo_private cairo_status_t
_cairo_array_grow_by (cairo_array_t *array, int additional);
-cairo_private void
+cairo_private_no_warn void
_cairo_array_truncate (cairo_array_t *array, unsigned int num_elements);
cairo_private cairo_status_t
@@ -513,7 +522,7 @@ _cairo_array_allocate (cairo_array_t *array,
cairo_private void *
_cairo_array_index (cairo_array_t *array, unsigned int index);
-cairo_private void
+cairo_private_no_warn void
_cairo_array_copy_element (cairo_array_t *array, int index, void *dst);
cairo_private int
@@ -524,10 +533,10 @@ _cairo_array_size (cairo_array_t *array);
typedef cairo_array_t cairo_user_data_array_t;
-cairo_private void
+cairo_private_no_warn void
_cairo_user_data_array_init (cairo_user_data_array_t *array);
-cairo_private void
+cairo_private_no_warn void
_cairo_user_data_array_fini (cairo_user_data_array_t *array);
cairo_private void *
@@ -654,16 +663,16 @@ struct _cairo_font_face {
const cairo_font_face_backend_t *backend;
};
-cairo_private void
+cairo_private_no_warn void
_cairo_font_reset_static_data (void);
-cairo_private void
+cairo_private_no_warn void
_cairo_ft_font_reset_static_data (void);
-cairo_private void
+cairo_private_no_warn void
_cairo_xlib_surface_reset_static_data (void);
-cairo_private void
+cairo_private_no_warn void
_cairo_xlib_screen_reset_static_data (void);
/* the font backend interface */
@@ -783,19 +792,19 @@ struct _cairo_font_face_backend {
/* concrete font backends */
#if CAIRO_HAS_FT_FONT
-extern const cairo_private struct _cairo_scaled_font_backend cairo_ft_scaled_font_backend;
+extern const cairo_private_no_warn struct _cairo_scaled_font_backend cairo_ft_scaled_font_backend;
#endif
#if CAIRO_HAS_WIN32_FONT
-extern const cairo_private struct _cairo_scaled_font_backend cairo_win32_scaled_font_backend;
+extern const cairo_private_no_warn struct _cairo_scaled_font_backend cairo_win32_scaled_font_backend;
#endif
#if CAIRO_HAS_ATSUI_FONT
-extern const cairo_private struct _cairo_scaled_font_backend cairo_atsui_scaled_font_backend;
+extern const cairo_private_no_warn struct _cairo_scaled_font_backend cairo_atsui_scaled_font_backend;
#endif
@@ -1121,7 +1130,7 @@ struct _cairo_image_surface {
pixman_image_t *pixman_image;
};
-extern const cairo_private cairo_surface_backend_t cairo_image_surface_backend;
+extern const cairo_private_no_warn cairo_surface_backend_t cairo_image_surface_backend;
/* XXX: Right now, the cairo_color structure puts unpremultiplied
color in the doubles and premultiplied color in the shorts. Yes,
@@ -1167,7 +1176,7 @@ typedef struct _cairo_solid_pattern {
cairo_color_t color;
} cairo_solid_pattern_t;
-extern const cairo_private cairo_solid_pattern_t cairo_pattern_nil;
+extern const cairo_private_no_warn cairo_solid_pattern_t cairo_pattern_nil;
typedef struct _cairo_surface_pattern {
cairo_pattern_t base;
@@ -1276,7 +1285,7 @@ typedef struct _cairo_stroke_face {
} cairo_stroke_face_t;
/* cairo.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_restrict_value (double *value, double min, double max);
cairo_private int
@@ -1314,19 +1323,19 @@ cairo_private cairo_status_t
_cairo_gstate_init (cairo_gstate_t *gstate,
cairo_surface_t *target);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_fini (cairo_gstate_t *gstate);
cairo_private cairo_gstate_t *
_cairo_gstate_clone (cairo_gstate_t *gstate);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_destroy (cairo_gstate_t *gstate);
cairo_private cairo_bool_t
_cairo_gstate_is_redirected (cairo_gstate_t *gstate);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_redirect_target (cairo_gstate_t *gstate, cairo_surface_t *child);
cairo_private cairo_surface_t *
@@ -1392,7 +1401,7 @@ _cairo_gstate_set_miter_limit (cairo_gstate_t *gstate, double limit);
cairo_private double
_cairo_gstate_get_miter_limit (cairo_gstate_t *gstate);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_get_matrix (cairo_gstate_t *gstate, cairo_matrix_t *matrix);
cairo_private cairo_status_t
@@ -1427,13 +1436,13 @@ _cairo_gstate_device_to_user (cairo_gstate_t *gstate, double *x, double *y);
cairo_private cairo_status_t
_cairo_gstate_device_to_user_distance (cairo_gstate_t *gstate, double *dx, double *dy);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_user_to_backend (cairo_gstate_t *gstate, double *x, double *y);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_backend_to_user (cairo_gstate_t *gstate, double *x, double *y);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_backend_to_user_rectangle (cairo_gstate_t *gstate,
double *x1, double *y1,
double *x2, double *y2,
@@ -1518,7 +1527,7 @@ cairo_private cairo_status_t
_cairo_gstate_set_font_size (cairo_gstate_t *gstate,
double size);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_get_font_matrix (cairo_gstate_t *gstate,
cairo_matrix_t *matrix);
@@ -1526,7 +1535,7 @@ cairo_private cairo_status_t
_cairo_gstate_set_font_matrix (cairo_gstate_t *gstate,
const cairo_matrix_t *matrix);
-cairo_private void
+cairo_private_no_warn void
_cairo_gstate_get_font_options (cairo_gstate_t *gstate,
cairo_font_options_t *options);
@@ -1592,30 +1601,30 @@ _cairo_stock_color (cairo_stock_t stock);
cairo_private uint16_t
_cairo_color_double_to_short (double d);
-cairo_private void
+cairo_private_no_warn void
_cairo_color_init (cairo_color_t *color);
-cairo_private void
+cairo_private_no_warn void
_cairo_color_init_rgb (cairo_color_t *color,
double red, double green, double blue);
-cairo_private void
+cairo_private_no_warn void
_cairo_color_init_rgba (cairo_color_t *color,
double red, double green, double blue,
double alpha);
-cairo_private void
+cairo_private_no_warn void
_cairo_color_multiply_alpha (cairo_color_t *color,
double alpha);
-cairo_private void
+cairo_private_no_warn void
_cairo_color_get_rgba (cairo_color_t *color,
double *red,
double *green,
double *blue,
double *alpha);
-cairo_private void
+cairo_private_no_warn void
_cairo_color_get_rgba_premultiplied (cairo_color_t *color,
double *red,
double *green,
@@ -1624,20 +1633,20 @@ _cairo_color_get_rgba_premultiplied (cairo_color_t *color,
/* cairo-font.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_font_freeze_cache (cairo_scaled_font_t *scaled_font);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_font_thaw_cache (cairo_scaled_font_t *scaled_font);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_font_set_error (cairo_scaled_font_t *scaled_font,
cairo_status_t status);
-extern const cairo_private cairo_font_face_t _cairo_font_face_nil;
-extern const cairo_private cairo_scaled_font_t _cairo_scaled_font_nil;
+extern const cairo_private_no_warn cairo_font_face_t _cairo_font_face_nil;
+extern const cairo_private_no_warn cairo_scaled_font_t _cairo_scaled_font_nil;
-cairo_private void
+cairo_private_no_warn void
_cairo_font_face_init (cairo_font_face_t *font_face,
const cairo_font_face_backend_t *backend);
@@ -1646,22 +1655,22 @@ _cairo_toy_font_face_create (const char *family,
cairo_font_slant_t slant,
cairo_font_weight_t weight);
-cairo_private void
+cairo_private_no_warn void
_cairo_unscaled_font_init (cairo_unscaled_font_t *font,
const cairo_unscaled_font_backend_t *backend);
cairo_private cairo_unscaled_font_t *
_cairo_unscaled_font_reference (cairo_unscaled_font_t *font);
-cairo_private void
+cairo_private_no_warn void
_cairo_unscaled_font_destroy (cairo_unscaled_font_t *font);
/* cairo-font-options.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_font_options_init_default (cairo_font_options_t *options);
-cairo_private void
+cairo_private_no_warn void
_cairo_font_options_init_copy (cairo_font_options_t *options,
const cairo_font_options_t *other);
@@ -1681,7 +1690,7 @@ cairo_private cairo_bool_t
_cairo_operator_always_translucent (cairo_operator_t op);
/* cairo_path.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_path_fixed_init (cairo_path_fixed_t *path);
cairo_private cairo_status_t
@@ -1691,10 +1700,10 @@ _cairo_path_fixed_init_copy (cairo_path_fixed_t *path,
cairo_private cairo_path_fixed_t *
_cairo_path_fixed_create (void);
-cairo_private void
+cairo_private_no_warn void
_cairo_path_fixed_fini (cairo_path_fixed_t *path);
-cairo_private void
+cairo_private_no_warn void
_cairo_path_fixed_destroy (cairo_path_fixed_t *path);
cairo_private cairo_status_t
@@ -1702,7 +1711,7 @@ _cairo_path_fixed_move_to (cairo_path_fixed_t *path,
cairo_fixed_t x,
cairo_fixed_t y);
-cairo_private void
+cairo_private_no_warn void
_cairo_path_fixed_new_sub_path (cairo_path_fixed_t *path);
cairo_private cairo_status_t
@@ -1771,7 +1780,7 @@ _cairo_path_fixed_bounds (cairo_path_fixed_t *path,
double *x1, double *y1,
double *x2, double *y2);
-cairo_private void
+cairo_private_no_warn void
_cairo_path_fixed_device_transform (cairo_path_fixed_t *path,
cairo_matrix_t *device_transform);
@@ -1801,11 +1810,11 @@ _cairo_scaled_font_init (cairo_scaled_font_t *scaled_font,
const cairo_font_options_t *options,
const cairo_scaled_font_backend_t *backend);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_font_set_metrics (cairo_scaled_font_t *scaled_font,
cairo_font_extents_t *fs_metrics);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_font_fini (cairo_scaled_font_t *scaled_font);
cairo_private cairo_status_t
@@ -1846,17 +1855,17 @@ _cairo_scaled_font_glyph_path (cairo_scaled_font_t *scaled_font,
int num_glyphs,
cairo_path_fixed_t *path);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_glyph_set_metrics (cairo_scaled_glyph_t *scaled_glyph,
cairo_scaled_font_t *scaled_font,
cairo_text_extents_t *fs_metrics);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_glyph_set_surface (cairo_scaled_glyph_t *scaled_glyph,
cairo_scaled_font_t *scaled_font,
cairo_image_surface_t *surface);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_glyph_set_path (cairo_scaled_glyph_t *scaled_glyph,
cairo_scaled_font_t *scaled_font,
cairo_path_fixed_t *path);
@@ -1867,29 +1876,29 @@ _cairo_scaled_glyph_lookup (cairo_scaled_font_t *scaled_font,
cairo_scaled_glyph_info_t info,
cairo_scaled_glyph_t **scaled_glyph_ret);
-cairo_private void
+cairo_private_no_warn void
_cairo_scaled_font_map_destroy (void);
/* cairo-stroke-style.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_stroke_style_init (cairo_stroke_style_t *style);
cairo_private cairo_status_t
_cairo_stroke_style_init_copy (cairo_stroke_style_t *style,
cairo_stroke_style_t *other);
-cairo_private void
+cairo_private_no_warn void
_cairo_stroke_style_fini (cairo_stroke_style_t *style);
/* cairo-surface.c */
-extern const cairo_private cairo_surface_t _cairo_surface_nil;
-extern const cairo_private cairo_surface_t _cairo_surface_nil_read_error;
-extern const cairo_private cairo_surface_t _cairo_surface_nil_write_error;
-extern const cairo_private cairo_surface_t _cairo_surface_nil_file_not_found;
+extern const cairo_private_no_warn cairo_surface_t _cairo_surface_nil;
+extern const cairo_private_no_warn cairo_surface_t _cairo_surface_nil_read_error;
+extern const cairo_private_no_warn cairo_surface_t _cairo_surface_nil_write_error;
+extern const cairo_private_no_warn cairo_surface_t _cairo_surface_nil_file_not_found;
-cairo_private void
+cairo_private_no_warn void
_cairo_surface_set_error (cairo_surface_t *surface,
cairo_status_t status);
@@ -1906,12 +1915,12 @@ _cairo_surface_create_similar_solid (cairo_surface_t *other,
int height,
const cairo_color_t *color);
-cairo_private void
+cairo_private_no_warn void
_cairo_surface_init (cairo_surface_t *surface,
const cairo_surface_backend_t *backend,
cairo_content_t content);
-cairo_private void
+cairo_private_no_warn void
_cairo_surface_set_font_options (cairo_surface_t *surface,
cairo_font_options_t *options);
@@ -2018,7 +2027,7 @@ _cairo_surface_acquire_source_image (cairo_surface_t *surface,
cairo_image_surface_t **image_out,
void **image_extra);
-cairo_private void
+cairo_private_no_warn void
_cairo_surface_release_source_image (cairo_surface_t *surface,
cairo_image_surface_t *image,
void *image_extra);
@@ -2030,7 +2039,7 @@ _cairo_surface_acquire_dest_image (cairo_surface_t *surface,
cairo_rectangle_int16_t *image_rect,
void **image_extra);
-cairo_private void
+cairo_private_no_warn void
_cairo_surface_release_dest_image (cairo_surface_t *surface,
cairo_rectangle_int16_t *interest_rect,
cairo_image_surface_t *image,
@@ -2127,7 +2136,7 @@ _cairo_surface_composite_shape_fixup_unbounded (cairo_surface_t *dst,
cairo_private cairo_bool_t
_cairo_surface_is_opaque (const cairo_surface_t *surface);
-cairo_private void
+cairo_private_no_warn void
_cairo_surface_set_device_scale (cairo_surface_t *surface,
double sx,
double sy);
@@ -2204,7 +2213,7 @@ _cairo_image_surface_create_for_data_with_content (unsigned char *data,
int height,
int stride);
-cairo_private void
+cairo_private_no_warn void
_cairo_image_surface_assume_ownership_of_data (cairo_image_surface_t *surface);
/* XXX: It's a nasty kludge that this appears here. Backend functions
@@ -2243,7 +2252,7 @@ _cairo_pen_init_empty (cairo_pen_t *pen);
cairo_private cairo_status_t
_cairo_pen_init_copy (cairo_pen_t *pen, cairo_pen_t *other);
-cairo_private void
+cairo_private_no_warn void
_cairo_pen_fini (cairo_pen_t *pen);
cairo_private cairo_status_t
@@ -2273,10 +2282,10 @@ _cairo_pen_stroke_spline (cairo_pen_t *pen,
cairo_traps_t *traps);
/* cairo_polygon.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_polygon_init (cairo_polygon_t *polygon);
-cairo_private void
+cairo_private_no_warn void
_cairo_polygon_fini (cairo_polygon_t *polygon);
cairo_private cairo_status_t
@@ -2302,23 +2311,23 @@ _cairo_spline_init (cairo_spline_t *spline,
cairo_private cairo_status_t
_cairo_spline_decompose (cairo_spline_t *spline, double tolerance);
-cairo_private void
+cairo_private_no_warn void
_cairo_spline_fini (cairo_spline_t *spline);
/* cairo_matrix.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_matrix_get_affine (const cairo_matrix_t *matrix,
double *xx, double *yx,
double *xy, double *yy,
double *x0, double *y0);
-cairo_private void
+cairo_private_no_warn void
_cairo_matrix_transform_bounding_box (const cairo_matrix_t *matrix,
double *x1, double *y1,
double *x2, double *y2,
cairo_bool_t *is_tight);
-cairo_private void
+cairo_private_no_warn void
_cairo_matrix_compute_determinant (const cairo_matrix_t *matrix, double *det);
cairo_private cairo_status_t
@@ -2338,22 +2347,22 @@ _cairo_matrix_is_integer_translation(const cairo_matrix_t *matrix,
cairo_private double
_cairo_matrix_transformed_circle_major_axis(cairo_matrix_t *matrix, double radius);
-cairo_private void
+cairo_private_no_warn void
_cairo_matrix_to_pixman_matrix (const cairo_matrix_t *matrix,
pixman_transform_t *pixman_transform);
/* cairo_traps.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_traps_init (cairo_traps_t *traps);
cairo_private cairo_status_t
_cairo_traps_init_box (cairo_traps_t *traps,
cairo_box_t *box);
-cairo_private void
+cairo_private_no_warn void
_cairo_traps_fini (cairo_traps_t *traps);
-cairo_private void
+cairo_private_no_warn void
_cairo_traps_translate (cairo_traps_t *traps, int x, int y);
cairo_private cairo_status_t
@@ -2380,14 +2389,14 @@ _cairo_bentley_ottmann_tessellate_polygon (cairo_traps_t *traps,
cairo_private int
_cairo_traps_contain (cairo_traps_t *traps, double x, double y);
-cairo_private void
+cairo_private_no_warn void
_cairo_traps_extents (cairo_traps_t *traps, cairo_box_t *extents);
cairo_private cairo_status_t
_cairo_traps_extract_region (cairo_traps_t *tr,
pixman_region16_t **region);
-cairo_private void
+cairo_private_no_warn void
_cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
cairo_trapezoid_t *src_traps,
int num_traps,
@@ -2395,7 +2404,7 @@ _cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
double sx, double sy);
/* cairo_slope.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_slope_init (cairo_slope_t *slope, cairo_point_t *a, cairo_point_t *b);
cairo_private int
@@ -2409,34 +2418,34 @@ _cairo_slope_counter_clockwise (cairo_slope_t *a, cairo_slope_t *b);
/* cairo_pattern.c */
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_init_copy (cairo_pattern_t *pattern,
const cairo_pattern_t *other);
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_init_solid (cairo_solid_pattern_t *pattern,
const cairo_color_t *color);
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern,
cairo_surface_t *surface);
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_init_linear (cairo_linear_pattern_t *pattern,
double x0, double y0, double x1, double y1);
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_init_radial (cairo_radial_pattern_t *pattern,
double cx0, double cy0, double radius0,
double cx1, double cy1, double radius1);
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_fini (cairo_pattern_t *pattern);
cairo_private cairo_pattern_t *
_cairo_pattern_create_solid (const cairo_color_t *color);
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_transform (cairo_pattern_t *pattern,
const cairo_matrix_t *ctm_inverse);
@@ -2456,7 +2465,7 @@ _cairo_pattern_acquire_surface (cairo_pattern_t *pattern,
cairo_surface_t **surface_out,
cairo_surface_attributes_t *attributes);
-cairo_private void
+cairo_private_no_warn void
_cairo_pattern_release_surface (cairo_pattern_t *pattern,
cairo_surface_t *surface,
cairo_surface_attributes_t *attributes);
@@ -2492,7 +2501,7 @@ _cairo_gstate_get_antialias (cairo_gstate_t *gstate);
cairo_private pixman_region16_t *
_cairo_region_create_from_rectangle (cairo_rectangle_int16_t *rect);
-cairo_private void
+cairo_private_no_warn void
_cairo_region_extents_rectangle (pixman_region16_t *region,
cairo_rectangle_int16_t *rect);
@@ -2510,7 +2519,7 @@ _cairo_utf8_to_utf16 (const unsigned char *str,
uint16_t **result,
int *items_written);
-cairo_private void
+cairo_private_no_warn void
_cairo_error (cairo_status_t status);
cairo_private int
diff --git a/src/check-headers.sh b/src/check-headers.sh
index 91a52a0..a17d666 100755
--- a/src/check-headers.sh
+++ b/src/check-headers.sh
@@ -12,7 +12,7 @@ xargs grep -B 1 '^cairo_.*[ ]\+(' |
awk '
/^--$/ { context=""; public=0; next; }
/:cairo_.*[ ]+\(/ { if (!public) {print context; print; print "--";} next; }
-/-cairo_public[ ]/ {public=1;}
+/-cairo_public.*[ ]/ {public=1;}
{ context=$0; }
' |
sed 's/[.]h-/.h:/' |
--
1.4.4.2
More information about the cairo
mailing list