55 * reserved.
66 * Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
77 * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
8- * Copyright (c) 2017 Research Organization for Information Science
9- * and Technology (RIST). All rights reserved.
8+ * Copyright (c) 2017-2019 Research Organization for Information Science
9+ * and Technology (RIST). All rights reserved.
1010 * $COPYRIGHT$
1111 *
1212 * Additional copyrights may follow
@@ -102,7 +102,7 @@ opal_convertor_raw( opal_convertor_t* pConvertor,
102102 /* now here we have a basic datatype */
103103 OPAL_DATATYPE_SAFEGUARD_POINTER ( source_base , blength , pConvertor -> pBaseBuf ,
104104 pConvertor -> pDesc , pConvertor -> count );
105- DO_DEBUG ( opal_output ( 0 , "raw 1. iov[%d] = {base %p, length %lu }\n" ,
105+ DO_DEBUG ( opal_output ( 0 , "raw 1. iov[%d] = {base %p, length %" PRIsize_t " }\n" ,
106106 index , (void * )source_base , (unsigned long )blength ); );
107107 iov [index ].iov_base = (IOVBASE_TYPE * ) source_base ;
108108 iov [index ].iov_len = blength ;
@@ -115,7 +115,7 @@ opal_convertor_raw( opal_convertor_t* pConvertor,
115115 for ( i = count_desc ; (i > 0 ) && (index < * iov_count ); i -- , index ++ ) {
116116 OPAL_DATATYPE_SAFEGUARD_POINTER ( source_base , blength , pConvertor -> pBaseBuf ,
117117 pConvertor -> pDesc , pConvertor -> count );
118- DO_DEBUG ( opal_output ( 0 , "raw 2. iov[%d] = {base %p, length %lu }\n" ,
118+ DO_DEBUG ( opal_output ( 0 , "raw 2. iov[%d] = {base %p, length %" PRIsize_t " }\n" ,
119119 index , (void * )source_base , (unsigned long )blength ); );
120120 iov [index ].iov_base = (IOVBASE_TYPE * ) source_base ;
121121 iov [index ].iov_len = blength ;
@@ -170,23 +170,30 @@ opal_convertor_raw( opal_convertor_t* pConvertor,
170170 ddt_endloop_desc_t * end_loop = (ddt_endloop_desc_t * )(pElem + pElem -> loop .items );
171171
172172 if ( pElem -> loop .common .flags & OPAL_DATATYPE_FLAG_CONTIGUOUS ) {
173- uint32_t i ;
174- source_base += end_loop -> first_elem_disp ;
175- for ( i = count_desc ; ( i > 0 ) && ( index < * iov_count ) ; i -- , index ++ ) {
173+ ptrdiff_t offset = end_loop -> first_elem_disp ;
174+ source_base += offset ;
175+ for (size_t i = MIN ( count_desc , * iov_count - index ); i > 0 ; i -- , index ++ ) {
176176 OPAL_DATATYPE_SAFEGUARD_POINTER ( source_base , end_loop -> size , pConvertor -> pBaseBuf ,
177177 pConvertor -> pDesc , pConvertor -> count );
178178 iov [index ].iov_base = (IOVBASE_TYPE * ) source_base ;
179179 iov [index ].iov_len = end_loop -> size ;
180180 source_base += pElem -> loop .extent ;
181181 raw_data += end_loop -> size ;
182182 count_desc -- ;
183+ DO_DEBUG ( opal_output ( 0 , "raw contig loop generate iov[%d] = {base %p, length %" PRIsize_t "}"
184+ "space %lu [pos_desc %d]\n" ,
185+ index , iov [index ].iov_base , iov [index ].iov_len ,
186+ (unsigned long )raw_data , pos_desc ); );
183187 }
184- source_base -= end_loop -> first_elem_disp ;
188+ source_base -= offset ;
185189 if ( 0 == count_desc ) { /* completed */
186190 pos_desc += pElem -> loop .items + 1 ;
187191 goto update_loop_description ;
188192 }
189193 }
194+ if ( index == * iov_count ) { /* all iov have been filled, we need to bail out */
195+ goto complete_loop ;
196+ }
190197 local_disp = (ptrdiff_t )source_base - local_disp ;
191198 PUSH_STACK ( pStack , pConvertor -> stack_pos , pos_desc , OPAL_DATATYPE_LOOP , count_desc ,
192199 pStack -> disp + local_disp );
0 commit comments