Jelajahi Sumber

avoid performing 'void *' arithmetic, and add a few const attributes

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1906 fd59a12c-fef9-0310-b244-a6a79926bd2f
Jim Meyering 17 tahun lalu
induk
melakukan
0c9c22e085
1 mengubah file dengan 12 tambahan dan 11 penghapusan
  1. 12 11
      services/cpg.c

+ 12 - 11
services/cpg.c

@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2006-2008 Red Hat, Inc.
+ * Copyright (c) 2006-2009 Red Hat, Inc.
  *
  *
  * All rights reserved.
  * All rights reserved.
  *
  *
@@ -139,7 +139,7 @@ static void message_handler_req_exec_cpg_procleave (
 	unsigned int nodeid);
 	unsigned int nodeid);
 
 
 static void message_handler_req_exec_cpg_joinlist (
 static void message_handler_req_exec_cpg_joinlist (
-	void *message,
+	const void *message,
 	unsigned int nodeid);
 	unsigned int nodeid);
 
 
 static void message_handler_req_exec_cpg_mcast (
 static void message_handler_req_exec_cpg_mcast (
@@ -513,7 +513,7 @@ static int count_groups(void)
 	return num_groups;
 	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 list_head *iter;
 	struct group_info *gi = NULL;
 	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);
 	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;
 	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));
 	struct join_list_entry *jle = (struct join_list_entry *)(msg + sizeof(mar_res_header_t));
 
 
 	/* XXX shouldn't mar_res_header be swabbed? */
 	/* 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);
 		jle->pid = swab32(jle->pid);
 		swab_mar_cpg_name_t (&jle->group_name);
 		swab_mar_cpg_name_t (&jle->group_name);
 		jle++;
 		jle++;
@@ -725,7 +726,7 @@ static void exec_cpg_mcast_endian_convert (void *msg)
 }
 }
 
 
 static void do_proc_join(
 static void do_proc_join(
-	mar_cpg_name_t *name,
+	const mar_cpg_name_t *name,
 	uint32_t pid,
 	uint32_t pid,
 	unsigned int nodeid,
 	unsigned int nodeid,
 	int reason)
 	int reason)
@@ -871,11 +872,12 @@ static void message_handler_req_exec_cpg_procleave (
 
 
 /* Got a proclist from another node */
 /* Got a proclist from another node */
 static void message_handler_req_exec_cpg_joinlist (
 static void message_handler_req_exec_cpg_joinlist (
-	void *message,
+	const void *message_v,
 	unsigned int nodeid)
 	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",
 	log_printf(LOG_LEVEL_NOTICE, "got joinlist message from node %d\n",
 		nodeid);
 		nodeid);
@@ -885,7 +887,7 @@ static void message_handler_req_exec_cpg_joinlist (
 		return;
 		return;
 	}
 	}
 
 
-	while ((void*)jle < message + res->size) {
+	while ((const char*)jle < message + res->size) {
 		do_proc_join(&jle->group_name, jle->pid, nodeid,
 		do_proc_join(&jle->group_name, jle->pid, nodeid,
 			CONFCHG_CPG_REASON_NODEUP);
 			CONFCHG_CPG_REASON_NODEUP);
 		jle++;
 		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,
 	api->ipc_response_send(conn, &res_lib_cpg_groups_get,
 		sizeof(res_lib_cpg_groups_get));
 		sizeof(res_lib_cpg_groups_get));
 }
 }
-