Re: [Linux-ha-dev] [PATCH] [glue] Fix compilation with GCC 4.6

2011-10-12 Thread nozawat
Hi

> BTW, does this get rid of the compiler warning as well?
The warning did not change.
I build in gcc4.6.1 of Fedora15.

---
apcsmart.c: In function 'apcsmart_hostlist':
apcsmart.c:725:34: error: cast discards '__attribute__((const))' qualifier
from pointer target type [-Werror=cast-qual]
cc1: all warnings being treated as errors
--

Regards,
Tomo

2011/10/13 Lars Ellenberg 

> On Wed, Oct 12, 2011 at 09:03:47PM +0200, Dejan Muhamedagic wrote:
> > On Mon, Jul 04, 2011 at 09:42:55PM +0100, Pádraig Brady wrote:
> > > On 01/07/11 11:23, Dejan Muhamedagic wrote:
> > > > Hi,
> > > >
> > > > On Fri, Jul 01, 2011 at 01:37:32AM +0100, Pádraig Brady wrote:
> > > >> On 30/06/11 20:33, Lars Ellenberg wrote:
> > > >>> 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?
> > > >>
> > > >> Sure, that would work but would involve a lot of changes I think.
> > > >> I was unsure how changing this interface might affect users
> > > >> outside this project, but if that's OK I'll go ahead
> > > >> and change that (tomorrow when I'm more awake).
> > > >
> > > > It should be OK. It is a change which may break compilation, then
> > > > if somebody's using the libraries they should fix their code
> > > > accordingly.
> > >
> > > I had another look, and I think this introduces too much churn.
> > > Sometimes new GCC warnings are a little intrusive for general use
> > > and I think -Wcast-qual is in this category for the moment.
> >
> > It could be that we're just really unlucky with cast-qual and how
> > some stonith internals were done.
> >
> > > The specific pattern at issue here is:
> > > char ** array_of_strings;
> > >
> > > One should be able to cast to the appropriate
> > > level of constness to:
> > >
> > > sort (const char**);
> > > copy (const char* const*);
> > > free (char **);
> > >
> > > So please consider my last patch instead.
> >
> > I did just now, very sorry for such a delay. Applied as two
> > patches, one to disable cast-qual and another to drop unused
> > vars.
> >
> > Many thanks for the patches.
>
> BTW, does this get rid of the compiler warning as well?
>
> -   return OurImports->CopyHostList((const char **)ad->hostlist);
> +   return OurImports->CopyHostList((const char **)(const char * const
> *)ad->hostlist);
>
> If it does, maybe introducing a
> #define CONST_CHAR_PP_CAST(x) ((const char **)(const char * const *)(x))
> #define COPY_HOSTLIST_CAST(x) CONST_CHAR_PP_CAST(x)
> would enable us to keep -Wcast-qual for now?
>
> Makes it easier as well, if we later chose to change the interface to
> take const char * const *.
>
> --
> : Lars Ellenberg
> : LINBIT | Your Way to High Availability
> : DRBD/HA support and consulting http://www.linbit.com
> ___
> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
>
__

Re: [Linux-ha-dev] [PATCH]Patch to build cluster-glue in Fedora15

2011-10-12 Thread nozawat
Hi Dejan

 Thank you for applied.
 The build succeeded.

Regards,
Tomo

2011/10/13 Dejan Muhamedagic 

> Hi,
>
> On Wed, Oct 12, 2011 at 04:27:54PM +0900, nozawat wrote:
> > Hi
> >
> >  I found the same phenomenon in past ML.
> >  How did this turn out?
> >  
>
> It turned out to be forgotten :( I applied the patch which was
> proposed in one of the messages. If you try the latest glue
> repository, it should build OK.
>
> Cheers,
>
> Dejan
>
> > Regards,
> > Tomo
> >
> > 2011/10/12 nozawat 
> >
> > > Hi Dejan
> > >
> > >  I send the contents of the build error.
> > >  The content of the error is as follows.
> > >
> > >  1)error: variable 'internal_type' set but not used
> > > [-Werror=unused-but-set-variable].
> > >  2)error: to be safe all intermediate pointers in cast from 'char **'
> to
> > > 'const char **' must be 'const' qualified [-Werror=cast-qual]
> > >
> > >  1) is log from a build start.
> > >  2) is log only for error points.
> > >
> > > Regards,
> > > Tomo
> > >
> > >
> > > 2011/10/12 nozawat 
> > >
> > >> Hi Dejan
> > >>
> > >>
> > >> >Can you please show the output of configure. Perhaps we should
> > >> >fix it in code.
> > >> OK,I make the patch for the code and send it.
> > >>
> > >> Regards,
> > >> Tomo
> > >>
> > >>
> > >> 2011/10/12 Dejan Muhamedagic 
> > >>
> > >>> Hi,
> > >>>
> > >>> On Tue, Oct 11, 2011 at 08:52:06PM +0900, nozawat wrote:
> > >>> > Hi
> > >>> >
> > >>> >  I added the option which just handled warning for gcc-4.6 in
> Fedora.
> > >>>
> > >>> Can you please show the output of configure. Perhaps we should
> > >>> fix it in code.
> > >>>
> > >>> Thanks,
> > >>>
> > >>> Dejan
> > >>>
> > >>> > Regards,
> > >>> > Tomo
> > >>>
> > >>>
> > >>> > ___
> > >>> > Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> > >>> > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> > >>> > Home Page: http://linux-ha.org/
> > >>>
> > >>> ___
> > >>> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> > >>> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> > >>> Home Page: http://linux-ha.org/
> > >>>
> > >>
> > >>
> > >
>
> > ___
> > Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> > Home Page: http://linux-ha.org/
>
> ___
> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
>
___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


Re: [Linux-ha-dev] [PATCH] [glue] Fix compilation with GCC 4.6

2011-10-12 Thread Lars Ellenberg
On Wed, Oct 12, 2011 at 09:03:47PM +0200, Dejan Muhamedagic wrote:
> On Mon, Jul 04, 2011 at 09:42:55PM +0100, Pádraig Brady wrote:
> > On 01/07/11 11:23, Dejan Muhamedagic wrote:
> > > Hi,
> > > 
> > > On Fri, Jul 01, 2011 at 01:37:32AM +0100, Pádraig Brady wrote:
> > >> On 30/06/11 20:33, Lars Ellenberg wrote:
> > >>> 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?
> > >>
> > >> Sure, that would work but would involve a lot of changes I think.
> > >> I was unsure how changing this interface might affect users
> > >> outside this project, but if that's OK I'll go ahead
> > >> and change that (tomorrow when I'm more awake).
> > > 
> > > It should be OK. It is a change which may break compilation, then
> > > if somebody's using the libraries they should fix their code
> > > accordingly.
> > 
> > I had another look, and I think this introduces too much churn.
> > Sometimes new GCC warnings are a little intrusive for general use
> > and I think -Wcast-qual is in this category for the moment.
> 
> It could be that we're just really unlucky with cast-qual and how
> some stonith internals were done.
> 
> > The specific pattern at issue here is:
> > char ** array_of_strings;
> > 
> > One should be able to cast to the appropriate
> > level of constness to:
> > 
> > sort (const char**);
> > copy (const char* const*);
> > free (char **);
> > 
> > So please consider my last patch instead.
> 
> I did just now, very sorry for such a delay. Applied as two
> patches, one to disable cast-qual and another to drop unused
> vars.
> 
> Many thanks for the patches.

BTW, does this get rid of the compiler warning as well?

-   return OurImports->CopyHostList((const char **)ad->hostlist);
+   return OurImports->CopyHostList((const char **)(const char * const 
*)ad->hostlist);

If it does, maybe introducing a
#define CONST_CHAR_PP_CAST(x) ((const char **)(const char * const *)(x))
#define COPY_HOSTLIST_CAST(x) CONST_CHAR_PP_CAST(x)
would enable us to keep -Wcast-qual for now?

Makes it easier as well, if we later chose to change the interface to
take const char * const *.

-- 
: Lars Ellenberg
: LINBIT | Your Way to High Availability
: DRBD/HA support and consulting http://www.linbit.com
___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


Re: [Linux-ha-dev] [PATCH] [glue] Fix compilation with GCC 4.6

2011-10-12 Thread Dejan Muhamedagic
On Mon, Jul 04, 2011 at 09:42:55PM +0100, Pádraig Brady wrote:
> On 01/07/11 11:23, Dejan Muhamedagic wrote:
> > Hi,
> > 
> > On Fri, Jul 01, 2011 at 01:37:32AM +0100, Pádraig Brady wrote:
> >> On 30/06/11 20:33, Lars Ellenberg wrote:
> >>> 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?
> >>
> >> Sure, that would work but would involve a lot of changes I think.
> >> I was unsure how changing this interface might affect users
> >> outside this project, but if that's OK I'll go ahead
> >> and change that (tomorrow when I'm more awake).
> > 
> > It should be OK. It is a change which may break compilation, then
> > if somebody's using the libraries they should fix their code
> > accordingly.
> 
> I had another look, and I think this introduces too much churn.
> Sometimes new GCC warnings are a little intrusive for general use
> and I think -Wcast-qual is in this category for the moment.

It could be that we're just really unlucky with cast-qual and how
some stonith internals were done.

> The specific pattern at issue here is:
> char ** array_of_strings;
> 
> One should be able to cast to the appropriate
> level of constness to:
> 
> sort (const char**);
> copy (const char* const*);
> free (char **);
> 
> So please consider my last patch instead.

I did just now, very sorry for such a delay. Applied as two
patches, one to disable cast-qual and another to drop unused
vars.

Many thanks for the patches.

Cheers,

Dejan

> cheers,
> Pádraig.
> ___
> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


Re: [Linux-ha-dev] [PATCH]Patch to build cluster-glue in Fedora15

2011-10-12 Thread Dejan Muhamedagic
Hi,

On Wed, Oct 12, 2011 at 04:27:54PM +0900, nozawat wrote:
> Hi
> 
>  I found the same phenomenon in past ML.
>  How did this turn out?
>  

It turned out to be forgotten :( I applied the patch which was
proposed in one of the messages. If you try the latest glue
repository, it should build OK.

Cheers,

Dejan

> Regards,
> Tomo
> 
> 2011/10/12 nozawat 
> 
> > Hi Dejan
> >
> >  I send the contents of the build error.
> >  The content of the error is as follows.
> >
> >  1)error: variable 'internal_type' set but not used
> > [-Werror=unused-but-set-variable].
> >  2)error: to be safe all intermediate pointers in cast from 'char **' to
> > 'const char **' must be 'const' qualified [-Werror=cast-qual]
> >
> >  1) is log from a build start.
> >  2) is log only for error points.
> >
> > Regards,
> > Tomo
> >
> >
> > 2011/10/12 nozawat 
> >
> >> Hi Dejan
> >>
> >>
> >> >Can you please show the output of configure. Perhaps we should
> >> >fix it in code.
> >> OK,I make the patch for the code and send it.
> >>
> >> Regards,
> >> Tomo
> >>
> >>
> >> 2011/10/12 Dejan Muhamedagic 
> >>
> >>> Hi,
> >>>
> >>> On Tue, Oct 11, 2011 at 08:52:06PM +0900, nozawat wrote:
> >>> > Hi
> >>> >
> >>> >  I added the option which just handled warning for gcc-4.6 in Fedora.
> >>>
> >>> Can you please show the output of configure. Perhaps we should
> >>> fix it in code.
> >>>
> >>> Thanks,
> >>>
> >>> Dejan
> >>>
> >>> > Regards,
> >>> > Tomo
> >>>
> >>>
> >>> > ___
> >>> > Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> >>> > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> >>> > Home Page: http://linux-ha.org/
> >>>
> >>> ___
> >>> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> >>> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> >>> Home Page: http://linux-ha.org/
> >>>
> >>
> >>
> >

> ___
> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/

___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


Re: [Linux-ha-dev] [PATCH]Patch to build cluster-glue in Fedora15

2011-10-12 Thread nozawat
Hi

 I found the same phenomenon in past ML.
 How did this turn out?
 

Regards,
Tomo

2011/10/12 nozawat 

> Hi Dejan
>
>  I send the contents of the build error.
>  The content of the error is as follows.
>
>  1)error: variable 'internal_type' set but not used
> [-Werror=unused-but-set-variable].
>  2)error: to be safe all intermediate pointers in cast from 'char **' to
> 'const char **' must be 'const' qualified [-Werror=cast-qual]
>
>  1) is log from a build start.
>  2) is log only for error points.
>
> Regards,
> Tomo
>
>
> 2011/10/12 nozawat 
>
>> Hi Dejan
>>
>>
>> >Can you please show the output of configure. Perhaps we should
>> >fix it in code.
>> OK,I make the patch for the code and send it.
>>
>> Regards,
>> Tomo
>>
>>
>> 2011/10/12 Dejan Muhamedagic 
>>
>>> Hi,
>>>
>>> On Tue, Oct 11, 2011 at 08:52:06PM +0900, nozawat wrote:
>>> > Hi
>>> >
>>> >  I added the option which just handled warning for gcc-4.6 in Fedora.
>>>
>>> Can you please show the output of configure. Perhaps we should
>>> fix it in code.
>>>
>>> Thanks,
>>>
>>> Dejan
>>>
>>> > Regards,
>>> > Tomo
>>>
>>>
>>> > ___
>>> > Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
>>> > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
>>> > Home Page: http://linux-ha.org/
>>>
>>> ___
>>> Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
>>> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
>>> Home Page: http://linux-ha.org/
>>>
>>
>>
>
___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/