diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-10-21 14:08:13 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-10-21 14:08:13 (GMT) |
commit | d1117ac78c622908b4749218a991388d64f01f31 (patch) | |
tree | 35162f14a1505ff84ce9c088d270019991869896 /src/H5Tbit.c | |
parent | afd35119824638eeefc90c07286e49a45746e186 (diff) | |
download | hdf5-d1117ac78c622908b4749218a991388d64f01f31.zip hdf5-d1117ac78c622908b4749218a991388d64f01f31.tar.gz hdf5-d1117ac78c622908b4749218a991388d64f01f31.tar.bz2 |
[svn-r19655] Description:
Bring r19654 from trunk to 1.8 branch:
Bring Coverity revisions from branch back to trunk, and clean up some other
misc. compiler warnings also.
r19500:
Fix coverity items 1446 and 1447. Moved up calls to memset in test_cont in
ohdr.c so the test never tries to close uninitialized locations.
r19501:
Fix coverity items 1398-1445. Various uninitialized variable errors in fheap.c.
r19502:
Fixed coverity issue 579 and some additional warnings in the file as well.
r19503:
Bug fix: This fix addressed the "RESOURCE_LEAK" problems #789 and 790, run 26
r19504:
minor mods to try to keep coverity from flagging false positives.
r19505:
Fixed coverity issues 566 - 571. Declared variables that are passed to functions that use them as arrays to be arrays of size 1.
Tested on:
Mac OS X/32 10.6.4 (amazon) w/debug, production & parallel
(h5committested on coverity branch)
Diffstat (limited to 'src/H5Tbit.c')
-rw-r--r-- | src/H5Tbit.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 2c289b0..a52d538 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -279,6 +279,7 @@ H5T_bit_get_d(uint8_t *buf, size_t offset, size_t size) case H5T_ORDER_ERROR: case H5T_ORDER_VAX: case H5T_ORDER_NONE: + case H5T_ORDER_MIXED: default: /* Unknown endianness. Bail out. */ HGOTO_DONE(UFAIL) @@ -326,6 +327,7 @@ H5T_bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) case H5T_ORDER_ERROR: case H5T_ORDER_VAX: case H5T_ORDER_NONE: + case H5T_ORDER_MIXED: default: HDabort(); } /* end switch */ @@ -534,7 +536,7 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size) else mask = ((unsigned)1 << (8 - start)) - 1; acc = ((unsigned)buf[idx] >> start) & mask; - acc += 1; + acc++; carry = acc & ((unsigned)1 << MIN(size, 8 - start)); buf[idx] &= (uint8_t)(~(mask << start)); buf[idx] |= (uint8_t)((acc & mask) << start); @@ -546,7 +548,7 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size) /* The middle */ while(carry && size >= 8) { acc = buf[idx]; - acc += 1; + acc++; carry = acc & 0x100; buf[idx] = acc & 0xff; idx++; @@ -557,7 +559,7 @@ H5T_bit_inc(uint8_t *buf, size_t start, size_t size) if(carry && size > 0) { mask = ((unsigned)1 << size) - 1; acc = buf[idx] & mask; - acc += 1; + acc++; carry = acc & ((unsigned)1 << size); buf[idx] &= (uint8_t)(~mask); buf[idx] |= (uint8_t)(acc & mask); @@ -606,7 +608,7 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size) */ if(!(buf[idx] >> pos)) borrow = 1; - buf[idx] -= 1 << pos; + buf[idx] = (uint8_t)(buf[idx] - (1 << pos)); idx++; size -= (8 - pos); @@ -614,7 +616,7 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size) while(borrow && size >= 8) { if(buf[idx]) borrow = 0; - buf[idx] -= 1; + buf[idx]--; idx++; size -= 8; @@ -624,9 +626,9 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size) if(borrow && size > 0) { /* Similar to the first byte case, where sequence ends in the same byte as starts */ tmp = buf[idx]; - buf[idx] -= 1; + buf[idx]--; if((buf[idx] >> size) != tmp >> size) - buf[idx] += 1 << size; + buf[idx] = (uint8_t)(buf[idx] + (1 << size)); } /* end if */ } /* end if */ else { /* bit sequence ends in the same byte as starts */ @@ -635,9 +637,9 @@ H5T_bit_dec(uint8_t *buf, size_t start, size_t size) * not equal). We need to put this bit back by increment 1000000. */ tmp = buf[idx]; - buf[idx] -= 1 << pos; + buf[idx] = (uint8_t)(buf[idx] - (1 << pos)); if((buf[idx] >> (pos + size)) != tmp >> (pos + size)) { - buf[idx] += 1 << (pos + size); + buf[idx] = (uint8_t)(buf[idx] + (1 << (pos + size))); borrow = 1; } /* end if */ } /* end else */ @@ -664,7 +666,7 @@ H5T_bit_neg(uint8_t *buf, size_t start, size_t size) { size_t idx = start / 8; size_t pos = start % 8; - uint8_t tmp; + uint8_t tmp[1]; /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5T_bit_neg); @@ -673,12 +675,11 @@ H5T_bit_neg(uint8_t *buf, size_t start, size_t size) HDassert(size); /* The first partial byte */ - tmp = buf[idx]; - tmp = (uint8_t)~tmp; + tmp[0] = (uint8_t)~buf[idx]; /* Simply copy the negated bit field back to the original byte */ if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ - H5T_bit_copy(&(buf[idx]), pos, &tmp, pos, (8-pos)); + H5T_bit_copy(&(buf[idx]), pos, tmp, pos, (8-pos)); idx++; size -= (8 - pos); @@ -692,13 +693,12 @@ H5T_bit_neg(uint8_t *buf, size_t start, size_t size) /* The last partial byte */ if(size > 0) { /* Similar to the first byte case, where sequence ends in the same byte as starts */ - tmp = buf[idx]; - tmp = (uint8_t)~tmp; - H5T_bit_copy(&(buf[idx]), (size_t)0, &tmp, (size_t)0, size); + tmp[0] = (uint8_t)~buf[idx]; + H5T_bit_copy(&(buf[idx]), (size_t)0, tmp, (size_t)0, size); } /* end if */ } /* end if */ else /* bit sequence ends in the same byte as starts */ - H5T_bit_copy(&(buf[idx]), pos, &tmp, pos, size); + H5T_bit_copy(&(buf[idx]), pos, tmp, pos, size); FUNC_LEAVE_NOAPI_VOID } /* end H5T_bit_neg() */ |