patches look good for commit

regards
-steve

On Tue, 2009-03-24 at 12:15 +0100, Jim Meyering wrote:
> Compiling the latest, I saw these:
> 
>   vsf_ykd.c:349: warning: pointer of type 'void *' used in arithmetic
>   cpg.c:692: warning: pointer of type 'void *' used in arithmetic
>   cpg.c:696: warning: pointer of type 'void *' used in arithmetic
>   cpg.c:878: warning: pointer of type 'void *' used in arithmetic
>   cpg.c:888: warning: pointer of type 'void *' used in arithmetic
>   votequorum.c:997: warning: pointer of type 'void *' used in arithmetic
> 
> since they really do cause trouble in some environments,
> I've fixed them like this:
> 
> From d8059e8fb572a4807cf2e9a90eb77c02ef6838c4 Mon Sep 17 00:00:00 2001
> From: Jim Meyering <[email protected]>
> Date: Tue, 24 Mar 2009 12:01:55 +0100
> Subject: [PATCH 1/2] avoid performing 'void *' arithmetic, and add a few 
> const attributes
> 
> ---
>  services/cpg.c |   23 ++++++++++++-----------
>  1 files changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/services/cpg.c b/services/cpg.c
> index d8b4a2b..ae1a665 100644
> --- a/services/cpg.c
> +++ b/services/cpg.c
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright (c) 2006-2008 Red Hat, Inc.
> + * Copyright (c) 2006-2009 Red Hat, Inc.
>   *
>   * All rights reserved.
>   *
> @@ -139,7 +139,7 @@ static void message_handler_req_exec_cpg_procleave (
>       unsigned int nodeid);
> 
>  static void message_handler_req_exec_cpg_joinlist (
> -     void *message,
> +     const void *message,
>       unsigned int nodeid);
> 
>  static void message_handler_req_exec_cpg_mcast (
> @@ -513,7 +513,7 @@ static int count_groups(void)
>       return num_groups;
>  }
> 
> -static struct group_info *get_group(mar_cpg_name_t *name)
> +static struct group_info *get_group(const mar_cpg_name_t *name)
>  {
>       struct list_head *iter;
>       struct group_info *gi = NULL;
> @@ -686,14 +686,15 @@ static void exec_cpg_procjoin_endian_convert (void *msg)
>       req_exec_cpg_procjoin->reason = swab32(req_exec_cpg_procjoin->reason);
>  }
> 
> -static void exec_cpg_joinlist_endian_convert (void *msg)
> +static void exec_cpg_joinlist_endian_convert (void *msg_v)
>  {
> +     char *msg = msg_v;
>       mar_res_header_t *res = (mar_res_header_t *)msg;
>       struct join_list_entry *jle = (struct join_list_entry *)(msg + 
> sizeof(mar_res_header_t));
> 
>       /* XXX shouldn't mar_res_header be swabbed? */
> 
> -     while ((void*)jle < msg + res->size) {
> +     while ((const char*)jle < msg + res->size) {
>               jle->pid = swab32(jle->pid);
>               swab_mar_cpg_name_t (&jle->group_name);
>               jle++;
> @@ -725,7 +726,7 @@ static void exec_cpg_mcast_endian_convert (void *msg)
>  }
> 
>  static void do_proc_join(
> -     mar_cpg_name_t *name,
> +     const mar_cpg_name_t *name,
>       uint32_t pid,
>       unsigned int nodeid,
>       int reason)
> @@ -871,11 +872,12 @@ static void message_handler_req_exec_cpg_procleave (
> 
>  /* Got a proclist from another node */
>  static void message_handler_req_exec_cpg_joinlist (
> -     void *message,
> +     const void *message_v,
>       unsigned int nodeid)
>  {
> -     mar_res_header_t *res = (mar_res_header_t *)message;
> -     struct join_list_entry *jle = (struct join_list_entry *)(message + 
> sizeof(mar_res_header_t));
> +     const char *message = message_v;
> +     const mar_res_header_t *res = (const mar_res_header_t *)message;
> +     const struct join_list_entry *jle = (const struct join_list_entry 
> *)(message + sizeof(mar_res_header_t));
> 
>       log_printf(LOG_LEVEL_NOTICE, "got joinlist message from node %d\n",
>               nodeid);
> @@ -885,7 +887,7 @@ static void message_handler_req_exec_cpg_joinlist (
>               return;
>       }
> 
> -     while ((void*)jle < message + res->size) {
> +     while ((const char*)jle < message + res->size) {
>               do_proc_join(&jle->group_name, jle->pid, nodeid,
>                       CONFCHG_CPG_REASON_NODEUP);
>               jle++;
> @@ -1225,4 +1227,3 @@ static void message_handler_req_lib_cpg_groups_get 
> (void *conn, void *message)
>       api->ipc_response_send(conn, &res_lib_cpg_groups_get,
>               sizeof(res_lib_cpg_groups_get));
>  }
> -
> -- 
> 1.6.2.rc1.285.gc5f54
> 
> 
> From 6b4af4d65d019def21df452ee42ccaee5111957d Mon Sep 17 00:00:00 2001
> From: Jim Meyering <[email protected]>
> Date: Tue, 24 Mar 2009 12:10:29 +0100
> Subject: [PATCH 2/2] Do not perform arithmetic on "void*" pointers.
> 
> * exec/vsf_ykd.c (ykd_deliver_fn): Do not perform "void*" arithmetic.
> * services/votequorum.c (quorum_deliver_fn): Likewise.
> ---
>  exec/vsf_ykd.c        |    4 ++--
>  services/votequorum.c |    2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/exec/vsf_ykd.c b/exec/vsf_ykd.c
> index c993d7f..9542fa4 100644
> --- a/exec/vsf_ykd.c
> +++ b/exec/vsf_ykd.c
> @@ -1,6 +1,6 @@
>  /*
>   * Copyright (c) 2005 MontaVista Software, Inc.
> - * Copyright (c) 2006-2008 Red Hat, Inc.
> + * Copyright (c) 2006-2009 Red Hat, Inc.
>   *
>   * All rights reserved.
>   *
> @@ -346,7 +346,7 @@ static void ykd_deliver_fn (
>       int all_received = 1;
>       int state_position = 0;
>       int i;
> -     char *msg_state = iovec->iov_base + sizeof (struct ykd_header);
> +     char *msg_state = (char *)(iovec->iov_base) + sizeof (struct 
> ykd_header);
>       
>       /*
>        * If this is a localhost address, this node is always primary
> diff --git a/services/votequorum.c b/services/votequorum.c
> index 537276d..2f4c397 100644
> --- a/services/votequorum.c
> +++ b/services/votequorum.c
> @@ -994,7 +994,7 @@ static void quorum_deliver_fn(unsigned int nodeid, struct 
> iovec *iovec, int iov_
>       if (header->tgtport == 0 &&
>           (header->tgtid == us->node_id ||
>            header->tgtid == 0)) {
> -             buf = iovec->iov_base + sizeof(struct q_protheader);
> +             buf = (char *)(iovec->iov_base) + sizeof(struct q_protheader);
>               switch (*buf) {
> 
>               case VOTEQUORUM_MSG_NODEINFO:

_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to