From 0fc9d137d3c00ec749152132db222d4a07bdc30f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 30 Apr 2005 15:04:44 -0500 Subject: [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 --- src/H5Zshuffle.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/H5Zshuffle.c b/src/H5Zshuffle.c index 301aafd..d97676e 100644 --- a/src/H5Zshuffle.c +++ b/src/H5Zshuffle.c @@ -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 if(H5Pget_filter_by_id(dcpl_id,H5Z_FILTER_SHUFFLE,&flags,&cd_nelmts, cd_values,0,NULL)<0) #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 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") /* 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") 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 */ bytesoftype=cd_values[H5Z_SHUFFLE_PARM_SIZE]; - /* Don't do anything for 1-byte elements */ - if(bytesoftype>1) { - /* Compute the number of elements in buffer */ - 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 */ leftover = nbytes%bytesoftype; -- cgit v0.12