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/cache.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/cache.c')
-rw-r--r-- | test/cache.c | 274 |
1 files changed, 198 insertions, 76 deletions
diff --git a/test/cache.c b/test/cache.c index e5673f8..c68f758 100644 --- a/test/cache.c +++ b/test/cache.c @@ -13581,9 +13581,13 @@ check_get_entry_status(void) } } - protect_entry(file_ptr, 0, 0); + if ( pass ) { + + protect_entry(file_ptr, 0, 0); + + unprotect_entry(file_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); - unprotect_entry(file_ptr, 0, 0, FALSE, H5C__NO_FLAGS_SET); + } if ( pass ) { @@ -13605,7 +13609,11 @@ check_get_entry_status(void) } } - protect_entry(file_ptr, 0, 0); + if ( pass ) { + + protect_entry(file_ptr, 0, 0); + + } if ( pass ) { @@ -13627,7 +13635,11 @@ check_get_entry_status(void) } } - unprotect_entry(file_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG); + if ( pass ) { + + unprotect_entry(file_ptr, 0, 0, FALSE, H5C__PIN_ENTRY_FLAG); + + } if ( pass ) { @@ -13649,7 +13661,11 @@ check_get_entry_status(void) } } - mark_pinned_entry_dirty(0, 0, FALSE, (size_t)0); + if ( pass ) { + + mark_pinned_entry_dirty(0, 0, FALSE, (size_t)0); + + } if ( pass ) { @@ -13671,7 +13687,11 @@ check_get_entry_status(void) } } - unpin_entry(0, 0); + if ( pass ) { + + unpin_entry(0, 0); + + } if ( pass ) { @@ -14908,7 +14928,11 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + if ( pass ) { + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + + } if ( pass ) { @@ -15025,7 +15049,11 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + if ( pass ) { + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + + } if ( pass ) { @@ -15096,9 +15124,13 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + if ( pass ) { + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__PIN_ENTRY_FLAG); + } if ( pass ) { @@ -15220,10 +15252,14 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + if ( pass ) { + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, + H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, - H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); + } if ( pass ) { @@ -15290,14 +15326,18 @@ check_resize_entry(void) entry_size = LARGE_ENTRY_SIZE; } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__NO_FLAGS_SET); - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, TRUE, H5C__NO_FLAGS_SET); + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__NO_FLAGS_SET); + + } if ( pass ) { @@ -15314,7 +15354,11 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + if ( pass ) { + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + + } if ( pass ) { @@ -15433,7 +15477,11 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + if ( pass ) { + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + + } if ( pass ) { @@ -15504,9 +15552,13 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + if ( pass ) { + + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, H5C__PIN_ENTRY_FLAG); + + } if ( pass ) { @@ -15630,10 +15682,14 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + if ( pass ) { - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, - H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 3); + + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 3, FALSE, + H5C__UNPIN_ENTRY_FLAG | H5C__DELETED_FLAG); + + } if ( pass ) { @@ -15680,15 +15736,18 @@ check_resize_entry(void) } } - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG); + if ( pass ) { - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 2); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 2, FALSE, H5C__DELETED_FLAG); - protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); - unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 1); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 1, FALSE, H5C__DELETED_FLAG); + protect_entry(file_ptr, LARGE_ENTRY_TYPE, 0); + unprotect_entry(file_ptr, LARGE_ENTRY_TYPE, 0, FALSE, H5C__DELETED_FLAG); + + } if ( pass ) { @@ -15753,7 +15812,7 @@ check_evictions_enabled(void) int mile_stone = 1; H5F_t * file_ptr = NULL; H5C_t * cache_ptr = NULL; - test_entry_t * base_addr; + test_entry_t * base_addr = NULL; test_entry_t * entry_ptr; TESTING("evictions enabled/disabled functionality"); @@ -15806,9 +15865,18 @@ check_evictions_enabled(void) file_ptr = setup_cache((size_t)(1 * 1024 * 1024), (size_t)( 512 * 1024)); - cache_ptr = file_ptr->shared->cache; + if ( file_ptr == NULL ) { - base_addr = entries[MONSTER_ENTRY_TYPE]; + pass = FALSE; + failure_mssg = "file_ptr NULL from setup_cache."; + + } + else + { + cache_ptr = file_ptr->shared->cache; + + base_addr = entries[MONSTER_ENTRY_TYPE]; + } } if ( show_progress ) /* 2 */ @@ -15852,12 +15920,16 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* fill the cache */ - for ( i = 0; i < 16 ; i++ ) - { - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, - FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* fill the cache */ + for ( i = 0; i < 16 ; i++ ) + { + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, i); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, i, + FALSE, H5C__NO_FLAGS_SET); + } + } if ( show_progress ) /* 5 */ @@ -15885,10 +15957,14 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* protect and unprotect another entry */ - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16, - FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* protect and unprotect another entry */ + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 16, + FALSE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 7 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -15950,8 +16026,12 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* insert an entry */ - insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 17, TRUE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* insert an entry */ + insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 17, TRUE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 10 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -16050,10 +16130,14 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* protect and unprotect another entry */ - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18, - FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* protect and unprotect another entry */ + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 18, + FALSE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 15 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -16079,8 +16163,12 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* insert another entry */ - insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, TRUE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* insert another entry */ + insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, TRUE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 17 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -16123,10 +16211,14 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* protect and unprotect an entry that is in the cache */ - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, - FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* protect and unprotect an entry that is in the cache */ + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 19, + FALSE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 20 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -16152,10 +16244,14 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* protect and unprotect an entry that isn't in the cache */ - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20, - FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* protect and unprotect an entry that isn't in the cache */ + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 20, + FALSE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 22 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -16273,13 +16369,16 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* protect and unprotect an entry that isn't in the cache, forcing - * the cache to grow. - */ - protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21); - unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21, - FALSE, H5C__NO_FLAGS_SET); + if ( pass ) { + /* protect and unprotect an entry that isn't in the cache, forcing + * the cache to grow. + */ + protect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21); + unprotect_entry(file_ptr, MONSTER_ENTRY_TYPE, 21, + FALSE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 27 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -16322,8 +16421,12 @@ check_evictions_enabled(void) HDfprintf(stdout, "%s() - %0d -- pass = %d\n", fcn_name, mile_stone++, (int)pass); - /* insert an entry */ - insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 22, TRUE, H5C__NO_FLAGS_SET); + if ( pass ) { + + /* insert an entry */ + insert_entry(file_ptr, MONSTER_ENTRY_TYPE, 22, TRUE, H5C__NO_FLAGS_SET); + + } if ( show_progress ) /* 30 */ HDfprintf(stdout, "%s() - %0d -- pass = %d\n", @@ -22459,7 +22562,17 @@ check_auto_cache_resize_disable(void) file_ptr = setup_cache((size_t)(2 * 1024), (size_t)(1 * 1024)); - cache_ptr = file_ptr->shared->cache; + + if ( file_ptr == NULL ) { + + pass = FALSE; + failure_mssg = "file_ptr NULL from setup_cache."; + + } + else { + + cache_ptr = file_ptr->shared->cache; + } } if ( pass ) { @@ -23520,8 +23633,11 @@ check_auto_cache_resize_disable(void) if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++); - /* flush the cache and destroy all entries so we start from a known point */ - flush_cache(file_ptr, TRUE, FALSE, FALSE); + if ( pass ) { + + /* flush the cache and destroy all entries so we start from a known point */ + flush_cache(file_ptr, TRUE, FALSE, FALSE); + } if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++); @@ -23748,8 +23864,11 @@ check_auto_cache_resize_disable(void) if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++); - /* flush the cache and destroy all entries so we start from a known point */ - flush_cache(file_ptr, TRUE, FALSE, FALSE); + if ( pass ) { + + /* flush the cache and destroy all entries so we start from a known point */ + flush_cache(file_ptr, TRUE, FALSE, FALSE); + } if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++); @@ -23983,8 +24102,11 @@ check_auto_cache_resize_disable(void) if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++); - /* flush the cache and destroy all entries so we start from a known point */ - flush_cache(file_ptr, TRUE, FALSE, FALSE); + if ( pass ) { + + /* flush the cache and destroy all entries so we start from a known point */ + flush_cache(file_ptr, TRUE, FALSE, FALSE); + } if ( show_progress ) HDfprintf(stderr, "check point %d\n", checkpoint++); |