@@ -109,11 +109,11 @@ size_t mca_btl_tcp_frag_dump(mca_btl_tcp_frag_t* frag, char* msg, char* buf, siz
109109
110110bool mca_btl_tcp_frag_send (mca_btl_tcp_frag_t * frag , int sd )
111111{
112- int cnt = -1 ;
112+ ssize_t cnt = -1 ;
113113 size_t i , num_vecs ;
114114
115115 /* non-blocking write, but continue if interrupted */
116- while ( cnt < 0 ) {
116+ do {
117117 cnt = writev (sd , frag -> iov_ptr , frag -> iov_cnt );
118118 if (cnt < 0 ) {
119119 switch (opal_socket_errno ) {
@@ -137,12 +137,12 @@ bool mca_btl_tcp_frag_send(mca_btl_tcp_frag_t* frag, int sd)
137137 return false;
138138 }
139139 }
140- }
140+ } while ( cnt < 0 );
141141
142142 /* if the write didn't complete - update the iovec state */
143143 num_vecs = frag -> iov_cnt ;
144- for (i = 0 ; i < num_vecs ; i ++ ) {
145- if (cnt >= ( int ) frag -> iov_ptr -> iov_len ) {
144+ for ( i = 0 ; i < num_vecs ; i ++ ) {
145+ if (cnt >= frag -> iov_ptr -> iov_len ) {
146146 cnt -= frag -> iov_ptr -> iov_len ;
147147 frag -> iov_ptr ++ ;
148148 frag -> iov_idx ++ ;
@@ -159,15 +159,15 @@ bool mca_btl_tcp_frag_send(mca_btl_tcp_frag_t* frag, int sd)
159159
160160bool mca_btl_tcp_frag_recv (mca_btl_tcp_frag_t * frag , int sd )
161161{
162- int cnt , dont_copy_data = 0 ;
163- size_t i , num_vecs ;
164162 mca_btl_base_endpoint_t * btl_endpoint = frag -> endpoint ;
163+ ssize_t cnt ;
164+ int32_t i , num_vecs , dont_copy_data = 0 ;
165165
166166 repeat :
167167 num_vecs = frag -> iov_cnt ;
168168#if MCA_BTL_TCP_ENDPOINT_CACHE
169169 if ( 0 != btl_endpoint -> endpoint_cache_length ) {
170- size_t length ;
170+ ssize_t length ;
171171 /* It's strange at the first look but cnt have to be set to the full amount of data
172172 * available. After going to advance_iov_position we will use cnt to detect if there
173173 * is still some data pending.
@@ -203,20 +203,20 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
203203
204204 /* non-blocking read, but continue if interrupted */
205205 cnt = -1 ;
206- while ( cnt < 0 ) {
206+ do {
207207 cnt = readv (sd , frag -> iov_ptr , num_vecs );
208- if ( 0 < cnt ) goto advance_iov_position ;
209- if ( cnt == 0 ) {
208+ if ( 0 < cnt ) goto advance_iov_position ;
209+ if ( cnt == 0 ) {
210210 btl_endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
211- mca_btl_tcp_endpoint_close (btl_endpoint );
212- return false;
213- }
214- switch (opal_socket_errno ) {
215- case EINTR :
216- continue ;
217- case EWOULDBLOCK :
218- return false;
219- case EFAULT :
211+ mca_btl_tcp_endpoint_close (btl_endpoint );
212+ return false;
213+ }
214+ switch (opal_socket_errno ) {
215+ case EINTR :
216+ continue ;
217+ case EWOULDBLOCK :
218+ return false;
219+ case EFAULT :
220220 BTL_ERROR (("mca_btl_tcp_frag_recv: readv error (%p, %lu)\n\t%s(%lu)\n" ,
221221 frag -> iov_ptr [0 ].iov_base , (unsigned long ) frag -> iov_ptr [0 ].iov_len ,
222222 strerror (opal_socket_errno ), (unsigned long ) frag -> iov_cnt ));
@@ -231,23 +231,23 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
231231 mca_btl_tcp_endpoint_close (btl_endpoint );
232232 return false;
233233 }
234- }
234+ } while ( cnt < 0 );
235235
236236 advance_iov_position :
237237 /* if the read didn't complete - update the iovec state */
238238 num_vecs = frag -> iov_cnt ;
239239 for ( i = 0 ; i < num_vecs ; i ++ ) {
240- if ( cnt < ( int ) frag -> iov_ptr -> iov_len ) {
240+ if ( cnt < frag -> iov_ptr -> iov_len ) {
241241 frag -> iov_ptr -> iov_base = (opal_iov_base_ptr_t )
242242 (((unsigned char * )frag -> iov_ptr -> iov_base ) + cnt );
243243 frag -> iov_ptr -> iov_len -= cnt ;
244244 cnt = 0 ;
245245 break ;
246- }
247- cnt -= frag -> iov_ptr -> iov_len ;
248- frag -> iov_idx ++ ;
249- frag -> iov_ptr ++ ;
250- frag -> iov_cnt -- ;
246+ }
247+ cnt -= frag -> iov_ptr -> iov_len ;
248+ frag -> iov_idx ++ ;
249+ frag -> iov_ptr ++ ;
250+ frag -> iov_cnt -- ;
251251 }
252252#if MCA_BTL_TCP_ENDPOINT_CACHE
253253 btl_endpoint -> endpoint_cache_length = cnt ;
0 commit comments