Saint Patrick's Day. 17t ffwuitmf. canada goose butikh March. Pádraig

{Advertisements}


Pádraig

цена канадской гуси
guanti d'oca canada
gans
canada goose outlet butikk
канадский гусиный муж

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).
> > > >


 

Art by Padraig McCAUL

Mist On the Minaun Cliffs, Achill
Padraig McCAUL - Mist On the Minaun Cliffs, Achill

Irish Art and Artists at Red Rag Gallery
Artist: Padraig McCAUL

Padraig McCaul was born in Dublin in 1963. He is a a self taught artist who works primarily in oils, using brushes and palette knives in strong, sweeping lines. McCaul's composition and form combine with vibrant, primary colours and all come together in capturing a vision of the Irish landscape

Like many other Irish artists before him Padrag McCaul has been held spellbound by the beauty of the west of Ireland. He believes there is a special energy deeply rooted in the landscape of the west, which he captures in his contemporary paintings.

A number of Irish artists have influenced Padraig McCaul's paintings. They include: the Irish landscape paintings of Paul Henry and Roderick O'Connor, as well contemporary artists such as Donald Teskey. A love of strong, vibrant colours has been inspired by artists such as Norah McGuinness and French artist Claude Idlas.

To receive updates on Irish artist Padraig McCAUL's art and art works at Red Rag Gallery click here

or CALL RED RAG NOW on 01451 832563 or outside the UK +44 1451 832563.