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.
diff -r 856ae1408ff9 configure.ac
--- a/configure.ac Sun Jun 19 21:03:24 2011 +0200
+++ b/configure.ac Wed Jun 29 12:54:49 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
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 Wed Jun 29 12:54:49 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 Wed Jun 29 12:54:49 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 Wed Jun 29 12:54:49 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 Wed Jun 29 12:54:49 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 Wed Jun 29 12:54:49 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 Wed Jun 29 12:54:49 2011 +0100
@@ -1117,7 +1117,6 @@
int nbytes;
int result;
- struct IPC_MESSAGE* ipcmsg;
socket_resume_io(ch);
result = socket_resume_io_read(ch, &nbytes, TRUE);
@@ -1138,12 +1137,10 @@
ch->recv_queue->current_qlen = 0;
return IPC_FAIL;
}
- ipcmsg = *message = (struct IPC_MESSAGE *) (element->data);
-
-
-#ifdef IPC_TIME_DEBUG
- ipc_time_debug(ch, ipcmsg, MSGPOS_DEQUEUE);
-#endif
+ *message = (struct IPC_MESSAGE *) (element->data);
+#ifdef IPC_TIME_DEBUG
+ ipc_time_debug(ch, *message, 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 Wed Jun 29 12:54:49 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 Wed Jun 29 12:54:49 2011 +0100
@@ -370,6 +370,8 @@
*rsc_info = g_list_remove(*rsc_info, cur->data);
g_free(cur->data);
}
+#else
+ (void) is_lsb_script;
#endif
cur = tmp;
}
@@ -504,6 +506,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 Wed Jun 29 12:54:49 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);
+ vsnprintf(buf, sizeof(buf)-1, fmt, ap);
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 Wed Jun 29 12:54:49 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 Wed Jun 29 12:54:49 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: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/