This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

cluster: STABLE3 - cman: fix warnings in daemon/ spotted by paranoiacflags


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=98857b8067d04d691ab544366ee385a982c3a732
Commit:        98857b8067d04d691ab544366ee385a982c3a732
Parent:        7c99ca09657285b527405cd7d8d94ff74cb62767
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Tue May 5 10:48:55 2009 +0200
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Tue May 5 10:48:55 2009 +0200

cman: fix warnings in daemon/ spotted by paranoia cflags

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 cman/daemon/ais.c            |    6 ++--
 cman/daemon/cman-preconfig.c |   61 ++++++++++++++++++++++++-----------------
 cman/daemon/cman.h           |    3 +-
 cman/daemon/cmanconfig.c     |    9 +++---
 cman/daemon/commands.c       |   24 ++++++++--------
 cman/daemon/daemon.c         |   12 ++------
 cman/daemon/nodelist.h       |    4 +-
 7 files changed, 62 insertions(+), 57 deletions(-)

diff --git a/cman/daemon/ais.c b/cman/daemon/ais.c
index c40541b..3e04dd6 100644
--- a/cman/daemon/ais.c
+++ b/cman/daemon/ais.c
@@ -13,6 +13,7 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
+#include <inttypes.h>
 
 /* corosync headers */
 #include <corosync/corotypes.h>
@@ -39,7 +40,6 @@
 #include "cmanconfig.h"
 #include "daemon.h"
 
-extern int our_nodeid();
 extern char cluster_name[MAX_CLUSTER_NAME_LEN+1];
 extern unsigned int quorumdev_poll;
 extern unsigned int ccsd_poll_interval;
@@ -324,7 +324,7 @@ static void cman_confchg_fn(enum totem_configuration_type configuration_type,
 	}
 
 	if (configuration_type == TOTEM_CONFIGURATION_REGULAR) {
-		P_AIS("last memb_count = %d, current = %d\n", last_memb_count, member_list_entries);
+		P_AIS("last memb_count = %d, current = %"PRIuFAST32"\n", last_memb_count, member_list_entries);
 		send_transition_msg(last_memb_count, first_trans);
 		last_memb_count = member_list_entries;
 		if (member_list_entries > 1)
@@ -338,7 +338,7 @@ static void cman_confchg_fn(enum totem_configuration_type configuration_type,
 
 /* Write an error message down the CMAN startup pipe so
    that cman_tool can display it */
-int write_cman_pipe(char *message)
+int write_cman_pipe(const char *message)
 {
 	if (startup_pipe)
 		return write(startup_pipe, message, strlen(message)+1);
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index 5af4437..2487401 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -138,7 +138,7 @@ static int ipaddr_equal(struct sockaddr_storage *addr1, struct sockaddr_storage
 /* Build a localhost ip_address */
 static int get_localhost(int family, struct sockaddr_storage *localhost)
 {
-	char *addr_text;
+	const char *addr_text;
 	struct addrinfo *ainfo;
 	struct addrinfo ahints;
 	int ret;
@@ -226,7 +226,7 @@ static hdb_handle_t find_cman_logger(struct objdb_iface_ver0 *objdb, hdb_handle_
 }
 
 
-static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int portnum)
+static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int port)
 {
 	hdb_handle_t totem_object_handle;
 	hdb_handle_t find_handle;
@@ -278,7 +278,7 @@ static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr,
 		objdb->object_key_create(interface_object_handle, "mcastaddr", strlen("mcastaddr"),
 					 mcast, strlen(mcast)+1);
 
-		sprintf(tmp, "%d", portnum);
+		sprintf(tmp, "%d", port);
 		objdb->object_key_create(interface_object_handle, "mcastport", strlen("mcastport"),
 					 tmp, strlen(tmp)+1);
 
@@ -300,7 +300,7 @@ static uint16_t generate_cluster_id(char *name)
 	return value & 0xFFFF;
 }
 
-static char *default_mcast(char *nodename, uint16_t cluster_id)
+static char *default_mcast(char *node, uint16_t clusterid)
 {
         struct addrinfo *ainfo;
         struct addrinfo ahints;
@@ -312,9 +312,9 @@ static char *default_mcast(char *nodename, uint16_t cluster_id)
 
         /* Lookup the the nodename address and use it's IP type to
 	   default a multicast address */
-        ret = getaddrinfo(nodename, NULL, &ahints, &ainfo);
+        ret = getaddrinfo(node, NULL, &ahints, &ainfo);
 	if (ret) {
-		sprintf(error_reason, "Can't determine address family of nodename %s\n", nodename);
+		sprintf(error_reason, "Can't determine address family of nodename %s\n", node);
 		write_cman_pipe("Can't determine address family of nodename");
 		return NULL;
 	}
@@ -323,18 +323,18 @@ static char *default_mcast(char *nodename, uint16_t cluster_id)
 	freeaddrinfo(ainfo);
 
 	if (family == AF_INET) {
-		snprintf(addr, sizeof(addr), "239.192.%d.%d", cluster_id >> 8, cluster_id % 0xFF);
+		snprintf(addr, sizeof(addr), "239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
 		return addr;
 	}
 	if (family == AF_INET6) {
-		snprintf(addr, sizeof(addr), "ff15::%x", cluster_id);
+		snprintf(addr, sizeof(addr), "ff15::%x", clusterid);
 		return addr;
 	}
 
 	return NULL;
 }
 
-static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
+static int verify_nodename(struct objdb_iface_ver0 *objdb, char *node)
 {
 	char nodename2[MAX_CLUSTER_MEMBER_NAME_LEN+1];
 	char nodename3[MAX_CLUSTER_MEMBER_NAME_LEN+1];
@@ -346,17 +346,17 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 	int error;
 
 	/* nodename is either from commandline or from uname */
-	if (nodelist_byname(objdb, cluster_parent_handle, nodename))
+	if (nodelist_byname(objdb, cluster_parent_handle, node))
 		return 0;
 
 	/* If nodename was from uname, try a domain-less version of it */
-	strcpy(nodename2, nodename);
+	strcpy(nodename2, node);
 	dot = strchr(nodename2, '.');
 	if (dot) {
 		*dot = '\0';
 
 		if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-			strcpy(nodename, nodename2);
+			strcpy(node, nodename2);
 			return 0;
 		}
 	}
@@ -382,7 +382,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 
 		if (strlen(nodename2) == len &&
 		    !strncmp(nodename2, nodename3, len)) {
-			strcpy(nodename, str);
+			strcpy(node, str);
 			return 0;
 		}
 		nodes_handle = nodeslist_next(objdb, find_handle);
@@ -401,7 +401,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 		socklen_t salen = 0;
 
 		/* Restore this */
-		strcpy(nodename2, nodename);
+		strcpy(nodename2, node);
 		sa = ifa->ifa_addr;
 		if (!sa)
 			continue;
@@ -418,7 +418,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 		if (!error) {
 
 			if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-				strcpy(nodename, nodename2);
+				strcpy(node, nodename2);
 				goto out;
 			}
 
@@ -428,7 +428,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 				*dot = '\0';
 
 				if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-					strcpy(nodename, nodename2);
+					strcpy(node, nodename2);
 					goto out;
 				}
 			}
@@ -441,7 +441,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 			continue;
 
 		if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-			strcpy(nodename, nodename2);
+			strcpy(node, nodename2);
 			goto out;
 		}
 	}
@@ -453,7 +453,7 @@ static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
 }
 
 /* Get any environment variable overrides */
-static int get_env_overrides()
+static int get_env_overrides(void)
 {
 	if (getenv("CMAN_CLUSTER_NAME")) {
 		cluster_name = strdup(getenv("CMAN_CLUSTER_NAME"));
@@ -617,10 +617,10 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 	objdb->object_find_create(node_object_handle,"altname", strlen("altname"), &find_handle);
 	while (objdb->object_find_next(find_handle, &alt_object) == 0) {
 		unsigned int port;
-		char *nodename;
+		char *node;
 		char *mcast;
 
-		if (objdb_get_string(objdb, alt_object, "name", &nodename)) {
+		if (objdb_get_string(objdb, alt_object, "name", &node)) {
 			continue;
 		}
 
@@ -630,7 +630,7 @@ static int get_nodename(struct objdb_iface_ver0 *objdb)
 			mcast = mcast_name;
 		}
 
-		if (add_ifaddr(objdb, mcast, nodename, portnum))
+		if (add_ifaddr(objdb, mcast, node, portnum))
 			return -1;
 
 		num_nodenames++;
@@ -856,10 +856,21 @@ static int set_noccs_defaults(struct objdb_iface_ver0 *objdb)
 	hdb_handle_t find_handle;
 
 	/* Enforce key */
-	key_filename = NOCCS_KEY_FILENAME;
+	key_filename = strdup(NOCCS_KEY_FILENAME);
+	if (!key_filename) {
+		sprintf(error_reason, "cannot allocate memory for key file name");
+		write_cman_pipe("cannot allocate memory for key file name");
+		return -1;
+	}
 
 	if (!cluster_name)
-		cluster_name = DEFAULT_CLUSTER_NAME;
+		cluster_name = strdup(DEFAULT_CLUSTER_NAME);
+
+	if (!cluster_name) {
+		sprintf(error_reason, "cannot allocate memory for cluster_name");
+		write_cman_pipe("cannot allocate memory for cluster_name");
+		return -1;
+	}
 
 	if (!cluster_id)
 		cluster_id = generate_cluster_id(cluster_name);
@@ -1010,7 +1021,7 @@ static int copy_config_tree(struct objdb_iface_ver0 *objdb, hdb_handle_t source_
  * Copy trees from /cluster where they live in cluster.conf, into the root
  * of the config tree where corosync expects to find them.
  */
-static int copy_tree_to_root(struct objdb_iface_ver0 *objdb, char *name, int always_create)
+static int copy_tree_to_root(struct objdb_iface_ver0 *objdb, const char *name, int always_create)
 {
 	hdb_handle_t find_handle;
 	hdb_handle_t object_handle;
@@ -1185,7 +1196,7 @@ static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, const char **error
 
 /* Write an error message down the CMAN startup pipe so
    that cman_tool can display it */
-int write_cman_pipe(char *message)
+int write_cman_pipe(const char *message)
 {
 	if (startup_pipe)
 		return write(startup_pipe, message, strlen(message)+1);
diff --git a/cman/daemon/cman.h b/cman/daemon/cman.h
index bba91aa..2ab40e1 100644
--- a/cman/daemon/cman.h
+++ b/cman/daemon/cman.h
@@ -1,6 +1,7 @@
 /* General cman bits */
-extern int write_cman_pipe(char *message);
+extern int write_cman_pipe(const char *message);
 extern void close_cman_pipe(void);
+extern int our_nodeid(void);
 
 /* How we announce ourself in syslog */
 #define CMAN_NAME "CMAN"
diff --git a/cman/daemon/cmanconfig.c b/cman/daemon/cmanconfig.c
index ed2dd90..e9519a3 100644
--- a/cman/daemon/cmanconfig.c
+++ b/cman/daemon/cmanconfig.c
@@ -46,7 +46,6 @@ int read_cman_nodes(struct corosync_api_v1 *corosync, unsigned int *config_versi
     int error;
     unsigned int expected = 0;
     unsigned int votes = 0;
-    int nodeid;
     hdb_handle_t object_handle;
     hdb_handle_t nodes_handle;
     hdb_handle_t find_handle;
@@ -182,18 +181,18 @@ static int get_cman_join_info(struct corosync_api_v1 *corosync)
 	   later */
 	nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
 	do {
-		int votes;
+		int nodevotes;
 
 		node_count++;
 
-		objdb_get_int(corosync, nodes_handle, "votes", (unsigned int *)&votes, 1);
-		if (votes < 0) {
+		objdb_get_int(corosync, nodes_handle, "votes", (unsigned int *)&nodevotes, 1);
+		if (nodevotes < 0) {
 			log_printf(LOG_ERR, "negative votes not allowed");
 			write_cman_pipe("Found negative votes for this node in CCS");
 			error = -EINVAL;
 			goto out;
 		}
-		vote_sum += votes;
+		vote_sum += nodevotes;
 		nodes_handle = nodeslist_next(corosync, find_handle);
 	} while (nodes_handle);
 	corosync->object_find_destroy(find_handle);
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
index 0fe66af..407e33b 100644
--- a/cman/daemon/commands.c
+++ b/cman/daemon/commands.c
@@ -93,7 +93,7 @@ static int send_port_enquire(int nodeid);
 static void process_internal_message(char *data, int nodeid, int byteswap);
 static void recalculate_quorum(int allow_decrease, int by_current_nodes);
 static void send_kill(int nodeid, uint16_t reason);
-static char *killmsg_reason(int reason);
+static const char *killmsg_reason(int reason);
 static void ccsd_timer_fn(void *arg);
 static int reread_config(int new_version);
 
@@ -978,7 +978,7 @@ static int do_cmd_leave_cluster(char *cmdbuf, int *retlen)
 	return 0;
 }
 
-static void check_shutdown_status()
+static void check_shutdown_status(void)
 {
 	int reply;
 	int leaveflags = CLUSTER_LEAVEFLAG_DOWN;
@@ -1634,7 +1634,7 @@ static void post_port_event(int reason, unsigned char port, int nodeid)
 		notify_listeners(con, reason, nodeid);
 }
 
-int our_nodeid()
+int our_nodeid(void)
 {
 	if (us)
 		return us->node_id;
@@ -1962,15 +1962,15 @@ static void do_process_transition(int nodeid, char *data)
 	if (node->fence_time && !msg->fence_time &&
 	    node->fence_agent && !msg->fence_agent[0])
 	{
-		char msg[sizeof(struct cl_fencemsg)+strlen(node->fence_agent)+1];
-		struct cl_fencemsg *fence_msg = (struct cl_fencemsg *)msg;
+		char fencemsg[sizeof(struct cl_fencemsg)+strlen(node->fence_agent)+1];
+		struct cl_fencemsg *fence_msg = (struct cl_fencemsg *)fencemsg;
 
 		fence_msg->cmd = CLUSTER_MSG_FENCESTATUS;
 		fence_msg->nodeid = nodeid;
 		fence_msg->timesec = node->fence_time;
 		fence_msg->fenced = 0;
 		strcpy(fence_msg->agent, node->fence_agent);
-		comms_send_message(msg, sizeof(msg), 0,0, nodeid, 0);
+		comms_send_message(fencemsg, sizeof(fencemsg), 0,0, nodeid, 0);
 	}
 }
 
@@ -2124,17 +2124,17 @@ void remove_unread_nodes()
 }
 
 /* Add a node from CCS, note that it may already exist if user has simply updated the config file */
-void add_ccs_node(char *nodename, int nodeid, int votes, int expected_votes)
+void add_ccs_node(char *node, int nodeid, int votes, int expected_votes)
 {
 	/* Update node entry */
-	add_new_node(nodename, nodeid, votes, expected_votes, NODESTATE_DEAD);
+	add_new_node(node, nodeid, votes, expected_votes, NODESTATE_DEAD);
 }
 
-void add_ais_node(int nodeid, uint64_t incarnation, int total_members)
+void add_ais_node(int nodeid, uint64_t incar, int total_members)
 {
 	struct cluster_node *node;
 
-	P_MEMB("add_ais_node ID=%d, incarnation = %" PRIu64 "\n",nodeid, incarnation);
+	P_MEMB("add_ais_node ID=%d, incarnation = %" PRIu64 "\n",nodeid, incar);
 
 	node = find_node_by_nodeid(nodeid);
 	if (!node && total_members == 1) {
@@ -2154,7 +2154,7 @@ void add_ais_node(int nodeid, uint64_t incarnation, int total_members)
 
 	if (node->state == NODESTATE_DEAD || node->state == NODESTATE_LEAVING) {
 		gettimeofday(&node->join_time, NULL);
-		node->incarnation = incarnation;
+		node->incarnation = incar;
 		node->state = NODESTATE_MEMBER;
 		cluster_members++;
 		recalculate_quorum(0, 0);
@@ -2261,7 +2261,7 @@ static struct cluster_node *find_node_by_name(char *name)
 	return NULL;
 }
 
-static char *killmsg_reason(int reason)
+static const char *killmsg_reason(int reason)
 {
 	static char msg[1024];
 
diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
index c67ea21..d74c454 100644
--- a/cman/daemon/daemon.c
+++ b/cman/daemon/daemon.c
@@ -255,7 +255,7 @@ static int process_client(hdb_handle_t handle, int fd, int revent, void *data)
 		}
 
 		if (msg->command == CMAN_CMD_DATA) {
-			char *buf = (char *)msg;
+			char *databuf = (char *)msg;
 			int ret;
 			uint8_t port;
 			struct sock_data_header *dmsg = (struct sock_data_header *)msg;
@@ -263,7 +263,7 @@ static int process_client(hdb_handle_t handle, int fd, int revent, void *data)
 			P_DAEMON("sending %lu bytes of data to node %d, port %d\n",
 				 (unsigned long)(msg->length - sizeof(struct sock_data_header)), dmsg->nodeid, dmsg->port);
 
-			buf += sizeof(struct sock_data_header);
+			databuf += sizeof(struct sock_data_header);
 
 			if (dmsg->port > 255) {
 				send_status_return(con, msg->command, -EINVAL);
@@ -275,7 +275,7 @@ static int process_client(hdb_handle_t handle, int fd, int revent, void *data)
 			else
 				port = con->port;
 
-			ret = comms_send_message(buf, msg->length - sizeof(struct sock_data_header),
+			ret = comms_send_message(databuf, msg->length - sizeof(struct sock_data_header),
 						 port, con->port,
 						 dmsg->nodeid,
 						 msg->flags);
@@ -477,12 +477,6 @@ void notify_confchg(struct sock_header *message)
 	}
 }
 
-void wake_daemon(void)
-{
-	P_DAEMON("Wake daemon called\n");
-}
-
-
 int num_listeners(void)
 {
 	int count = 0;
diff --git a/cman/daemon/nodelist.h b/cman/daemon/nodelist.h
index 6269f71..bbf2628 100644
--- a/cman/daemon/nodelist.h
+++ b/cman/daemon/nodelist.h
@@ -1,6 +1,6 @@
 /* These just make the access a little neater */
 static inline int objdb_get_string(OBJDB_API *corosync, hdb_handle_t object_service_handle,
-				   char *key, char **value)
+				   const char *key, char **value)
 {
 	int res;
 
@@ -17,7 +17,7 @@ static inline int objdb_get_string(OBJDB_API *corosync, hdb_handle_t object_serv
 }
 
 static inline void objdb_get_int(OBJDB_API *corosync, hdb_handle_t object_service_handle,
-				 char *key, unsigned int *intvalue, unsigned int default_value)
+				 const char *key, unsigned int *intvalue, unsigned int default_value)
 {
 	char *value = NULL;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]