[cairo-commit] 3 commits - configure.in pixman/src src/cairoint.h

Carl Worth cworth at kemper.freedesktop.org
Wed Apr 11 14:44:34 PDT 2007


 configure.in         |   21 ++++++++++++++++++---
 pixman/src/icimage.c |    2 ++
 pixman/src/pixman.h  |   10 +++++++---
 src/cairoint.h       |   13 ++++++-------
 4 files changed, 33 insertions(+), 13 deletions(-)

New commits:
diff-tree 3bc413343a0b846c9501ee870db0424412aea701 (from 54134dd901d6dc94aa56d45486223e7d4f6ba569)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 11 01:08:17 2007 +0100

    Define cairo_public_warn in terms of cairo_public.
    
    By defining cairo_public_warn as an extension of cairo_public, the
    programmer need only to override cairo_public in order to export the
    complete API for different architectures i.e. existing configurations
    will continue to work with no alterations.

diff --git a/configure.in b/configure.in
index e52c058..60bb3cd 100644
--- a/configure.in
+++ b/configure.in
@@ -871,7 +871,7 @@ AC_CONFIG_COMMANDS([src/cairo-features.h
 # define cairo_public
 #endif
 #ifndef cairo_public_warn
-# define cairo_public_warn CAIRO_WARN_UNUSED_RESULT
+# define cairo_public_warn cairo_public CAIRO_WARN_UNUSED_RESULT
 #endif
 
 #define CAIRO_VERSION_MAJOR $CAIRO_VERSION_MAJOR
diff-tree 54134dd901d6dc94aa56d45486223e7d4f6ba569 (from f53c2b418cb4a36fbc1c30cdb1bf0ba9dba77bd0)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 10 23:09:13 2007 +0100

    Only enable warn-unused-result for recent gcc
    
    The attribute was introduced with gcc-3.4, but the ability to suppress
    warnings from misapplied attributes (-Wno-attributes) was only introduced
    later. Without the supression, gcc will emit tens of warnings for each
    compilation completely drowning the real errors that the programmer
    must see.

diff --git a/configure.in b/configure.in
index f267c22..e52c058 100644
--- a/configure.in
+++ b/configure.in
@@ -654,10 +654,24 @@ AC_CACHE_CHECK([for supported warning fl
 	cairo_cv_warn_maybe=$MAYBE_WARN
 
 	AC_MSG_CHECKING([which warning flags were supported])])
-WARN_CFLAGS=$cairo_cv_warn_cflags
+WARN_CFLAGS="$cairo_cv_warn_cflags"
 CAIRO_CFLAGS="$CAIRO_CFLAGS $WARN_CFLAGS"
 PIXMAN_CFLAGS="$PIXMAN_CFLAGS $WARN_CFLAGS"
 
+# We only wish to enable attribute(warn_unused_result) if we can prevent
+# gcc from generating thousands of warnings about the misapplication of the
+# attribute to void functions and variables.
+AC_MSG_CHECKING([how to enable unused result warnings])
+warn_unused_result=""
+if echo $WARN_CFLAGS | grep -e '-Wno-attributes' >/dev/null; then
+    AC_TRY_COMPILE([__attribute__((__warn_unused_result__))
+	int f (int i) { return i; }], [],
+	[warn_unused_result="__attribute__((__warn_unused_result__))"])
+fi
+AC_DEFINE_UNQUOTED([WARN_UNUSED_RESULT], [$warn_unused_result],
+	  [Define to the value your compiler uses to support the warn-unused-result attribute])
+AC_MSG_RESULT([$warn_unused_result])
+
 CAIRO_CC_TRY_FLAG([-fno-strict-aliasing],
 		  [CAIRO_CFLAGS="$CAIRO_CFLAGS -fno-strict-aliasing"
 		   PIXMAN_CFLAGS="$PIXMAN_CFLAGS -fno-strict-aliasing"])
@@ -845,7 +859,8 @@ AC_CONFIG_COMMANDS([src/cairo-features.h
 # define CAIRO_END_DECLS
 #endif
 
-#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
+#if    __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)
+/* only enable warnings if they can be suppressed  (-Wno-attributes) */
 #define CAIRO_WARN_UNUSED_RESULT 		\
   __attribute__((__warn_unused_result__))
 #else
diff --git a/pixman/src/pixman.h b/pixman/src/pixman.h
index fb2ccf7..22a9983 100644
--- a/pixman/src/pixman.h
+++ b/pixman/src/pixman.h
@@ -100,13 +100,17 @@ SOFTWARE.
 #include "pixman-remap.h"
 
 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun__)
-#define pixman_private		__attribute__((__visibility__("hidden"),__warn_unused_result__))
+#define pixman_private_no_warn	__attribute__((__visibility__("hidden")))
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
-#define pixman_private		__hidden
+#define pixman_private_no_warn	__hidden
 #else /* not gcc >= 3.3 and not Sun Studio >= 8 */
-#define pixman_private
+#define pixman_private_no_warn
 #endif
 
+/* Add attribute(warn_unused_result) if supported */
+#define pixman_warn WARN_UNUSED_RESULT
+#define pixman_private pixman_private_no_warn pixman_warn
+
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
 #endif
diff --git a/src/cairoint.h b/src/cairoint.h
index 628ee41..f0ac938 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -103,17 +103,16 @@ CAIRO_BEGIN_DECLS
 
 /* slim_internal.h */
 #if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
-#define cairo_private			__attribute__((__visibility__("hidden"),__warn_unused_result__))
-#define cairo_private_no_warn		__attribute__((__visibility__("hidden")))
+#define cairo_private_no_warn	__attribute__((__visibility__("hidden")))
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
-#define cairo_private			__hidden CAIRO_WARN_UNUSED_RESULT
-#define cairo_private_no_warn		__hidden
+#define cairo_private_no_warn	__hidden
 #else /* not gcc >= 3.3 and not Sun Studio >= 8 */
-#define cairo_private			CAIRO_WARN_UNUSED_RESULT
-#define cairo_private_no_warn		
+#define cairo_private_no_warn
 #endif
 
-#define cairo_warn CAIRO_WARN_UNUSED_RESULT
+/* Add attribute(warn_unused_result) if supported */
+#define cairo_warn	    WARN_UNUSED_RESULT
+#define cairo_private	    cairo_private_no_warn cairo_warn
 
 /* This macro allow us to deprecate a function by providing an alias
    for the old function name to the new function name. With this
diff-tree f53c2b418cb4a36fbc1c30cdb1bf0ba9dba77bd0 (from d0745c08b782d79fc7ccfd59cab0ae841a56c428)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon Apr 9 16:24:11 2007 +0100

    _pixman_create_source_image() - check for malloc failure
    
    Fix an unchecked malloc by propagating the NULL pointer up to its callers,
    which were already checking for failures.

diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c
index 34d68ef..4cc2be7 100644
--- a/pixman/src/icimage.c
+++ b/pixman/src/icimage.c
@@ -191,6 +191,8 @@ _pixman_create_source_image (void)
     pixman_image_t *image;
 
     image = (pixman_image_t *) malloc (sizeof (pixman_image_t));
+    if (image == NULL)
+	return NULL;
     image->pDrawable   = NULL;
     image->pixels      = NULL;
     image->format_code = PICT_a8r8g8b8;


More information about the cairo-commit mailing list