diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-02-20 02:30:56 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-02-20 02:30:56 (GMT) |
commit | 8a9eb9fdcdbb01f18d40ad100ce38ba1d5515a26 (patch) | |
tree | 75440a1986b30ab10f68620c6472941fb97f5482 /test/error_test.c | |
parent | d0a61166cc593cd043e3697674d472f7aa85aae3 (diff) | |
download | hdf5-8a9eb9fdcdbb01f18d40ad100ce38ba1d5515a26.zip hdf5-8a9eb9fdcdbb01f18d40ad100ce38ba1d5515a26.tar.gz hdf5-8a9eb9fdcdbb01f18d40ad100ce38ba1d5515a26.tar.bz2 |
[svn-r18301] Description:
Bring r18300 from trunk to 1.8 branch:
Bring Coverity fixes from branch to trunk:
r18282:
Fix Coverity issue #428 by wrapping testing calls with if(pass) {} block.
r18283:
Fix Coverity issue #425 by wrapping test calls in if(pass) {} block
r18284:
Issue 166: init_error() malloc'd 3 pointers in initialization and never freed
inc ase of errors. Init pointers to NULL, check allocation results and free
allocations in error block
r18285:
Fix Coverity issue #410 by wrapping test calls with if(pass) {} block.
r18286:
Issue 165: custom_print_cb() needed allocations freed in error block.
r18287:
Fix coverity issue # 409
Added if (pass) checks around calls to flush_cache. Additionally,
added a check for file_ptr = NULL after call to setup_cache.
r18288:
Fix coverity# 107 free fh in H5HF_close() correctly before exit the function
even when failure occurs.
r18289:
Fix Coverity issue #429: correct failure return values to match return type
from routine.
r18290:
Fix Coverity issue #103: release allocated indirect section on error
r18294:
Issue 153, 152: Check allocations and free allocations in error block. Also
cleaned up hid_t identifer that were opened in error block.
r18295:
Fix coverity# 101 free new_loc in H5HF_man_iter_start_entry() correctly before
exit the function even when failure occurs
r18296:
Fix coverity# 100 free down_loc in H5HF_man_iter_down() before exit the function
when failure occurs
r18297:
Fixed coverity issues 54, 55 and 216. Correctly handle the various ways that
allocation of attr_name can fail in test_attr_basic_write.
r18298:
Fix coverity# 119 free object in H5HG_read() before exit the function when
failure occurs
r18299:
Fix coverity issue #112:
Add cleanup during error handling of H5MP_create.
Tested on:
Mac OS X/32 10.6.2 (amazon) w/debug & production
Misc. Linux configurations (on original checkins)
Diffstat (limited to 'test/error_test.c')
-rw-r--r-- | test/error_test.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/test/error_test.c b/test/error_test.c index 21a3e58..e784eb9 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -186,11 +186,16 @@ test_error(hid_t file) static herr_t init_error(void) { - ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME)+1; - char *cls_name = (char*)HDmalloc(HDstrlen(ERR_CLS_NAME)+1); + ssize_t cls_size = (ssize_t)HDstrlen(ERR_CLS_NAME) + 1; ssize_t msg_size = (ssize_t)HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1; - char *msg = (char*)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG)+1); - H5E_type_t *msg_type= (H5E_type_t *)HDmalloc(sizeof(H5E_type_t)); + char *cls_name = NULL; + char *msg = NULL; + H5E_type_t msg_type; + + if(NULL == (cls_name = (char *)HDmalloc(HDstrlen(ERR_CLS_NAME) + 1))) + TEST_ERROR + if(NULL == (msg = (char *)HDmalloc(HDstrlen(ERR_MIN_SUBROUTINE_MSG) + 1))) + TEST_ERROR if((ERR_CLS = H5Eregister_class(ERR_CLS_NAME, PROG_NAME, PROG_VERS)) < 0) TEST_ERROR; @@ -218,24 +223,28 @@ init_error(void) if((ERR_MIN_GETNUM = H5Ecreate_msg(ERR_CLS, H5E_MINOR, ERR_MIN_GETNUM_MSG)) < 0) TEST_ERROR; - if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, msg_type, msg, (size_t)msg_size) + 1) + if(msg_size != H5Eget_msg(ERR_MIN_SUBROUTINE, &msg_type, msg, (size_t)msg_size) + 1) TEST_ERROR; - if(*msg_type != H5E_MINOR) + if(msg_type != H5E_MINOR) TEST_ERROR; if(HDstrcmp(msg, ERR_MIN_SUBROUTINE_MSG)) TEST_ERROR; - HDfree(cls_name); - HDfree(msg); - HDfree(msg_type); - /* Register another class for later testing. */ if((ERR_CLS2 = H5Eregister_class(ERR_CLS2_NAME, PROG2_NAME, PROG_VERS)) < 0) TEST_ERROR; + HDfree(cls_name); + HDfree(msg); + return 0; error: + if(cls_name) + HDfree(cls_name); + if(msg) + HDfree(msg); + return -1; } /* end init_error() */ |