[svn-r10703] Purpose:

Bug fix

Description:
    Correct bug where buffers that have only fractional elements (usually from
being compressed before being shuffled) would cause optimized algorithm to
dump core.

Solution:
    Don't attempt to shuffle bytes unless we've got more than one element.

Platforms tested:
    FreeBSD 4.11 (sleipnir)
    Too minor to require h5committest
This commit is contained in:
Quincey Koziol 2005-04-30 15:04:44 -05:00
parent 78e4e6f008
commit 0fc9d137d3

View File

@ -78,7 +78,7 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
#ifdef H5_WANT_H5_V1_6_COMPAT #ifdef H5_WANT_H5_V1_6_COMPAT
if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0) if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0)
#else #else
if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL,NULL)<0) if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,(size_t)0,NULL,NULL)<0)
#endif #endif
HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters") HGOTO_ERROR(H5E_PLINE, H5E_CANTGET, FAIL, "can't get shuffle parameters")
@ -87,7 +87,7 @@ H5Z_set_local_shuffle(hid_t dcpl_id, hid_t type_id, hid_t UNUSED space_id)
HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size")
/* Modify the filter's parameters for this dataset */ /* Modify the filter's parameters for this dataset */
if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SHUFFLE, flags, H5Z_SHUFFLE_TOTAL_NPARMS, cd_values)<0) if(H5Pmodify_filter(dcpl_id, H5Z_FILTER_SHUFFLE, flags, (size_t)H5Z_SHUFFLE_TOTAL_NPARMS, cd_values)<0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters") HGOTO_ERROR(H5E_PLINE, H5E_CANTSET, FAIL, "can't set local shuffle parameters")
done: done:
@ -142,11 +142,11 @@ H5Z_filter_shuffle(unsigned flags, size_t cd_nelmts, const unsigned cd_values[],
/* Get the number of bytes per element from the parameter block */ /* Get the number of bytes per element from the parameter block */
bytesoftype=cd_values[H5Z_SHUFFLE_PARM_SIZE]; bytesoftype=cd_values[H5Z_SHUFFLE_PARM_SIZE];
/* Don't do anything for 1-byte elements */ /* Compute the number of elements in buffer */
if(bytesoftype>1) { numofelements=nbytes/bytesoftype;
/* Compute the number of elements in buffer */
numofelements=nbytes/bytesoftype;
/* Don't do anything for 1-byte elements, or "fractional" elements */
if(bytesoftype > 1 && numofelements > 1) {
/* Compute the leftover bytes if there are any */ /* Compute the leftover bytes if there are any */
leftover = nbytes%bytesoftype; leftover = nbytes%bytesoftype;