[rrd-developers] [PATCH] Use -Werror.

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Wed Oct 1 17:40:33 CEST 2008


Hi Sebastian, all,

On Wed, Oct 01, 2008 at 04:57:39PM +0200, Sebastian Harl wrote:
>This patch adds -Werror to the CFLAGS of all parts of rrdtool. All issues that
>were identified by that have been fixed. This includes fixes for the following
>compiler warnings:
>
> - unused variable
> - unused parameter
> - assignment / argument discards qualifiers from pointer target type
> - comparison between signed and unsigned
> - too many arguments to function
> - assignment makes pointer from integer without a cast
> - incompatible pointer type
> - differ in signedness
> - implicit declaration of function
> - enumeration value not handled in switch
> - value computed is not used
>

>diff --git a/program/bindings/tcl/tclrrd.c b/program/bindings/tcl/tclrrd.c
>index d4593bb..7f604d9 100644
>--- a/program/bindings/tcl/tclrrd.c
>+++ b/program/bindings/tcl/tclrrd.c
>@@ -97,7 +97,7 @@ static void getopt_squieeze(
> 
> /* Thread-safe version */
> static int Rrd_Create(
>-    ClientData clientData,
>+    ClientData __attribute__((unused)) clientData,

careful, not everybody accepts __attribute__

Usually some header has stanzas like

/* Convenience macros to test the version of gcc. */
#undef __GNUC_PREREQ
#if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
        ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#else
# define __GNUC_PREREQ(maj, min) 0
#endif

/* Define macros for some gcc attributes.  This permits us to use the
   macros freely, and know that they will come into play for the
   version of gcc in which they are supported.  */

#if !__GNUC_PREREQ(2,7)
# ifndef __attribute__
#  define __attribute__(x)
# endif
#endif

#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))

>diff --git a/program/configure.ac b/program/configure.ac
>index 1e3da86..2370f21 100644
>--- a/program/configure.ac
>+++ b/program/configure.ac
>@@ -138,6 +138,21 @@ AC_PROG_LIBTOOL
> dnl Try to detect/use GNU features
> CFLAGS="$CFLAGS -D_GNU_SOURCE"
> 
>+dnl check for -Werror separatly
>+dnl (quite a few autotool checks don't work with -Werror; also, the
>+dnl check for -Werror fails after checking and adding the other flags)
>+AC_CACHE_CHECK([if gcc likes the -Werror flag], rd_cv_gcc_flag__Werror,

s/gcc/CC/
and it's not a matter of "likes" but rather "supports", perhaps


>diff --git a/program/src/rrd_client.c b/program/src/rrd_client.c
>index 44d4d60..76fded0 100644
>--- a/program/src/rrd_client.c
>+++ b/program/src/rrd_client.c
>@@ -741,7 +741,7 @@ void rrdc_stats_free (rrdc_stats_t *ret_stats) /* {{{ */
> 
>     if (this->name != NULL)
>     {
>-      free (this->name);
>+      free ((char *)this->name);
>       this->name = NULL;
>     }

It's perfectly valid to free(NULL), so the check is redundant.

>     free (this);



More information about the rrd-developers mailing list