[Openais] [PATCH 3/3] Fix some "set but not used" warnings [-Wunused-but-set-variable]

Steven Dake sdake at redhat.com
Tue Mar 15 07:52:18 PDT 2011


Reviewed-by: Steven Dake <sdake at redhat.com>

On 03/14/2011 04:44 PM, Angus Salkeld wrote:
> Signed-off-by: Angus Salkeld <asalkeld at redhat.com>
> ---
>  exec/logsys.c          |    5 +----
>  exec/main.c            |    3 ---
>  exec/syncv2.c          |    9 +++------
>  exec/totemconfig.c     |    2 +-
>  exec/totempg.c         |    3 +--
>  exec/totemsrp.c        |   15 ---------------
>  exec/totemudp.c        |    6 +-----
>  exec/totemudpu.c       |    6 +-----
>  lib/coroipcc.c         |    4 +---
>  lib/sam.c              |    2 --
>  services/cfg.c         |    3 +--
>  services/evs.c         |    2 --
>  services/votequorum.c  |    2 --
>  tools/corosync-fplay.c |    5 -----
>  14 files changed, 10 insertions(+), 57 deletions(-)
> 
> diff --git a/exec/logsys.c b/exec/logsys.c
> index 30ab9ae..579af99 100644
> --- a/exec/logsys.c
> +++ b/exec/logsys.c
> @@ -378,10 +378,7 @@ static inline void records_reclaim (unsigned int idx, unsigned int words)
>  
>  		words_needed = words + 1;
>  		do {
> -			unsigned int old_tail;
> -
>  			words_needed -= flt_data[flt_tail];
> -			old_tail = flt_tail;
>  			flt_tail =
>  				(flt_tail +
>  				flt_data[flt_tail]) % (flt_data_size);
> @@ -1669,7 +1666,7 @@ void logsys_atexit (void)
>  			logsys_wthread_lock();
>  
>  			res = sem_getvalue (&logsys_print_finished, &value);
> -			if (value == 0) {
> +			if (res != 0 || value == 0) {
>  				logsys_wthread_unlock();
>  				return;
>  			}
> diff --git a/exec/main.c b/exec/main.c
> index 6193ec0..c720128 100644
> --- a/exec/main.c
> +++ b/exec/main.c
> @@ -864,16 +864,13 @@ static void deliver_fn (
>  	int service;
>  	int fn_id;
>  	unsigned int id;
> -	unsigned int size;
>  	unsigned int key_incr_dummy;
>  
>  	header = msg;
>  	if (endian_conversion_required) {
>  		id = swab32 (header->id);
> -		size = swab32 (header->size);
>  	} else {
>  		id = header->id;
> -		size = header->size;
>  	}
>  
>  	/*
> diff --git a/exec/syncv2.c b/exec/syncv2.c
> index e661fc7..7b47424 100644
> --- a/exec/syncv2.c
> +++ b/exec/syncv2.c
> @@ -402,7 +402,6 @@ static void memb_determine_message_transmit (void)
>  {
>  	struct iovec iovec;
>  	struct req_exec_memb_determine_message req_exec_memb_determine_message;
> -	int res;
>  
>  	req_exec_memb_determine_message.header.size = sizeof (struct req_exec_memb_determine_message);
>  	req_exec_memb_determine_message.header.id = MESSAGE_REQ_SYNC_MEMB_DETERMINE;
> @@ -414,7 +413,7 @@ static void memb_determine_message_transmit (void)
>  	iovec.iov_base = (char *)&req_exec_memb_determine_message;
>  	iovec.iov_len = sizeof (req_exec_memb_determine_message);
>  
> -	res = totempg_groups_mcast_joined (sync_group_handle,
> +	(void)totempg_groups_mcast_joined (sync_group_handle,
>  		&iovec, 1, TOTEMPG_AGREED);
>  }
>  
> @@ -422,7 +421,6 @@ static void barrier_message_transmit (void)
>  {
>  	struct iovec iovec;
>  	struct req_exec_barrier_message req_exec_barrier_message;
> -	int res;
>  
>  	req_exec_barrier_message.header.size = sizeof (struct req_exec_barrier_message);
>  	req_exec_barrier_message.header.id = MESSAGE_REQ_SYNC_BARRIER;
> @@ -433,14 +431,13 @@ static void barrier_message_transmit (void)
>  	iovec.iov_base = (char *)&req_exec_barrier_message;
>  	iovec.iov_len = sizeof (req_exec_barrier_message);
>  
> -	res = totempg_groups_mcast_joined (sync_group_handle,
> +	(void)totempg_groups_mcast_joined (sync_group_handle,
>  		&iovec, 1, TOTEMPG_AGREED);
>  }
>  
>  static void service_build_message_transmit (struct req_exec_service_build_message *service_build_message)
>  {
>  	struct iovec iovec;
> -	int res;
>  
>  	service_build_message->header.size = sizeof (struct req_exec_service_build_message);
>  	service_build_message->header.id = MESSAGE_REQ_SYNC_SERVICE_BUILD;
> @@ -451,7 +448,7 @@ static void service_build_message_transmit (struct req_exec_service_build_messag
>  	iovec.iov_base = (void *)service_build_message;
>  	iovec.iov_len = sizeof (struct req_exec_service_build_message);
>  
> -	res = totempg_groups_mcast_joined (sync_group_handle,
> +	(void)totempg_groups_mcast_joined (sync_group_handle,
>  		&iovec, 1, TOTEMPG_AGREED);
>  }
>  
> diff --git a/exec/totemconfig.c b/exec/totemconfig.c
> index 0b9732b..fa5ab9c 100644
> --- a/exec/totemconfig.c
> +++ b/exec/totemconfig.c
> @@ -759,7 +759,7 @@ static int read_keyfile (
>  	close (fd);
>  
>  	if (res == -1) {
> -		strerror_r (errno, error_str, 100);
> +		strerror_r (saved_errno, error_str, 100);
>  		snprintf (error_string_response, sizeof(error_string_response),
>  			"Could not read %s: %s\n",
>  			 key_location, error_str);
> diff --git a/exec/totempg.c b/exec/totempg.c
> index fb21695..c514453 100644
> --- a/exec/totempg.c
> +++ b/exec/totempg.c
> @@ -662,7 +662,6 @@ int callback_token_received_fn (enum totem_callback_token_type type,
>  {
>  	struct totempg_mcast mcast;
>  	struct iovec iovecs[3];
> -	int res;
>  
>  	pthread_mutex_lock (&mcast_msg_mutex);
>  	if (mcast_packed_msg_count == 0) {
> @@ -691,7 +690,7 @@ int callback_token_received_fn (enum totem_callback_token_type type,
>  	iovecs[1].iov_len = mcast_packed_msg_count * sizeof (unsigned short);
>  	iovecs[2].iov_base = (void *)&fragmentation_data[0];
>  	iovecs[2].iov_len = fragment_size;
> -	res = totemmrp_mcast (iovecs, 3, 0);
> +	(void)totemmrp_mcast (iovecs, 3, 0);
>  
>  	mcast_packed_msg_count = 0;
>  	fragment_size = 0;
> diff --git a/exec/totemsrp.c b/exec/totemsrp.c
> index 2aa3e43..e29456c 100644
> --- a/exec/totemsrp.c
> +++ b/exec/totemsrp.c
> @@ -2428,7 +2428,6 @@ static int orf_token_rtr (
>  	unsigned int res;
>  	unsigned int i, j;
>  	unsigned int found;
> -	unsigned int total_entries;
>  	struct sq *sort_queue;
>  	struct rtr_item *rtr_list;
>  	unsigned int range = 0;
> @@ -2456,8 +2455,6 @@ static int orf_token_rtr (
>  			"%s", retransmit_msg);
>  	}
>  
> -	total_entries = orf_token->rtr_list_entries;
> -
>  	/*
>  	 * Retransmit messages on orf_token's RTR list from RTR queue
>  	 */
> @@ -2805,13 +2802,8 @@ static int memb_state_commit_token_send_recovery (
>  	struct totemsrp_instance *instance,
>  	struct memb_commit_token *commit_token)
>  {
> -	struct srp_addr *addr;
> -	struct memb_commit_token_memb_entry *memb_list;
>  	unsigned int commit_token_size;
>  
> -	addr = (struct srp_addr *)commit_token->end_of_commit_token;
> -	memb_list = (struct memb_commit_token_memb_entry *)(addr + commit_token->addr_entries);
> -
>  	commit_token->token_seq++;
>  	commit_token_size = sizeof (struct memb_commit_token) +
>  		((sizeof (struct srp_addr) +
> @@ -2838,13 +2830,8 @@ static int memb_state_commit_token_send_recovery (
>  static int memb_state_commit_token_send (
>  	struct totemsrp_instance *instance)
>  {
> -	struct srp_addr *addr;
> -	struct memb_commit_token_memb_entry *memb_list;
>  	unsigned int commit_token_size;
>  
> -	addr = (struct srp_addr *)instance->commit_token->end_of_commit_token;
> -	memb_list = (struct memb_commit_token_memb_entry *)(addr + instance->commit_token->addr_entries);
> -
>  	instance->commit_token->token_seq++;
>  	commit_token_size = sizeof (struct memb_commit_token) +
>  		((sizeof (struct srp_addr) +
> @@ -4241,7 +4228,6 @@ static int message_handler_memb_commit_token (
>  	int sub_entries;
>  
>  	struct srp_addr *addr;
> -	struct memb_commit_token_memb_entry *memb_list;
>  
>  	log_printf (instance->totemsrp_log_level_debug,
>  		"got commit token\n");
> @@ -4253,7 +4239,6 @@ static int message_handler_memb_commit_token (
>  	}
>  	memb_commit_token = memb_commit_token_convert;
>  	addr = (struct srp_addr *)memb_commit_token->end_of_commit_token;
> -	memb_list = (struct memb_commit_token_memb_entry *)(addr + memb_commit_token->addr_entries);
>  
>  #ifdef TEST_DROP_COMMIT_TOKEN_PERCENTAGE
>  	if (random()%100 < TEST_DROP_COMMIT_TOKEN_PERCENTAGE) {
> diff --git a/exec/totemudp.c b/exec/totemudp.c
> index ec5be1a..b4f8a0c 100644
> --- a/exec/totemudp.c
> +++ b/exec/totemudp.c
> @@ -1171,7 +1171,6 @@ static int net_deliver_fn (
>  	struct totemudp_instance *instance = (struct totemudp_instance *)data;
>  	struct msghdr msg_recv;
>  	struct iovec *iovec;
> -	struct security_header *security_header;
>  	struct sockaddr_storage system_from;
>  	int bytes_received;
>  	int res = 0;
> @@ -1214,8 +1213,6 @@ static int net_deliver_fn (
>  		return (0);
>  	}
>  
> -	security_header = (struct security_header *)iovec->iov_base;
> -
>  	iovec->iov_len = bytes_received;
>  	if (instance->totem_config->secauth == 1) {
>  		/*
> @@ -1276,7 +1273,6 @@ static void timer_function_netif_check_timeout (
>  	void *data)
>  {
>  	struct totemudp_instance *instance = (struct totemudp_instance *)data;
> -	int res;
>  	int interface_up;
>  	int interface_num;
>  	struct totem_ip_address *bind_address;
> @@ -1350,7 +1346,7 @@ static void timer_function_netif_check_timeout (
>  	/*
>  	 * Create and bind the multicast and unicast sockets
>  	 */
> -	res = totemudp_build_sockets (instance,
> +	(void)totemudp_build_sockets (instance,
>  		&instance->mcast_address,
>  		bind_address,
>  		&instance->totemudp_sockets,
> diff --git a/exec/totemudpu.c b/exec/totemudpu.c
> index 2d6a3da..de8ee52 100644
> --- a/exec/totemudpu.c
> +++ b/exec/totemudpu.c
> @@ -1066,7 +1066,6 @@ static int net_deliver_fn (
>  	struct totemudpu_instance *instance = (struct totemudpu_instance *)data;
>  	struct msghdr msg_recv;
>  	struct iovec *iovec;
> -	struct security_header *security_header;
>  	struct sockaddr_storage system_from;
>  	int bytes_received;
>  	int res = 0;
> @@ -1105,8 +1104,6 @@ static int net_deliver_fn (
>  		return (0);
>  	}
>  
> -	security_header = (struct security_header *)iovec->iov_base;
> -
>  	iovec->iov_len = bytes_received;
>  	if (instance->totem_config->secauth == 1) {
>  		/*
> @@ -1167,7 +1164,6 @@ static void timer_function_netif_check_timeout (
>  	void *data)
>  {
>  	struct totemudpu_instance *instance = (struct totemudpu_instance *)data;
> -	int res;
>  	int interface_up;
>  	int interface_num;
>  	struct totem_ip_address *bind_address;
> @@ -1233,7 +1229,7 @@ static void timer_function_netif_check_timeout (
>  	/*
>  	 * Create and bind the multicast and unicast sockets
>  	 */
> -	res = totemudpu_build_sockets (instance,
> +	totemudpu_build_sockets (instance,
>  		bind_address,
>  		&instance->totem_interface->boundto);
>  
> diff --git a/lib/coroipcc.c b/lib/coroipcc.c
> index bbeb95f..1ace543 100644
> --- a/lib/coroipcc.c
> +++ b/lib/coroipcc.c
> @@ -372,9 +372,7 @@ error_close_unlink:
>  static void
>  memory_unmap (void *addr, size_t bytes)
>  {
> -	int res;
> -
> -	res = munmap (addr, bytes);
> +	(void)munmap (addr, bytes);
>  }
>  
>  void ipc_hdb_destructor (void *context ) {
> diff --git a/lib/sam.c b/lib/sam.c
> index 35bb7ee..6bf644e 100644
> --- a/lib/sam.c
> +++ b/lib/sam.c
> @@ -837,12 +837,10 @@ static cs_error_t sam_parent_warn_signal_set (
>  	int parent_fd_in,
>  	int parent_fd_out)
>  {
> -	char *user_data;
>  	int warn_signal;
>  	cs_error_t err;
>  
>  	err = CS_OK;
> -	user_data = NULL;
>  
>  	if (sam_safe_read (parent_fd_in, &warn_signal, sizeof (warn_signal)) != sizeof (warn_signal)) {
>  		err = CS_ERR_LIBRARY;
> diff --git a/services/cfg.c b/services/cfg.c
> index 109bea8..bd6e92f 100644
> --- a/services/cfg.c
> +++ b/services/cfg.c
> @@ -833,7 +833,6 @@ static void message_handler_req_lib_cfg_killnode (
>  	struct res_lib_cfg_killnode res_lib_cfg_killnode;
>  	struct req_exec_cfg_killnode req_exec_cfg_killnode;
>  	struct iovec iovec;
> -	int res;
>  
>  	ENTER();
>  	req_exec_cfg_killnode.header.size =
> @@ -846,7 +845,7 @@ static void message_handler_req_lib_cfg_killnode (
>  	iovec.iov_base = (char *)&req_exec_cfg_killnode;
>  	iovec.iov_len = sizeof (struct req_exec_cfg_killnode);
>  
> -	res = api->totem_mcast (&iovec, 1, TOTEM_SAFE);
> +	(void)api->totem_mcast (&iovec, 1, TOTEM_SAFE);
>  
>  	res_lib_cfg_killnode.header.size = sizeof(struct res_lib_cfg_killnode);
>  	res_lib_cfg_killnode.header.id = MESSAGE_RES_CFG_KILLNODE;
> diff --git a/services/evs.c b/services/evs.c
> index de88375..d76d784 100644
> --- a/services/evs.c
> +++ b/services/evs.c
> @@ -323,7 +323,6 @@ static void message_handler_req_evs_leave (void *conn, const void *msg)
>  	const struct req_lib_evs_leave *req_lib_evs_leave = msg;
>  	struct res_lib_evs_leave res_lib_evs_leave;
>  	cs_error_t error = CS_OK;
> -	int error_index;
>  	int i, j;
>  	int found;
>  	struct evs_pd *evs_pd = (struct evs_pd *)api->ipc_private_data_get (conn);
> @@ -351,7 +350,6 @@ static void message_handler_req_evs_leave (void *conn, const void *msg)
>  		}
>  		if (found == 0) {
>  			error = CS_ERR_NOT_EXIST;
> -			error_index = i;
>  			break;
>  		}
>  	}
> diff --git a/services/votequorum.c b/services/votequorum.c
> index 5b89359..543485d 100644
> --- a/services/votequorum.c
> +++ b/services/votequorum.c
> @@ -463,7 +463,6 @@ static void read_quorum_config(hdb_handle_t quorum_handle)
>  	unsigned int value = 0;
>  	int cluster_members = 0;
>  	struct list_head *tmp;
> -	struct cluster_node *node;
>  
>  	log_printf(LOGSYS_LEVEL_INFO, "Reading configuration\n");
>  
> @@ -487,7 +486,6 @@ static void read_quorum_config(hdb_handle_t quorum_handle)
>  	 * two_node mode is invalid if there are more than 2 nodes in the cluster!
>  	 */
>  	list_iterate(tmp, &cluster_members_list) {
> -		node = list_entry(tmp, struct cluster_node, list);
>  		cluster_members++;
>          }
>  
> diff --git a/tools/corosync-fplay.c b/tools/corosync-fplay.c
> index 96bb4f0..c74c201 100644
> --- a/tools/corosync-fplay.c
> +++ b/tools/corosync-fplay.c
> @@ -378,7 +378,6 @@ static void logsys_rec_print (const void *record)
>  	const uint32_t *buf_uint32t = record;
>  	uint32_t rec_size;
>  	uint32_t rec_ident;
> -	uint32_t level;
>  	uint32_t line;
>  	uint32_t arg_size_idx;
>  	unsigned int i;
> @@ -386,7 +385,6 @@ static void logsys_rec_print (const void *record)
>  	unsigned int rec_idx = 0;
>  	uint32_t record_number;
>  	unsigned int words_processed;
> -	unsigned int found;
>  	const char *arguments[64];
>  	int arg_count = 0;
>  
> @@ -395,8 +393,6 @@ static void logsys_rec_print (const void *record)
>  	line = buf_uint32t[rec_idx+2];
>  	record_number = buf_uint32t[rec_idx+3];
>  
> -	level = LOGSYS_DECODE_LEVEL(rec_ident);
> -
>  	printf ("rec=[%d] ", record_number);
>  	arg_size_idx = rec_idx + 4;
>  	words_processed = 4;
> @@ -408,7 +404,6 @@ static void logsys_rec_print (const void *record)
>  
>  	}
>  
> -	found = 0;
>  	for (i = 0; i < printer_subsys_count; i++) {
>  		if (strcmp (arguments[0], printer_subsystems[i].subsys) == 0) {
>  			for (j = 0; j < printer_subsystems[i].record_printers_count; j++) {



More information about the Openais mailing list