diff --git a/src/mca/pml/teg/src/pml_ptl_array.h b/src/mca/pml/teg/src/pml_ptl_array.h index f03f192ee3..3f077ba6a2 100644 --- a/src/mca/pml/teg/src/pml_ptl_array.h +++ b/src/mca/pml/teg/src/pml_ptl_array.h @@ -68,13 +68,14 @@ static inline mca_ptl_proc_t* mca_ptl_array_get_index(mca_ptl_array_t* array, si static inline mca_ptl_proc_t* mca_ptl_array_get_next(mca_ptl_array_t* array) { + mca_ptl_proc_t* ptl_proc; #if LAM_ENABLE_DEBUG if(array->ptl_size == 0) { lam_output(0, "mca_ptl_array_get_next: invalid array size"); return 0; } #endif - mca_ptl_proc_t* ptl_proc = &array->ptl_procs[array->ptl_index++]; + ptl_proc = &array->ptl_procs[array->ptl_index++]; if(array->ptl_index == array->ptl_size) array->ptl_index = 0; return ptl_proc; diff --git a/src/mca/pml/teg/src/pml_teg_sendreq.c b/src/mca/pml/teg/src/pml_teg_sendreq.c index 91291ea948..4a545d0a13 100644 --- a/src/mca/pml/teg/src/pml_teg_sendreq.c +++ b/src/mca/pml/teg/src/pml_teg_sendreq.c @@ -37,6 +37,7 @@ void mca_pml_teg_send_request_schedule(mca_ptl_base_send_request_t* req) * size, then go ahead and give the rest of the message to this PTL. */ size_t bytes_to_frag; + int rc; if(num_ptl == num_ptl_avail || bytes_remaining < ptl->ptl_min_frag_size) bytes_to_frag = bytes_remaining; @@ -51,7 +52,7 @@ void mca_pml_teg_send_request_schedule(mca_ptl_base_send_request_t* req) bytes_to_frag = bytes_remaining; } - int rc = ptl->ptl_send(ptl, ptl_proc->ptl_peer, req, bytes_to_frag, 0); + rc = ptl->ptl_send(ptl, ptl_proc->ptl_peer, req, bytes_to_frag, 0); if(rc == LAM_SUCCESS) bytes_remaining = req->super.req_length - req->req_offset; } diff --git a/src/mca/ptl/tcp/src/ptl_tcp.c b/src/mca/ptl/tcp/src/ptl_tcp.c index a781aa406c..4a0bd845b3 100644 --- a/src/mca/ptl/tcp/src/ptl_tcp.c +++ b/src/mca/ptl/tcp/src/ptl_tcp.c @@ -139,9 +139,9 @@ void mca_ptl_tcp_recv_frag_return(struct mca_ptl_t* ptl, struct mca_ptl_tcp_recv void mca_ptl_tcp_send_frag_return(struct mca_ptl_t* ptl, struct mca_ptl_tcp_send_frag_t* frag) { if(lam_list_get_size(&mca_ptl_tcp_module.tcp_pending_acks)) { - THREAD_LOCK(&mca_ptl_tcp_module.tcp_lock); mca_ptl_tcp_recv_frag_t* pending = (mca_ptl_tcp_recv_frag_t*) lam_list_remove_first(&mca_ptl_tcp_module.tcp_pending_acks); + THREAD_LOCK(&mca_ptl_tcp_module.tcp_lock); if(NULL == pending) { THREAD_UNLOCK(&mca_ptl_tcp_module.tcp_lock); lam_free_list_return(&mca_ptl_tcp_module.tcp_send_frags, (lam_list_item_t*)frag); diff --git a/src/mca/ptl/tcp/src/ptl_tcp_module.c b/src/mca/ptl/tcp/src/ptl_tcp_module.c index 7ebb52a781..1deca40244 100644 --- a/src/mca/ptl/tcp/src/ptl_tcp_module.c +++ b/src/mca/ptl/tcp/src/ptl_tcp_module.c @@ -217,6 +217,8 @@ static int mca_ptl_tcp_module_create_instances(void) static int mca_ptl_tcp_module_create_listen(void) { int flags; + struct sockaddr_in inaddr; + lam_socklen_t addrlen = sizeof(struct sockaddr_in); /* create a listen socket for incoming connections */ mca_ptl_tcp_module.tcp_listen_sd = socket(AF_INET, SOCK_STREAM, 0); @@ -226,7 +228,6 @@ static int mca_ptl_tcp_module_create_listen(void) } /* bind to all addresses and dynamically assigned port */ - struct sockaddr_in inaddr; memset(&inaddr, 0, sizeof(inaddr)); inaddr.sin_family = AF_INET; inaddr.sin_addr.s_addr = INADDR_ANY; @@ -238,7 +239,6 @@ static int mca_ptl_tcp_module_create_listen(void) } /* resolve system assignend port */ - lam_socklen_t addrlen = sizeof(struct sockaddr_in); if(getsockname(mca_ptl_tcp_module.tcp_listen_sd, (struct sockaddr*)&inaddr, &addrlen) < 0) { lam_output(0, "mca_ptl_tcp_module_init: getsockname() failed with errno=%d", errno); return LAM_ERROR; @@ -281,7 +281,7 @@ static int mca_ptl_tcp_module_create_listen(void) static int mca_ptl_tcp_module_exchange(void) { - size_t i; + size_t i, rc; size_t size = mca_ptl_tcp_module.tcp_num_ptls * sizeof(mca_ptl_tcp_addr_t); mca_ptl_tcp_addr_t *addrs = malloc(size); for(i=0; ipeer_sd = socket(AF_INET, SOCK_STREAM, 0); if (ptl_peer->peer_sd < 0) { ptl_peer->peer_retries++; @@ -342,7 +344,6 @@ static int mca_ptl_tcp_peer_start_connect(mca_ptl_base_peer_t* ptl_peer) mca_ptl_tcp_peer_event_init(ptl_peer, ptl_peer->peer_sd); /* setup the socket as non-blocking */ - int flags; if((flags = fcntl(ptl_peer->peer_sd, F_GETFL, 0)) < 0) { lam_output(0, "mca_ptl_tcp_peer_connect: fcntl(F_GETFL) failed with errno=%d\n", errno); } else { @@ -352,7 +353,6 @@ static int mca_ptl_tcp_peer_start_connect(mca_ptl_base_peer_t* ptl_peer) } /* start the connect - will likely fail with EINPROGRESS */ - struct sockaddr_in peer_addr; peer_addr.sin_family = AF_INET; peer_addr.sin_addr = ptl_peer->peer_addr->addr_inet; peer_addr.sin_port = ptl_peer->peer_addr->addr_port; diff --git a/src/mca/ptl/tcp/src/ptl_tcp_sendfrag.c b/src/mca/ptl/tcp/src/ptl_tcp_sendfrag.c index e4338a5b0c..a00fcea80a 100644 --- a/src/mca/ptl/tcp/src/ptl_tcp_sendfrag.c +++ b/src/mca/ptl/tcp/src/ptl_tcp_sendfrag.c @@ -109,7 +109,7 @@ void mca_ptl_tcp_send_frag_init( bool mca_ptl_tcp_send_frag_handler(mca_ptl_tcp_send_frag_t* frag, int sd) { int cnt=-1; - size_t i; + size_t i, num_vecs; /* non-blocking write, but continue if interrupted */ while(cnt < 0) { @@ -131,7 +131,7 @@ bool mca_ptl_tcp_send_frag_handler(mca_ptl_tcp_send_frag_t* frag, int sd) } /* if the write didn't complete - update the iovec state */ - size_t num_vecs = frag->frag_vec_cnt; + num_vecs = frag->frag_vec_cnt; for(i=0; i= (int)frag->frag_vec_ptr->iov_len) { cnt -= frag->frag_vec_ptr->iov_len; diff --git a/src/mem/mem_pool.c b/src/mem/mem_pool.c index bc921d6057..36f755122b 100644 --- a/src/mem/mem_pool.c +++ b/src/mem/mem_pool.c @@ -389,6 +389,7 @@ void *lam_fmp_get_mem_segment(lam_fixed_mpool_t *pool, ssize_t len_to_alloc; char *ptr; lam_memseg_t *tmp_seg; + void *tmp_ptr; /* return if pool can't be used */ if ( !pool->fmp_pool_ok_to_use ) @@ -481,7 +482,7 @@ void *lam_fmp_get_mem_segment(lam_fixed_mpool_t *pool, len_to_alloc = 4 * (length + alignment); if (len_to_alloc < pool->fmp_min_alloc_size) len_to_alloc = 2 * pool->fmp_min_alloc_size; - void *tmp_ptr = + tmp_ptr = lam_zero_alloc(len_to_alloc, MMAP_SHARED_PROT, MMAP_SHARED_FLAGS); if ( !tmp_ptr ) { diff --git a/src/util/if.c b/src/util/if.c index 074bad85eb..cc9172b632 100644 --- a/src/util/if.c +++ b/src/util/if.c @@ -45,16 +45,16 @@ static lam_list_t lam_if_list; static int lam_ifinit(void) { - if (lam_list_get_size(&lam_if_list) > 0) - return LAM_SUCCESS; - char buff[1024]; char *ptr; struct ifconf ifconf; + int sd; ifconf.ifc_len = sizeof(buff); ifconf.ifc_buf = buff; - int sd; + if (lam_list_get_size(&lam_if_list) > 0) + return LAM_SUCCESS; + if((sd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { lam_output(0, "lam_ifinit: socket() failed with errno=%d\n", errno); return LAM_ERROR; @@ -201,11 +201,11 @@ int lam_ifnametoindex(const char* if_name) int lam_ifaddrtoname(const char* if_addr, char* if_name, int length) { lam_if_t* intf; + in_addr_t inaddr = inet_addr(if_addr); int rc = lam_ifinit(); if(rc != LAM_SUCCESS) return rc; - in_addr_t inaddr = inet_addr(if_addr); if(inaddr == INADDR_ANY) { struct hostent *h = gethostbyname(if_addr); if(h == 0) { @@ -245,9 +245,10 @@ int lam_ifcount() int lam_ifbegin() { + lam_if_t *intf; if(lam_ifinit() != LAM_SUCCESS) return (-1); - lam_if_t *intf = (lam_if_t*)lam_list_get_first(&lam_if_list); + intf = (lam_if_t*)lam_list_get_first(&lam_if_list); if(intf != 0) return intf->if_index; return (-1);