diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-03-11 00:28:10 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2004-03-11 00:28:10 (GMT) |
commit | 7fe2ed7f9124758c95f698dc3cf8945b359264ee (patch) | |
tree | 38c6ff2c21fb76ff8092d17574239e78feb57cd8 /src/H5Zfletcher32.c | |
parent | 891308f73c0a420cfa0d1a14ebdca201e3e3350f (diff) | |
download | hdf5-7fe2ed7f9124758c95f698dc3cf8945b359264ee.zip hdf5-7fe2ed7f9124758c95f698dc3cf8945b359264ee.tar.gz hdf5-7fe2ed7f9124758c95f698dc3cf8945b359264ee.tar.bz2 |
[svn-r8253] Purpose:
bug fix
new test for the bug
Description:
the fletcher filter used a 2 byte word buffer to compute the checksum.
this is non portable between big-endian/little endian.
Solution:
replaced with a buffer of 1 byte type
added a test that reads 2 pre-saved files (one LE, other BE) with that filter enabled
Platforms tested:
linux
solaris
AIX
Misc. update:
Diffstat (limited to 'src/H5Zfletcher32.c')
-rw-r--r-- | src/H5Zfletcher32.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/src/H5Zfletcher32.c b/src/H5Zfletcher32.c index 1b11fae..48e7aea 100644 --- a/src/H5Zfletcher32.c +++ b/src/H5Zfletcher32.c @@ -60,36 +60,31 @@ const H5Z_class_t H5Z_FLETCHER32[1] = {{ * Programmer: Raymond Lu * Jan 3, 2003 * - * Modifications: + * Modifications: Pedro Vicente, March 10, 2004 + * defined *SRC as unsigned char for all cases * *------------------------------------------------------------------------- */ + static uint32_t H5Z_filter_fletcher32_compute(void *_src, size_t len) { -#if H5_SIZEOF_UINT16_T==2 - uint16_t *src=(uint16_t *)_src; -#else /* H5_SIZEOF_UINT16_T */ - /*To handle unusual platforms like Cray*/ unsigned char *src=(unsigned char *)_src; + /*To handle unusual platforms like Cray*/ unsigned short tmp_src; -#endif /* H5_SIZEOF_UINT16_T */ size_t count = len; /* Number of bytes left to checksum */ uint32_t s1 = 0, s2 = 0; /* Temporary partial checksums */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5Z_filter_fletcher32_compute); + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5Z_filter_fletcher32_compute) /* Compute checksum */ while(count > 1) { -#if H5_SIZEOF_UINT16_T==2 - /*For normal platforms*/ - s1 += *src++; -#else /* H5_SIZEOF_UINT16_T */ + /*To handle unusual platforms like Cray*/ tmp_src = (((unsigned short)src[0])<<8) | ((unsigned short)src[1]); src +=2; s1 += tmp_src; -#endif /* H5_SIZEOF_UINT16_T */ + if(s1 & 0xFFFF0000) { /*Wrap around carry if occurred*/ s1 &= 0xFFFF; s1++; @@ -115,9 +110,10 @@ H5Z_filter_fletcher32_compute(void *_src, size_t len) } } - FUNC_LEAVE_NOAPI((s2 << 16) + s1); + FUNC_LEAVE_NOAPI((s2 << 16) + s1) } + /*------------------------------------------------------------------------- * Function: H5Z_filter_fletcher32 |