diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-10-21 13:08:44 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-10-21 13:08:44 (GMT) |
commit | ba665404620b16f0e5140c5f1d19b18ffb68590e (patch) | |
tree | 8759a98880bc6b7fc7cc1b1612f6548207837cef /src | |
parent | 9e2fff4540bbbc1718e1395f101973800f706eb9 (diff) | |
download | hdf5-ba665404620b16f0e5140c5f1d19b18ffb68590e.zip hdf5-ba665404620b16f0e5140c5f1d19b18ffb68590e.tar.gz hdf5-ba665404620b16f0e5140c5f1d19b18ffb68590e.tar.bz2 |
[svn-r19654] Description:
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 trunk)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5AC.c | 4 | ||||
-rw-r--r-- | src/H5C.c | 25 | ||||
-rw-r--r-- | src/H5Dcontig.c | 10 | ||||
-rw-r--r-- | src/H5Tbit.c | 34 |
4 files changed, 43 insertions, 30 deletions
@@ -2499,7 +2499,9 @@ H5AC_open_trace_file(H5AC_t * cache_ptr, #else /* H5_HAVE_PARALLEL */ - sprintf(file_name, "%s", trace_file_name); + HDsnprintf(file_name, + (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 1), + "%s", trace_file_name); #endif /* H5_HAVE_PARALLEL */ @@ -4392,15 +4392,26 @@ done: herr_t H5C_set_prefix(H5C_t * cache_ptr, char * prefix) { - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5C_set_prefix) + herr_t ret_value = SUCCEED; /* Return value */ - HDassert((cache_ptr) && (cache_ptr->magic == H5C__H5C_T_MAGIC)); - HDassert(prefix); - HDassert(HDstrlen(prefix) < H5C__PREFIX_LEN); + FUNC_ENTER_NOAPI(H5C_set_prefix, FAIL) - HDstrcpy(&(cache_ptr->prefix[0]), prefix); + if ( ( cache_ptr == NULL ) || + ( cache_ptr->magic != H5C__H5C_T_MAGIC ) || + ( prefix == NULL ) || + ( HDstrlen(prefix) >= H5C__PREFIX_LEN ) ) { + + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad param(s) on entry.") + } + + HDstrncpy(&(cache_ptr->prefix[0]), prefix, (size_t)(H5C__PREFIX_LEN)); + + cache_ptr->prefix[H5C__PREFIX_LEN - 1] = '\0'; + +done: + + FUNC_LEAVE_NOAPI(ret_value) - FUNC_LEAVE_NOAPI(SUCCEED) } /* H5C_set_prefix() */ @@ -9263,7 +9274,7 @@ H5C_mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) H5C_cache_entry_t *next_entry_ptr; /* entry pointer */ unsigned u; /* Local index variable */ - FUNC_ENTER_NOAPI_NOINIT(H5C_mark_tagged_entries) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5C_mark_tagged_entries) /* Assertions */ HDassert(0); /* This function is not yet used. We shouldn't be in here yet. */ diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 9b4f338..9a6e08f 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -1301,7 +1301,7 @@ H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, void *reclaim_buf = NULL; /* Buffer for reclaiming data */ H5S_t *buf_space = NULL; /* Dataspace describing buffer */ hid_t buf_sid = -1; /* ID for buffer dataspace */ - hsize_t buf_dim; /* Dimension for buffer */ + hsize_t buf_dim[1] = {0}; /* Dimension for buffer */ hbool_t is_vlen = FALSE; /* Flag to indicate that VL type conversion should occur */ hbool_t fix_ref = FALSE; /* Flag to indicate that ref values should be fixed */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1382,10 +1382,10 @@ H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, buf_size = nelmts * max_dt_size; /* Create dataspace for number of elements in buffer */ - buf_dim = nelmts; + buf_dim[0] = nelmts; /* Create the space and set the initial extent */ - if(NULL == (buf_space = H5S_create_simple((unsigned)1, &buf_dim, NULL))) + if(NULL == (buf_space = H5S_create_simple((unsigned)1, buf_dim, NULL))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Atomize */ @@ -1441,10 +1441,10 @@ H5D_contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, mem_nbytes = nelmts * mem_dt_size; /* Adjust size of buffer's dataspace dimension */ - buf_dim = nelmts; + buf_dim[0] = nelmts; /* Adjust size of buffer's dataspace */ - if(H5S_set_extent_real(buf_space, &buf_dim) < 0) + if(H5S_set_extent_real(buf_space, buf_dim) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "unable to change buffer dataspace size") } /* end if */ else 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() */ |