On Wed, Jun 29, 2011 at 12:55:08PM +0100, Pádraig Brady wrote:
> On 29/06/11 11:56, Lars Ellenberg wrote:
> > On Tue, Jun 28, 2011 at 01:44:23AM +0100, Pádraig Brady wrote:
> >> The attached patch fixes compilation -Werrors with GCC 4.6
> >>
> >> cheers,
> >> Pádraig.
> >>
> > 
> >> Fix compilation with GCC 4.6
> >>
> >> avoid -Werror=unused-but-set-variable issues
> >> remove -Wcast-qual which caused issues with copyHostList()
> > 
> > Care to explain or show those "issues"?
> 
> All uses of copyHostList error like:
> 
> apcsmart.c: In function 'apcsmart_hostlist':
> apcsmart.c:722:34: error: to be safe all intermediate pointers in cast from 
> 'char **' to 'const char **' must be 'const' qualified [-Werror=cast-qual]

From the gcc 4.5 documentation:
-Wcast-qual
        Warn whenever a pointer is cast so as to remove a type qualifier from 
the target
        type. For example, warn if a const char * is cast to an ordinary char *.
        Also warn when making a cast which introduces a type qualifier in an 
unsafe
        way. For example, casting char ** to const char ** is unsafe, as in 
this ex-
        ample:
                /* p is char ** value. */
                const char **q = (const char **) p;
                /* Assignment of readonly string to const char * is OK.
                *q = "string";
                /* Now char** pointer points to read-only memory. */
                **p = ’b’;

So apparently it needs to be

include/stonith/stonith_plugin.h:
 struct StonithImports_s {
 ...
-       char **(*CopyHostList)(const char ** hlstring);
+       char **(*CopyHostList)(const char * const * hlstring);

And the callers have to be adjusted accordingly?
Could you check if that works?

> >> -  nbytes=vsnprintf(buf, sizeof(buf)-1, fmt, ap);
> >> +  (void) vsnprintf(buf, sizeof(buf)-1, fmt, ap);
> > 
> > What is that (void) supposed to achieve?

> Just a personal preference to document
> we're discarding the return on purpose.
> I'll remove this extra syntax.

In that case, just leave it in, no problem there.
I just wondered it was to suppress yet an other warning,
and which one that might be ;-)

> Updated patch attached.

Thanks, will have a look soon.
Dejan, anyone, what do you think?

-- 
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com

DRBD® and LINBIT® are registered trademarks of LINBIT, Austria.
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to