summaryrefslogtreecommitdiffstats
path: root/src/H5Ztrans.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-30 18:06:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-30 18:06:32 (GMT)
commiteff803f8249485e8b1fdb5c71197314f0527c995 (patch)
tree46163e26a5b0be38e839f8f195b1821ba25f86d6 /src/H5Ztrans.c
parent7fe87a24722f991ffc030782cd42d24df00dbace (diff)
downloadhdf5-eff803f8249485e8b1fdb5c71197314f0527c995.zip
hdf5-eff803f8249485e8b1fdb5c71197314f0527c995.tar.gz
hdf5-eff803f8249485e8b1fdb5c71197314f0527c995.tar.bz2
[svn-r19156] Description:
Bring revisions from Coverity branch back to trunk: r19044: Coverity #449 - Line 1560 called function H5O_chunk_protect for 2 pointers to allocate. But when there's failure on the second one, the first wasn't freed (H5O_chunk_unprotect). We fixed it by freeing the pointers when an error happens. r19045: Fixed coverity issue # 319. Free sec_node in done if it is not NULL. r19046: Add intended but missing assignments to initialize pointers to NULL (coverity issue fixes). r19049: Hdf5_1_8_coverity branch was recreated from hdf5_1_8 branch in revision 18839 without fix for Coverity issue #84 having been propagated to the hdf5_1_8 branch. This revision adds the fix again. r19060: added parentheses to see if they will keep subversion from getting confused r19061: Fix coverity item 139. Fixed incorrect condition for freeing buffer on error. Fix coverity items 20 and 21. Removed unused NTESTS facility from dtypes.c. Cleanup in H5Shyper.c. r19062: Fix coverity item 450. Check to see if chk_proxy has been allocated before attempting to free it. Fix coverity item 454. Check to see if allocation of buf failed in H5D_fill_refill_vl. Fix coverity items 455-457. Initilize hid_t's to -1, check their value before attempting to close them, and check if the close failed. r19063: New fix to address coverity issue #84. Check that pointers in H5Z_xform_find_type are not NULL before passing them to H5T_cmp. Tested on: Mac OS X/32 10.6.4 (amazon) w/debug & production (Too minor to require h5committest)
Diffstat (limited to 'src/H5Ztrans.c')
-rw-r--r--src/H5Ztrans.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c
index 762b316..8028123 100644
--- a/src/H5Ztrans.c
+++ b/src/H5Ztrans.c
@@ -555,7 +555,7 @@ static H5Z_node *
H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
{
H5Z_node *expr;
- void* ret_value;
+ H5Z_node *ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5Z_parse_expression)
@@ -566,7 +566,7 @@ H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
current = H5Z_get_token(current);
- switch (current->tok_type) {
+ switch(current->tok_type) {
case H5Z_XFORM_PLUS:
new_node = H5Z_new_node(H5Z_XFORM_PLUS);
@@ -612,6 +612,13 @@ H5Z_parse_expression(H5Z_token *current, H5Z_datval_ptrs* dat_val_pointers)
case H5Z_XFORM_END:
HGOTO_DONE(expr)
+ case H5Z_XFORM_ERROR:
+ case H5Z_XFORM_INTEGER:
+ case H5Z_XFORM_FLOAT:
+ case H5Z_XFORM_SYMBOL:
+ case H5Z_XFORM_MULT:
+ case H5Z_XFORM_DIVIDE:
+ case H5Z_XFORM_LPAREN:
default:
H5Z_xform_destroy_parse_tree(expr);
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "Error parsing data transform expression")
@@ -1101,54 +1108,69 @@ done:
static hid_t
H5Z_xform_find_type(const H5T_t* type)
{
- hid_t ret_value = SUCCEED;
+ H5T_t *tmp; /* Temporary datatype */
+ hid_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5Z_xform_find_type)
HDassert(type);
/* Check for SHORT type */
- if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_SHORT, H5I_DATATYPE), FALSE)) == 0)
+ if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_SHORT, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_SHORT)
/* Check for INT type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_INT, H5I_DATATYPE), FALSE)) == 0)
- HGOTO_DONE(H5T_NATIVE_INT)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_INT, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
+ HGOTO_DONE(H5T_NATIVE_INT)
/* Check for LONG type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_LONG, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_LONG, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_LONG)
/* Check for LONGLONG type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_LLONG, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_LLONG, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_LLONG)
/* Check for UCHAR type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_UCHAR, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_UCHAR, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_UCHAR)
/* Check for CHAR type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_CHAR, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_CHAR, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_CHAR)
/* Check for SCHAR type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_SCHAR, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_SCHAR, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_SCHAR)
/* Check for USHORT type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_USHORT, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_USHORT, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_USHORT)
/* Check for UINT type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_UINT, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_UINT, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_UINT)
/* Check for ULONG type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_ULONG, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_ULONG, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_ULONG)
/* Check for ULONGLONG type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_ULLONG, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_ULLONG, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_ULLONG)
/* Check for FLOAT type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_FLOAT, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_FLOAT, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_FLOAT)
/* Check for DOUBLE type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_DOUBLE, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_DOUBLE, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_DOUBLE)
#if H5_SIZEOF_LONG_DOUBLE !=0
/* Check for LONGDOUBLE type */
- else if((H5T_cmp(type, (const H5T_t *)H5I_object_verify(H5T_NATIVE_LDOUBLE, H5I_DATATYPE), FALSE)) == 0)
+ else if((tmp = (H5T_t *)H5I_object_verify(H5T_NATIVE_LDOUBLE, H5I_DATATYPE))
+ && 0 == H5T_cmp(type, tmp, FALSE))
HGOTO_DONE(H5T_NATIVE_LDOUBLE)
#endif
else