Hi,

On Thu, Oct 13, 2011 at 11:34:36AM +0200, Lars Ellenberg wrote:
> On Thu, Oct 13, 2011 at 01:01:26PM +0900, nozawat wrote:
> > 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
> 
> Yeah, well, I meanwhile got me a setup where the gcc is new enough to
> warn about this. Could be fixed with (const char **)(void*).
> But that only masks an unclean interface.
> 
> I suggest three steps:
>   - Changing the signature of get_confignames, and CopyHostList.
>     This is a boring mechanical patch.
>   - move qsort to sort the copy, not the supposedly const char * const *
>   - Re-enable -Wcast-qual
> see below.

Very good. I was reluctant to disable cast-qual yesterday too.
Please push the patch.

Cheers,

Dejan

> ======================================================================
> Changing the signature of get_confignames, and CopyHostList.
> 
> diff -r 61fd9fb20b99 include/stonith/stonith.h
> --- a/include/stonith/stonith.h       Wed Oct 12 20:49:40 2011 +0200
> +++ b/include/stonith/stonith.h       Wed Oct 12 23:00:54 2011 +0200
> @@ -95,7 +95,7 @@
>  Stonith*stonith_new(const char * type);
>  void stonith_delete(Stonith *);
>  
> -const char** stonith_get_confignames (Stonith* s);
> +const char * const * stonith_get_confignames (Stonith* s);
>                               /* static/global return */
>                               /* Return number and list of valid s_names */
>  
> diff -r 61fd9fb20b99 include/stonith/stonith_plugin.h
> --- a/include/stonith/stonith_plugin.h        Wed Oct 12 20:49:40 2011 +0200
> +++ b/include/stonith/stonith_plugin.h        Wed Oct 12 23:00:54 2011 +0200
> @@ -53,7 +53,7 @@
>       void (*destroy)         (StonithPlugin*);       /*(full) Destructor */
>  
>       const char* (*get_info) (StonithPlugin*, int infotype);
> -     const char** (*get_confignames) (StonithPlugin*);
> +     const char * const * (*get_confignames) (StonithPlugin*);
>       int (*set_config)       (StonithPlugin*, StonithNVpair* list);
>                                       /* Finishes construction */
>       /*
> @@ -104,7 +104,7 @@
>       const char* (*GetValue)(StonithNVpair*, const char * name);
>       int     (*CopyAllValues) (StonithNamesToGet* out, StonithNVpair* in);
>       char **(*StringToHostList)(const char * hlstring);
> -     char **(*CopyHostList)(const char ** hlstring);
> +     char **(*CopyHostList)(const char * const * hlstring);
>       void (*FreeHostList)(char** hostlist);
>       int (*TtyLock)(const char* tty);
>       int (*TtyUnlock)(const char* tty);
> diff -r 61fd9fb20b99 lib/plugins/stonith/apcmaster.c
> --- a/lib/plugins/stonith/apcmaster.c Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/apcmaster.c Wed Oct 12 23:00:54 2011 +0200
> @@ -65,7 +65,7 @@
>  
>  static StonithPlugin *       apcmaster_new(const char *);
>  static void          apcmaster_destroy(StonithPlugin *);
> -static const char ** apcmaster_get_confignames(StonithPlugin *);
> +static const char * const *  apcmaster_get_confignames(StonithPlugin *);
>  static int           apcmaster_set_config(StonithPlugin *, StonithNVpair *);
>  static const char *  apcmaster_getinfo(StonithPlugin * s, int InfoType);
>  static int           apcmaster_status(StonithPlugin * );
> @@ -678,7 +678,7 @@
>  /*
>   *   Get the configuration parameters names
>   */
> -static const char **
> +static const char * const *
>  apcmaster_get_confignames(StonithPlugin * s)
>  {
>       static const char * ret[] = {ST_IPADDR, ST_LOGIN, ST_PASSWD, NULL};
> diff -r 61fd9fb20b99 lib/plugins/stonith/apcsmart.c
> --- a/lib/plugins/stonith/apcsmart.c  Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/apcsmart.c  Wed Oct 12 23:00:54 2011 +0200
> @@ -109,7 +109,7 @@
>  
>  static StonithPlugin *       apcsmart_new(const char *);
>  static void          apcsmart_destroy(StonithPlugin *);
> -static const char**  apcsmart_get_confignames(StonithPlugin*);
> +static const char * const *  apcsmart_get_confignames(StonithPlugin*);
>  static int           apcsmart_set_config(StonithPlugin *, StonithNVpair*);
>  static const char *  apcsmart_get_info(StonithPlugin * s, int InfoType);
>  static int           apcsmart_status(StonithPlugin * );
> @@ -621,7 +621,7 @@
>               ad->upsfd = -1;
>       }
>  }
> -static const char**
> +static const char * const *
>  apcsmart_get_confignames(StonithPlugin* sp)
>  {
>       static const char * names[] =  {ST_TTYDEV, ST_HOSTLIST, NULL};
> @@ -719,7 +719,7 @@
>       }
>       ERRIFNOTCONFIGED(s,NULL);
>  
> -     return OurImports->CopyHostList((const char **)ad->hostlist);
> +     return OurImports->CopyHostList((const char **)(void*)ad->hostlist);
>  }
>  
>  static gboolean
> diff -r 61fd9fb20b99 lib/plugins/stonith/baytech.c
> --- a/lib/plugins/stonith/baytech.c   Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/baytech.c   Wed Oct 12 23:00:54 2011 +0200
> @@ -37,7 +37,7 @@
>  static StonithPlugin *       baytech_new(const char *);
>  static void          baytech_destroy(StonithPlugin *);
>  static int           baytech_set_config(StonithPlugin *, StonithNVpair *);
> -static const char ** baytech_get_confignames(StonithPlugin * s);
> +static const char * const *  baytech_get_confignames(StonithPlugin * s);
>  static const char *  baytech_get_info(StonithPlugin * s, int InfoType);
>  static int           baytech_status(StonithPlugin *);
>  static int           baytech_reset_req(StonithPlugin * s, int request, const 
> char * host);
> @@ -744,7 +744,7 @@
>       return(rc != S_OK ? rc : lorc);
>  }
>  
> -static const char **
> +static const char * const *
>  baytech_get_confignames(StonithPlugin * s)
>  {
>       static const char * ret[] = {ST_IPADDR, ST_LOGIN, ST_PASSWD, NULL};
> diff -r 61fd9fb20b99 lib/plugins/stonith/cyclades.c
> --- a/lib/plugins/stonith/cyclades.c  Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/cyclades.c  Wed Oct 12 23:00:54 2011 +0200
> @@ -45,7 +45,7 @@
>  static StonithPlugin *       cyclades_new(const char *);
>  static void          cyclades_destroy(StonithPlugin *);
>  static int           cyclades_set_config(StonithPlugin *, StonithNVpair *);
> -static const char ** cyclades_get_confignames(StonithPlugin * s);
> +static const char * const *  cyclades_get_confignames(StonithPlugin * s);
>  static const char *  cyclades_get_info(StonithPlugin * s, int InfoType);
>  static int           cyclades_status(StonithPlugin *);
>  static int           cyclades_reset_req(StonithPlugin * s, int request, 
> const char * host);
> @@ -523,7 +523,7 @@
>       return rc;
>  }
>  
> -static const char **
> +static const char * const *
>  cyclades_get_confignames(StonithPlugin * s)
>  {
>       static const char * ret[] = {ST_IPADDR, ST_LOGIN, ST_SERIALPORT, NULL};
> diff -r 61fd9fb20b99 lib/plugins/stonith/external.c
> --- a/lib/plugins/stonith/external.c  Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/external.c  Wed Oct 12 23:00:54 2011 +0200
> @@ -46,7 +46,7 @@
>  static StonithPlugin *       external_new(const char *);
>  static void          external_destroy(StonithPlugin *);
>  static int           external_set_config(StonithPlugin *, StonithNVpair *);
> -static const char**  external_get_confignames(StonithPlugin *);
> +static const char * const *  external_get_confignames(StonithPlugin *);
>  static const char *  external_getinfo(StonithPlugin * s, int InfoType);
>  static int           external_status(StonithPlugin * );
>  static int           external_reset_req(StonithPlugin * s, int request, 
> const char * host);
> @@ -461,7 +461,7 @@
>  /*
>   * Return STONITH config vars
>   */
> -static const char**
> +static const char * const *
>  external_get_confignames(StonithPlugin* p)
>  {
>       struct pluginDevice *   sd;
> @@ -544,7 +544,7 @@
>               sd->confignames[dircount] = NULL;
>       }
>  
> -     return (const char **)sd->confignames;
> +     return (const char * const *)sd->confignames;
>  }
>  
>  /*
> diff -r 61fd9fb20b99 lib/plugins/stonith/ibmhmc.c
> --- a/lib/plugins/stonith/ibmhmc.c    Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/ibmhmc.c    Wed Oct 12 23:00:54 2011 +0200
> @@ -131,7 +131,7 @@
>  static StonithPlugin *       ibmhmc_new(const char *);
>  static void          ibmhmc_destroy(StonithPlugin *);
>  static const char *  ibmhmc_getinfo(StonithPlugin * s, int InfoType);
> -static const char**  ibmhmc_get_confignames(StonithPlugin* p);
> +static const char * const *  ibmhmc_get_confignames(StonithPlugin* p);
>  static int           ibmhmc_status(StonithPlugin * );
>  static int           ibmhmc_reset_req(StonithPlugin * s,int request,const 
> char* host);
>  static char **               ibmhmc_hostlist(StonithPlugin  *);
> @@ -318,7 +318,7 @@
>  }
>  
>  
> -static const char**     
> +static const char * const *
>  ibmhmc_get_confignames(StonithPlugin* p)
>  {
>       static const char * names[] = {ST_IPADDR, NULL};
> diff -r 61fd9fb20b99 lib/plugins/stonith/meatware.c
> --- a/lib/plugins/stonith/meatware.c  Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/meatware.c  Wed Oct 12 23:00:54 2011 +0200
> @@ -40,7 +40,7 @@
>  static StonithPlugin *       meatware_new(const char *);
>  static void          meatware_destroy(StonithPlugin *);
>  static int           meatware_set_config(StonithPlugin *, StonithNVpair *);
> -static const char**  meatware_get_confignames(StonithPlugin *);
> +static const char * const *  meatware_get_confignames(StonithPlugin *);
>  static const char *  meatware_getinfo(StonithPlugin * s, int InfoType);
>  static int           meatware_status(StonithPlugin * );
>  static int           meatware_reset_req(StonithPlugin * s, int request, 
> const char * host);
> @@ -136,7 +136,7 @@
>               return(NULL);
>       }
>  
> -     return OurImports->CopyHostList((const char **)nd->hostlist);
> +     return OurImports->CopyHostList((const char * const *)nd->hostlist);
>  }
>  
>  /*
> @@ -265,7 +265,7 @@
>  /*
>   * Return STONITH config vars
>   */
> -static const char**
> +static const char * const *
>  meatware_get_confignames(StonithPlugin* p)
>  {
>       static const char *     MeatwareParams[] = {ST_HOSTLIST, NULL };
> diff -r 61fd9fb20b99 lib/plugins/stonith/null.c
> --- a/lib/plugins/stonith/null.c      Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/null.c      Wed Oct 12 23:00:54 2011 +0200
> @@ -42,7 +42,7 @@
>  static void          null_destroy(StonithPlugin *);
>  static int           null_set_config(StonithPlugin*
>  ,                            StonithNVpair*);
> -static const char**  null_get_confignames(StonithPlugin*);
> +static const char * const *  null_get_confignames(StonithPlugin*);
>  static const char *  null_getinfo(StonithPlugin * s, int InfoType);
>  static int           null_status(StonithPlugin * );
>  static int           null_reset_req(StonithPlugin * s
> @@ -126,7 +126,7 @@
>       struct pluginDevice*    nd = (struct pluginDevice*)s;
>  
>       ERRIFWRONGDEV(s, NULL);
> -     return OurImports->CopyHostList((const char**)nd->hostlist);
> +     return OurImports->CopyHostList((const char * const *)nd->hostlist);
>  }
>  
>  
> @@ -148,7 +148,7 @@
>  }
>  
>  
> -static const char**
> +static const char * const *
>  null_get_confignames(StonithPlugin* p)
>  {
>       static const char *     NullParams[] = {ST_HOSTLIST, NULL };
> diff -r 61fd9fb20b99 lib/plugins/stonith/nw_rpc100s.c
> --- a/lib/plugins/stonith/nw_rpc100s.c        Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/nw_rpc100s.c        Wed Oct 12 23:00:54 2011 +0200
> @@ -40,7 +40,7 @@
>  static StonithPlugin *       nw_rpc100s_new(const char *);
>  static void          nw_rpc100s_destroy(StonithPlugin *);
>  static int           nw_rpc100s_set_config(StonithPlugin *, StonithNVpair *);
> -static const char**  nw_rpc100s_get_confignames(StonithPlugin *);
> +static const char * const *  nw_rpc100s_get_confignames(StonithPlugin *);
>  static const char *  nw_rpc100s_getinfo(StonithPlugin * s, int InfoType);
>  static int           nw_rpc100s_status(StonithPlugin * );
>  static int           nw_rpc100s_reset_req(StonithPlugin * s, int request, 
> const char * host);
> @@ -678,7 +678,7 @@
>  /*
>   * Return STONITH config vars
>   */
> -static const char **
> +static const char * const *
>  nw_rpc100s_get_confignames(StonithPlugin* p)
>  {
>       static const char *     RpcParams[] = {ST_TTYDEV , ST_HOSTLIST, NULL };
> diff -r 61fd9fb20b99 lib/plugins/stonith/rcd_serial.c
> --- a/lib/plugins/stonith/rcd_serial.c        Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/rcd_serial.c        Wed Oct 12 23:00:54 2011 +0200
> @@ -54,7 +54,7 @@
>  static StonithPlugin*        rcd_serial_new(const char *);
>  static void          rcd_serial_destroy(StonithPlugin *);
>  static int           rcd_serial_set_config(StonithPlugin *, StonithNVpair *);
> -static const char ** rcd_serial_get_confignames(StonithPlugin *);
> +static const char * const *  rcd_serial_get_confignames(StonithPlugin *);
>  static const char *  rcd_serial_getinfo(StonithPlugin * s, int InfoType);
>  static int           rcd_serial_status(StonithPlugin * );
>  static int           rcd_serial_reset_req(StonithPlugin * s, int request, 
> const char * host);
> @@ -347,7 +347,7 @@
>               return(NULL);
>       }
>  
> -     return OurImports->CopyHostList((const char **)rcd->hostlist);
> +     return OurImports->CopyHostList((const char * const *)rcd->hostlist);
>  }
>  
>  /*
> @@ -497,7 +497,7 @@
>  /*
>   * Return STONITH config vars
>   */
> -static const char**
> +static const char * const *
>  rcd_serial_get_confignames(StonithPlugin* p)
>  {
>       static const char *     RcdParams[] = {ST_HOSTLIST, ST_TTYDEV
> diff -r 61fd9fb20b99 lib/plugins/stonith/rhcs.c
> --- a/lib/plugins/stonith/rhcs.c      Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/rhcs.c      Wed Oct 12 23:00:54 2011 +0200
> @@ -53,7 +53,7 @@
>  static StonithPlugin *       rhcs_new(const char *);
>  static void          rhcs_destroy(StonithPlugin *);
>  static int           rhcs_set_config(StonithPlugin *, StonithNVpair *);
> -static const char**  rhcs_get_confignames(StonithPlugin *);
> +static const char * const *  rhcs_get_confignames(StonithPlugin *);
>  static const char *  rhcs_getinfo(StonithPlugin * s, int InfoType);
>  static int           rhcs_status(StonithPlugin * );
>  static int           rhcs_reset_req(StonithPlugin * s, int request, const 
> char * host);
> @@ -659,7 +659,7 @@
>  /*
>   * Return STONITH config vars
>   */
> -static const char**
> +static const char * const *
>  rhcs_get_confignames(StonithPlugin* p)
>  {
>       struct pluginDevice *   sd;
> @@ -703,7 +703,7 @@
>               sd->confignames[dircount] = NULL;
>       }
>  
> -     return (const char **)sd->confignames;
> +     return (const char * const *)sd->confignames;
>  }
>  
>  /*
> diff -r 61fd9fb20b99 lib/plugins/stonith/rps10.c
> --- a/lib/plugins/stonith/rps10.c     Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/rps10.c     Wed Oct 12 23:00:54 2011 +0200
> @@ -43,7 +43,7 @@
>  static StonithPlugin *       rps10_new(const char *);
>  static void          rps10_destroy(StonithPlugin *);
>  static int           rps10_set_config(StonithPlugin *, StonithNVpair *);
> -static const char**  rps10_get_confignames(StonithPlugin *);
> +static const char * const *  rps10_get_confignames(StonithPlugin *);
>  static const char *  rps10_getinfo(StonithPlugin * s, int InfoType);
>  static int           rps10_status(StonithPlugin * );
>  static int           rps10_reset_req(StonithPlugin * s, int request, const 
> char * host);
> @@ -948,7 +948,7 @@
>   *  Return the Stonith plugin configuration parameter 
>   *
>   */
> -static const char**
> +static const char * const *
>  rps10_get_confignames(StonithPlugin* p)
>  {
>       static const char *     Rps10Params[] = {ST_RPS10 ,NULL };
> diff -r 61fd9fb20b99 lib/plugins/stonith/ssh.c
> --- a/lib/plugins/stonith/ssh.c       Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/ssh.c       Wed Oct 12 23:00:54 2011 +0200
> @@ -36,7 +36,7 @@
>  
>  static StonithPlugin *       ssh_new(const char *);
>  static void          ssh_destroy(StonithPlugin *);
> -static const char**  ssh_get_confignames(StonithPlugin *);
> +static const char * const *  ssh_get_confignames(StonithPlugin *);
>  static int           ssh_set_config(StonithPlugin *, StonithNVpair*);
>  static const char *  ssh_get_info(StonithPlugin * s, int InfoType);
>  static int           ssh_status(StonithPlugin * );
> @@ -161,7 +161,7 @@
>               return(NULL);
>       }
>  
> -     return OurImports->CopyHostList((const char **)sd->hostlist);
> +     return OurImports->CopyHostList((const char * const *)sd->hostlist);
>  }
>  
>  
> @@ -234,7 +234,7 @@
>       }
>  }
>  
> -static const char**
> +static const char * const *
>  ssh_get_confignames(StonithPlugin* p)
>  {
>       static const char *     SshParams[] = {ST_HOSTLIST, NULL };
> diff -r 61fd9fb20b99 lib/plugins/stonith/suicide.c
> --- a/lib/plugins/stonith/suicide.c   Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/suicide.c   Wed Oct 12 23:00:54 2011 +0200
> @@ -34,7 +34,7 @@
>  
>  static StonithPlugin *       suicide_new(const char *);
>  static void          suicide_destroy(StonithPlugin *);
> -static const char**  suicide_get_confignames(StonithPlugin *);
> +static const char * const *  suicide_get_confignames(StonithPlugin *);
>  static int           suicide_set_config(StonithPlugin *, StonithNVpair*);
>  static const char *  suicide_get_info(StonithPlugin * s, int InfoType);
>  static int           suicide_status(StonithPlugin * );
> @@ -189,7 +189,7 @@
>       }
>  }
>  
> -static const char**
> +static const char * const *
>  suicide_get_confignames(StonithPlugin* p)
>  {
>       /* Donnot need to initialize from external. */
> diff -r 61fd9fb20b99 lib/plugins/stonith/wti_nps.c
> --- a/lib/plugins/stonith/wti_nps.c   Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/plugins/stonith/wti_nps.c   Wed Oct 12 23:00:54 2011 +0200
> @@ -78,7 +78,7 @@
>  
>  static StonithPlugin *       wti_nps_new(const char *);
>  static void          wti_nps_destroy(StonithPlugin *);
> -static const char**  wti_nps_get_confignames(StonithPlugin *);
> +static const char * const *  wti_nps_get_confignames(StonithPlugin *);
>  static int           wti_nps_set_config(StonithPlugin * , StonithNVpair * );
>  static const char *  wti_nps_get_info(StonithPlugin * s, int InfoType);
>  static int           wti_nps_status(StonithPlugin * );
> @@ -689,7 +689,7 @@
>   * Return the Stonith plugin configuration parameter 
>   *
>   */
> -static const char**
> +static const char * const *
>  wti_nps_get_confignames(StonithPlugin * p)
>  {
>       static  const char * names[] =  { ST_IPADDR , ST_PASSWD , NULL};
> diff -r 61fd9fb20b99 lib/stonith/expect.c
> --- a/lib/stonith/expect.c    Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/stonith/expect.c    Wed Oct 12 23:00:54 2011 +0200
> @@ -335,10 +335,10 @@
>  }
>  
>  static char **
> -stonith_copy_hostlist(const char** hostlist)
> +stonith_copy_hostlist(const char * const * hostlist)
>  {
>       int hlleng = 1;
> -     const char ** here = hostlist;
> +     const char * const * here = hostlist;
>       char ** hret;
>       char ** ret;
>  
> diff -r 61fd9fb20b99 lib/stonith/main.c
> --- a/lib/stonith/main.c      Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/stonith/main.c      Wed Oct 12 23:00:54 2011 +0200
> @@ -191,7 +191,7 @@
>       for(this=typelist; *this && !devfound; ++this) {
>               const char *    SwitchType = *this;
>               const char *    cres;
> -             const char **   pnames;
> +             const char * const *    pnames;
>  
>  
>               if ((s = stonith_new(SwitchType)) == NULL) {
> @@ -318,7 +318,7 @@
>  void
>  print_confignames(Stonith *s)
>  {
> -     const char**    names;
> +     const char * const *    names;
>       int             i;
>  
>       names = stonith_get_confignames(s);
> @@ -572,7 +572,7 @@
>  
>       if (!listparanames && !metadata && optfile == NULL &&
>                       parameters == NULL && !params_from_env && nvcount == 0) 
> {
> -             const char**    names;
> +             const char * const *    names;
>               int             needs_parms = 1;
>  
>               if (s != NULL && (names = stonith_get_confignames(s)) != NULL 
> && names[0] == NULL) {
> @@ -654,7 +654,7 @@
>                *      Configure STONITH device using cmdline arguments...
>                */
>               if ((rc = stonith_set_config(s, nvargs)) != S_OK) {
> -                     const char**    names;
> +                     const char * const *    names;
>                       int             j;
>                       fprintf(stderr
>                       ,       "Invalid config info for %s device\n"
> diff -r 61fd9fb20b99 lib/stonith/stonith.c
> --- a/lib/stonith/stonith.c   Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/stonith/stonith.c   Wed Oct 12 23:00:54 2011 +0200
> @@ -166,7 +166,8 @@
>  get_plugin_list(const char *pltype)
>  {
>       char ** typelist = NULL;
> -     const char **extPI, **p;
> +     const char * const *extPI;
> +     const char * const *p;
>       int numextPI, i;
>       Stonith * ext;
>  
> @@ -303,7 +305,7 @@
>       }
>  }
>  
> -const char **
> +const char * const *
>  stonith_get_confignames(Stonith* s)
>  {
>       StonithPlugin*  sp = (StonithPlugin*)s;
> @@ -471,7 +473,7 @@
>        * Everything after the last delimiter is passed along as part of
>        * the final argument - white space and all...
>        */
> -     const char **   config_names;
> +     const char * const *    config_names;
>       int             n_names;
>       int             j;
>       const char *    delims = " \t\n\r\f";
> @@ -521,7 +523,7 @@
>  stonith_env_to_NVpair(Stonith* s)
>  {
>       /* Read the config names values from the environment */
> -     const char **   config_names;
> +     const char * const *    config_names;
>       int             n_names;
>       int             j;
>       StonithNVpair*  ret;
> 
> ======================================================================
> move qsort to sort the copy, not the supposedly const char * const *
> 
> diff -r 61fd9fb20b99 lib/stonith/stonith.c
> --- a/lib/stonith/stonith.c   Wed Oct 12 20:49:40 2011 +0200
> +++ b/lib/stonith/stonith.c   Wed Oct 12 23:00:54 2011 +0200
> @@ -185,9 +186,6 @@
>       /* count the external plugins */
>       for (numextPI = 0, p = extPI; *p; p++, numextPI++);
>  
> -     /* sort the external plugins */
> -     qsort(extPI, numextPI, sizeof(char *), qsort_string_cmp);
> -
>       typelist = (char **)
>               MALLOC((numextPI+1)*sizeof(char *));
>       if (typelist == NULL) {
> @@ -213,6 +211,10 @@
>       }
>  
>       stonith_delete(ext);
> +
> +     /* sort the list of plugin names */
> +     qsort(typelist, numextPI, sizeof(char *), qsort_string_cmp);
> +
>       return typelist;
>  err:
>       stonith_free_hostlist(typelist);
> 
> ======================================================================
> Re-enable -Wcast-qual
> 
> diff -r 61fd9fb20b99 configure.ac
> --- a/configure.ac    Wed Oct 12 20:49:40 2011 +0200
> +++ b/configure.ac    Wed Oct 12 23:00:54 2011 +0200
> @@ -1182,12 +1182,12 @@
>          CFLAGS="$CFLAGS -ggdb3 -O0"
>  
>       # We had to eliminate -Wnested-externs because of libtool changes
> -     # -Wcast-qual gives errors with GCC 4.6
>          EXTRA_FLAGS="-fgnu89-inline
>               -fstack-protector-all
>               -Wall
>               -Waggregate-return
>               -Wbad-function-cast 
> +             -Wcast-qual
>               -Wcast-align 
>               -Wdeclaration-after-statement
>               -Wendif-labels
> _______________________________________________________
> Linux-HA-Dev: [email protected]
> http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> Home Page: http://linux-ha.org/
_______________________________________________________
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