1
1

Alway call the memory allocation function with the correct type for the first argument. The problem is

that on some OSes the iovec struct is not POSIX complian, the iov_len is not a size_t but simply an int.
This patch, add a local variable (type size_t) to use with the memory allocation function, and then put
back the value in the iov_len field.

This commit was SVN r7615.
Этот коммит содержится в:
George Bosilca 2005-10-04 14:44:59 +00:00
родитель 059c802094
Коммит 9a67831ba3
4 изменённых файлов: 20 добавлений и 17 удалений

Просмотреть файл

@ -78,14 +78,13 @@ int ompi_convertor_pack_general( ompi_convertor_t* pConvertor,
for( iov_count = 0; iov_count < (*out_size); iov_count++ ) {
bConverted = 0;
if( iov[iov_count].iov_base == NULL ) {
uint32_t length = iov[iov_count].iov_len;
size_t length = iov[iov_count].iov_len;
if( length <= 0 )
length = pConvertor->count * pData->size - pConvertor->bConverted - bConverted;
if( (*max_data) < length )
length = *max_data;
iov[iov_count].iov_base = pConvertor->memAlloc_fn( &length, pConvertor->memAlloc_userdata );
iov[iov_count].iov_len = length;
iov[iov_count].iov_base = pConvertor->memAlloc_fn( &(iov[iov_count].iov_len),
pConvertor->memAlloc_userdata );
*freeAfter = (*freeAfter) | ( 1 << iov_count);
}
pInput = iov[iov_count].iov_base;
@ -415,8 +414,9 @@ int ompi_convertor_pack_no_conversion( ompi_convertor_t* pConv,
/* point to the end of loop element */
ddt_endloop_desc_t* end_loop = &(pElems[pos_desc + pElems[pos_desc].loop.items].end_loop);
if( iov[iov_pos].iov_base == NULL ) {
iov[iov_pos].iov_base = pConv->memAlloc_fn( &(iov[iov_pos].iov_len),
pConv->memAlloc_userdata );
size_t length = iov[iov_pos].iov_len;
iov[iov_pos].iov_base = pConv->memAlloc_fn( &length, pConv->memAlloc_userdata );
iov[iov_pos].iov_len = length;
space_on_iovec = iov[iov_pos].iov_len;
destination = iov[iov_pos].iov_base;
(*freeAfter) |= (1 << iov_pos);
@ -482,6 +482,8 @@ int ompi_convertor_pack_no_conversion( ompi_convertor_t* pConv,
*/
do {
if( iov[iov_pos].iov_base == NULL ) {
size_t length;
if( saveLength > IOVEC_MEM_LIMIT ) {
/* If the user didn't provide any memory, then we are free
* to handle this case as we want.
@ -499,9 +501,10 @@ int ompi_convertor_pack_no_conversion( ompi_convertor_t* pConv,
space_on_iovec = iov[iov_pos].iov_len;
break;
}
length = iov[iov_pos].iov_len;
/* Let's allocate some. */
iov[iov_pos].iov_base = pConv->memAlloc_fn( &(iov[iov_pos].iov_len),
pConv->memAlloc_userdata );
iov[iov_pos].iov_base = pConv->memAlloc_fn( &length, pConv->memAlloc_userdata );
iov[iov_pos].iov_len = length;
(*freeAfter) |= (1 << iov_pos);
destination = iov[iov_pos].iov_base;
space_on_iovec = iov[iov_pos].iov_len;
@ -600,7 +603,7 @@ ompi_convertor_pack_no_conv_contig( ompi_convertor_t* pConv,
pSrc = pConv->pBaseBuf + pStack[0].disp + pStack[1].disp;
for( iov_count = 0; iov_count < (*out_size); iov_count++ ) {
if( 0 == length ) break;
if( iov[iov_count].iov_len > length )
if( (size_t)iov[iov_count].iov_len > length )
iov[iov_count].iov_len = length;
if( iov[iov_count].iov_base == NULL ) {
iov[iov_count].iov_base = pSrc;
@ -707,10 +710,11 @@ ompi_convertor_pack_no_conv_contig_with_gaps( ompi_convertor_t* pConv,
uint32_t done, counter;
if( iov[iov_count].iov_base == NULL ) {
iov[iov_count].iov_base = pConv->memAlloc_fn( &(iov[iov_count].iov_len),
pConv->memAlloc_userdata );
size_t length = iov[iov_count].iov_len;
iov[iov_count].iov_base = pConv->memAlloc_fn( &length, pConv->memAlloc_userdata );
iov[iov_count].iov_len = length;
(*freeAfter) |= (1 << 0);
if( max_allowed < iov[iov_count].iov_len )
if( max_allowed < (size_t)iov[iov_count].iov_len )
iov[iov_count].iov_len = max_allowed;
else
max_allowed = iov[iov_count].iov_len;

Просмотреть файл

@ -73,7 +73,7 @@ int32_t ompi_ddt_sndrcv( void *sbuf, int32_t scount, const ompi_datatype_t* sdty
iov_count = 1;
iov.iov_len = rcount;
iov.iov_base = rbuf;
max_data = ( iov.iov_len > (scount * sdtype->size) ? (scount * sdtype->size) : iov.iov_len );
max_data = ( (size_t)iov.iov_len > (scount * sdtype->size) ? (scount * sdtype->size) : iov.iov_len );
err = ompi_convertor_pack( send_convertor, &iov, &iov_count, &max_data, &freeAfter );
OBJ_RELEASE( send_convertor );
@ -89,7 +89,7 @@ int32_t ompi_ddt_sndrcv( void *sbuf, int32_t scount, const ompi_datatype_t* sdty
iov_count = 1;
iov.iov_len = scount;
iov.iov_base = sbuf;
max_data = ( iov.iov_len < (rcount * rdtype->size) ? iov.iov_len : (rcount * rdtype->size) );
max_data = ( (size_t)iov.iov_len < (rcount * rdtype->size) ? iov.iov_len : (rcount * rdtype->size) );
err = ompi_convertor_unpack( recv_convertor, &iov, &iov_count, &max_data, &freeAfter );
if( scount > (int32_t)(rcount * rdtype->size) )

Просмотреть файл

@ -333,7 +333,7 @@ static int ompi_convertor_unpack_homogeneous_contig( ompi_convertor_t* pConv,
for( iov_count = 0; iov_count < (*out_size); iov_count++ ) {
pSrcBuf = (char*)iov[iov_count].iov_base;
remaining = pConv->count * pData->size - pConv->bConverted;
if( remaining > iov[iov_count].iov_len )
if( remaining > (uint32_t)iov[iov_count].iov_len )
remaining = iov[iov_count].iov_len;
bConverted = remaining; /* how much will get unpacked this time */

Просмотреть файл

@ -174,14 +174,13 @@ int ompi_convertor_generic_simple_pack( ompi_convertor_t* pConvertor,
/*
* ALLOCATE SOME MEMORY ...
*/
uint32_t length = iov[iov_count].iov_len;
size_t length = iov[iov_count].iov_len;
if( length <= 0 )
length = pConvertor->count * pData->size - pConvertor->bConverted;
if( ((*max_data) - total_packed) < length )
length = (*max_data) - total_packed;
iov[iov_count].iov_base = pConvertor->memAlloc_fn( &length, pConvertor->memAlloc_userdata );
iov[iov_count].iov_len = length;
iov[iov_count].iov_base = pConvertor->memAlloc_fn( &(iov[iov_count].iov_len),
pConvertor->memAlloc_userdata );
*freeAfter = (*freeAfter) | (1 << iov_count);
}
destination = iov[iov_count].iov_base;