Mailing List Archive

[PATCH] [glue] Fix compilation with GCC 4.6
The attached patch fixes compilation -Werrors with GCC 4.6

cheers,
Pádraig.
Re: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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"?

> diff -r 856ae1408ff9 configure.ac
> --- a/configure.ac Sun Jun 19 21:03:24 2011 +0200
> +++ b/configure.ac Tue Jun 28 01:23:28 2011 +0100
> @@ -1186,12 +1186,12 @@
> CFLAGS="$CFLAGS -ggdb3 -O0"
>
> # We had to eliminate -Wnested-externs because of libtool changes
> + # -Wcast-qual gives errors with GCC 4.6

And those cannot be fixed?
Why?

> EXTRA_FLAGS="-fgnu89-inline
> -fstack-protector-all
> -Wall
> -Waggregate-return
> -Wbad-function-cast
> - -Wcast-qual
> -Wcast-align
> -Wdeclaration-after-statement
> -Wendif-labels
> diff -r 856ae1408ff9 lib/clplumbing/base64_md5_test.c
> --- a/lib/clplumbing/base64_md5_test.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/clplumbing/base64_md5_test.c Tue Jun 28 01:23:28 2011 +0100
> @@ -108,5 +108,6 @@
> error_count++;
> }
>
> + (void) rc; /* Suppress -Werror=unused-but-set-variable */
> return error_count;
> }
> diff -r 856ae1408ff9 lib/clplumbing/cl_msg.c
> --- a/lib/clplumbing/cl_msg.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/clplumbing/cl_msg.c Tue Jun 28 01:23:28 2011 +0100
> @@ -598,7 +598,6 @@
> {
>
> size_t startlen = sizeof(MSG_START)-1;
> - int internal_type;
>
>
> int (*addfield) (struct ha_msg* msg, char* name, size_t namelen,
> @@ -633,8 +632,6 @@
> return(HA_FAIL);
> }
>
> - internal_type = type;
> -
> HA_MSG_ASSERT(type < DIMOF(fieldtypefuncs));
>
> addfield = fieldtypefuncs[type].addfield;
> diff -r 856ae1408ff9 lib/clplumbing/cl_msg_types.c
> --- a/lib/clplumbing/cl_msg_types.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/clplumbing/cl_msg_types.c Tue Jun 28 01:23:28 2011 +0100
> @@ -931,7 +931,6 @@
> void* value, size_t vallen, int depth)
> {
> int next;
> - struct ha_msg* childmsg;
>
> if ( !msg || !name || !value
> || depth < 0){
> @@ -940,8 +939,6 @@
> return HA_FAIL;
> }
>
> - childmsg = (struct ha_msg*)value;
> -
> next = msg->nfields;
> msg->names[next] = name;
> msg->nlens[next] = namelen;
> @@ -964,7 +961,6 @@
> int next;
> int j;
> GList* list = NULL;
> - int stringlen_add;
>
> if ( !msg || !name || !value
> || namelen <= 0
> @@ -983,13 +979,8 @@
> }
>
> if ( j >= msg->nfields){
> - int listlen;
> list = (GList*)value;
>
> - listlen = string_list_pack_length(list);
> -
> - stringlen_add = list_stringlen(namelen,listlen , value);
> -
> next = msg->nfields;
> msg->names[next] = name;
> msg->nlens[next] = namelen;
> @@ -1001,8 +992,7 @@
> } else if( msg->types[j] == FT_LIST ){
>
> GList* oldlist = (GList*) msg->values[j];
> - int oldlistlen = string_list_pack_length(oldlist);
> - int newlistlen;
> + int listlen;
> size_t i;
>
> for ( i =0; i < g_list_length((GList*)value); i++){
> @@ -1014,12 +1004,10 @@
> return HA_FAIL;
> }
>
> - newlistlen = string_list_pack_length(list);
> + listlen = string_list_pack_length(list);
>
> - stringlen_add = newlistlen - oldlistlen;
> -
> msg->values[j] = list;
> - msg->vlens[j] = string_list_pack_length(list);
> + msg->vlens[j] = listlen;
> g_list_free((GList*)value); /*we don't free each element
> because they are used in new list*/
> free(name); /* this name is no longer necessary
> @@ -1069,7 +1057,6 @@
> void* value, size_t vallen, int depth)
> {
> int next;
> - struct ha_msg* childmsg;
>
> if ( !msg || !name || !value
> || depth < 0){
> @@ -1078,8 +1065,6 @@
> return HA_FAIL;
> }
>
> - childmsg = (struct ha_msg*)value;
> -
> next = msg->nfields;
> msg->names[next] = name;
> msg->nlens[next] = namelen;
> diff -r 856ae1408ff9 lib/clplumbing/cl_poll.c
> --- a/lib/clplumbing/cl_poll.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/clplumbing/cl_poll.c Tue Jun 28 01:23:28 2011 +0100
> @@ -497,7 +497,6 @@
> int
> cl_poll_ignore(int fd)
> {
> - short nsig;
> int flags;
>
> if (debug) {
> @@ -511,7 +510,6 @@
> if (!is_monitored[fd]) {
> return 0;
> }
> - nsig = monitorinfo[fd].nsig;
>
> is_monitored[fd] = FALSE;
> memset(monitorinfo+fd, 0, sizeof(monitorinfo[0]));
> diff -r 856ae1408ff9 lib/clplumbing/cl_syslog.c
> --- a/lib/clplumbing/cl_syslog.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/clplumbing/cl_syslog.c Tue Jun 28 01:23:28 2011 +0100
> @@ -120,14 +120,12 @@
> int
> cl_syslogfac_str2int(const char *fname)
> {
> - struct _syslog_code *fnames;
> int i;
>
> if(fname == NULL || strcmp("none", fname) == 0) {
> return 0;
> }
>
> - fnames = (struct _syslog_code *) facilitynames;
> for (i = 0; facilitynames[i].c_name != NULL; i++) {
> if (strcmp(fname, facilitynames[i].c_name) == 0) {
> return facilitynames[i].c_val;
> @@ -140,10 +138,8 @@
> const char *
> cl_syslogfac_int2str(int fnum)
> {
> - struct _syslog_code *fnames;
> int i;
>
> - fnames = (struct _syslog_code *) facilitynames;
> for (i = 0; facilitynames[i].c_name != NULL; i++) {
> if (facilitynames[i].c_val == fnum) {
> return facilitynames[i].c_name;
> diff -r 856ae1408ff9 lib/clplumbing/ipcsocket.c
> --- a/lib/clplumbing/ipcsocket.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/clplumbing/ipcsocket.c Tue Jun 28 01:23:28 2011 +0100
> @@ -1117,7 +1117,9 @@
>
> int nbytes;
> int result;
> +#ifdef IPC_TIME_DEBUG
> struct IPC_MESSAGE* ipcmsg;
> +#endif
>
> socket_resume_io(ch);
> result = socket_resume_io_read(ch, &nbytes, TRUE);
> @@ -1138,12 +1140,10 @@
> ch->recv_queue->current_qlen = 0;
> return IPC_FAIL;
> }
> +#ifdef IPC_TIME_DEBUG
> ipcmsg = *message = (struct IPC_MESSAGE *) (element->data);

Um, you skip setting message now??
I think you need to keep
*message = (struct IPC_MESSAGE *) (element->data);
outside the ifdef?

> -
> -
> -#ifdef IPC_TIME_DEBUG
> - ipc_time_debug(ch, ipcmsg, MSGPOS_DEQUEUE);
> -#endif
> + ipc_time_debug(ch, ipcmsg, MSGPOS_DEQUEUE);
> +#endif
>
> CHECKFOO(1,ch, *message, SavedReadBody, "read message");
> SocketIPCStats.nreceived++;
> diff -r 856ae1408ff9 lib/clplumbing/ipctest.c
> --- a/lib/clplumbing/ipctest.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/clplumbing/ipctest.c Tue Jun 28 01:23:28 2011 +0100
> @@ -1326,7 +1326,6 @@
> mainloop_server(IPC_Channel* chan, int repcount)
> {
> struct iterinfo info;
> - GCHSource* msgchan;
> guint sendmsgsrc;
>
>
> @@ -1340,7 +1339,7 @@
> chan->low_flow_mark = 2;
>
> sendmsgsrc = g_idle_add(s_send_msg, &info);
> - msgchan = G_main_add_IPC_Channel(G_PRIORITY_DEFAULT, chan
> + G_main_add_IPC_Channel(G_PRIORITY_DEFAULT, chan
> , FALSE, s_rcv_msg, &info, NULL);
> cl_log(LOG_INFO, "Mainloop echo server: %d reps pid %d.", repcount, (int)getpid());
> g_main_run(loop);
> diff -r 856ae1408ff9 lib/plugins/lrm/raexeclsb.c
> --- a/lib/plugins/lrm/raexeclsb.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lib/plugins/lrm/raexeclsb.c Tue Jun 28 01:23:28 2011 +0100
> @@ -322,7 +322,6 @@
> cur = tmp;
> continue;
> }
> - is_lsb_script = FALSE;

Why? that does not look right.

> next_continue = FALSE;
> found_begin_tag = FALSE;
> while (NULL != fgets(buffer, BUFLEN, fp)) {
> @@ -370,6 +369,8 @@
> *rsc_info = g_list_remove(*rsc_info, cur->data);
> g_free(cur->data);
> }
> +#else
> + (void) is_lsb_script;
> #endif
> cur = tmp;
> }
> @@ -504,6 +505,8 @@
> break;
> }
> }
> +#else
> + (void) next_continue;
> #endif
>
> /* Enter into the lsb-compliant comment block */
> diff -r 856ae1408ff9 logd/ha_logd.c
> --- a/logd/ha_logd.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/logd/ha_logd.c Tue Jun 28 01:23:28 2011 +0100
> @@ -138,11 +138,10 @@
> {
> char buf[MAXLINE];
> va_list ap;
> - int nbytes;
>
> buf[MAXLINE-1] = EOS;
> va_start(ap, fmt);
> - nbytes=vsnprintf(buf, sizeof(buf)-1, fmt, ap);
> + (void) vsnprintf(buf, sizeof(buf)-1, fmt, ap);

What is that (void) supposed to achieve?

> va_end(ap);
>
> fprintf(stderr, "%s", buf);
> diff -r 856ae1408ff9 lrm/test/apitest.c
> --- a/lrm/test/apitest.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lrm/test/apitest.c Tue Jun 28 01:23:28 2011 +0100
> @@ -44,7 +44,6 @@
> lrm_op_t* op = NULL;
> const char* rid = "ip248";
> GHashTable* param = NULL;
> - int call_id;
> GList* classes;
> int i;
>
> @@ -104,7 +103,7 @@
> op->user_data_len = strlen(op->user_data)+1;
> op->interval = 1000;
> op->target_rc=EVERYTIME;
> - call_id = rsc->ops->perform_op(rsc,op);
> + rsc->ops->perform_op(rsc,op);
> printf_op(op);
> lrm_free_op(op);
>
> @@ -142,7 +141,7 @@
> op->user_data_len = strlen(op->user_data)+1;
> op->interval = 2000;
> op->target_rc=EVERYTIME;
> - call_id = rsc->ops->perform_op(rsc,op);
> + rsc->ops->perform_op(rsc,op);
> printf_op(op);
> lrm_free_op(op);
>
> @@ -180,7 +179,7 @@
> op->user_data_len = strlen(op->user_data)+1;
> op->interval = 3000;
> op->target_rc=EVERYTIME;
> - call_id = rsc->ops->perform_op(rsc,op);
> + rsc->ops->perform_op(rsc,op);
> printf_op(op);
> lrm_free_op(op);
>
> diff -r 856ae1408ff9 lrm/test/callbacktest.c
> --- a/lrm/test/callbacktest.c Sun Jun 19 21:03:24 2011 +0200
> +++ b/lrm/test/callbacktest.c Tue Jun 28 01:23:28 2011 +0100
> @@ -44,7 +44,6 @@
> lrm_op_t* op = NULL;
> const char* rid = "ip248";
> GHashTable* param = NULL;
> - int call_id;
>
> lrm = ll_lrm_new("lrm");
>
> @@ -94,7 +93,7 @@
> op->user_data_len = strlen(op->user_data)+1;
> op->interval = 1000;
> op->target_rc=EVERYTIME;
> - call_id = rsc->ops->perform_op(rsc,op);
> + rsc->ops->perform_op(rsc,op);
> printf_op(op);
>
> puts("perform_op(stop)...");
>

> _______________________________________________________
> 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/


--
: 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: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
Re: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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]

>
>> diff -r 856ae1408ff9 configure.ac
>> --- a/configure.ac Sun Jun 19 21:03:24 2011 +0200
>> +++ b/configure.ac Tue Jun 28 01:23:28 2011 +0100
>> @@ -1186,12 +1186,12 @@
>> CFLAGS="$CFLAGS -ggdb3 -O0"
>>
>> # We had to eliminate -Wnested-externs because of libtool changes
>> + # -Wcast-qual gives errors with GCC 4.6
>
> And those cannot be fixed?
> Why?

I thought it would be too invasive.
There may be a simpler work around I'm missing.

>> --- a/lib/clplumbing/ipcsocket.c Sun Jun 19 21:03:24 2011 +0200
>> +++ b/lib/clplumbing/ipcsocket.c Tue Jun 28 01:23:28 2011 +0100
>> @@ -1117,7 +1117,9 @@
>>
>> int nbytes;
>> int result;
>> +#ifdef IPC_TIME_DEBUG
>> struct IPC_MESSAGE* ipcmsg;
>> +#endif
>>
>> socket_resume_io(ch);
>> result = socket_resume_io_read(ch, &nbytes, TRUE);
>> @@ -1138,12 +1140,10 @@
>> ch->recv_queue->current_qlen = 0;
>> return IPC_FAIL;
>> }
>> +#ifdef IPC_TIME_DEBUG
>> ipcmsg = *message = (struct IPC_MESSAGE *) (element->data);
>
> Um, you skip setting message now??
> I think you need to keep
> *message = (struct IPC_MESSAGE *) (element->data);
> outside the ifdef?

ouch. well spotted.
I've simplified the code to not use a temp variable at all.

>> --- a/lib/plugins/lrm/raexeclsb.c Sun Jun 19 21:03:24 2011 +0200
>> +++ b/lib/plugins/lrm/raexeclsb.c Tue Jun 28 01:23:28 2011 +0100
>> @@ -322,7 +322,6 @@
>> cur = tmp;
>> continue;
>> }
>> - is_lsb_script = FALSE;
>
> Why? that does not look right.

I did that before I noticed it was used in the ifdef.
I shouldn't have removed that, in case the ifdef'd code is reinstated.

>> --- a/logd/ha_logd.c Sun Jun 19 21:03:24 2011 +0200
>> +++ b/logd/ha_logd.c Tue Jun 28 01:23:28 2011 +0100
>> @@ -138,11 +138,10 @@
>> {
>> char buf[MAXLINE];
>> va_list ap;
>> - int nbytes;
>>
>> buf[MAXLINE-1] = EOS;
>> va_start(ap, fmt);
>> - 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.

Updated patch attached.

cheers,
Pádraig.
Re: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
Re: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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).

Oh and originally I forgot to mention that
these changes are required to get this project to
compile on Fedora 15.

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/
Re: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
Hi,

On Thu, Jun 30, 2011 at 09:33:57PM +0200, 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?
>
> > >> - 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?

Unfortunately, I'm swamped by other obligations right now.
If the patch helps compile with the new gcc and doesn't break
existing, we can of course include it. I'd just suggest that it
comes in smaller chunks, if I'm not wrong, it contained various
unrelated stuff.

Cheers,

Dejan

> --
> : 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: 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: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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.

> Oh and originally I forgot to mention that
> these changes are required to get this project to
> compile on Fedora 15.

OK. Many thanks for providing the patch.

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: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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.

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.

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/
Re: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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 <lars.ellenberg@linbit.com>

> 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: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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.

======================================================================
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: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
Re: [PATCH] [glue] Fix compilation with GCC 4.6 [ In reply to ]
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: 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/