From fcaf9c483ac83f9cc6765b032022d56081942d37 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 1 Jun 2016 12:02:30 -0500 Subject: [svn-r30002] Fixed some minor warnings in H5AC.c and H5C.c, cleaned up warnings in the cache tests, and made some huge static arrays dynamic in the cache tests. Tested on: 64-bit Ubuntu Linux w/ gcc 5.3.1 Autotools serial --- src/H5AC.c | 2 +- src/H5C.c | 2 +- test/cache.c | 67 ++++++++------ test/cache_common.c | 249 ++++++++++++++++++++++++++++++++++++++++++--------- test/cache_common.h | 4 + test/cache_tagging.c | 167 +++++++++++++++++++++++----------- 6 files changed, 368 insertions(+), 123 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index 42f328e..213e5d5 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -1144,7 +1144,7 @@ H5AC_protect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, FILE * trace_file_ptr = NULL; #endif /* H5AC__TRACE_FILE_ENABLED */ void * thing = NULL; /* Pointer to native data structure for entry */ - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5C.c b/src/H5C.c index f632af5..b7c5919 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -9293,7 +9293,7 @@ H5C__mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) { unsigned u; /* Local index variable */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(cache_ptr); diff --git a/test/cache.c b/test/cache.c index 88077e4..a5c8f93 100644 --- a/test/cache.c +++ b/test/cache.c @@ -9146,23 +9146,29 @@ check_flush_cache__flush_op_test(H5F_t * file_ptr, ( check[i].entry_type >= NUMBER_OF_ENTRY_TYPES ) || ( check[i].entry_index < 0 ) || ( check[i].entry_index > max_indices[check[i].entry_type] ) || - ( check[i].expected_size <= (size_t)0 ) || - ( ( check[i].in_cache != TRUE ) && - ( check[i].in_cache != FALSE ) ) || - ( ( check[i].at_main_addr != TRUE ) && - ( check[i].at_main_addr != FALSE ) ) || - ( ( check[i].is_dirty != TRUE ) && - ( check[i].is_dirty != FALSE ) ) || - ( ( check[i].is_protected != TRUE ) && - ( check[i].is_protected != FALSE ) ) || - ( ( check[i].is_pinned != TRUE ) && - ( check[i].is_pinned != FALSE ) ) || - ( ( check[i].expected_deserialized != TRUE ) && - ( check[i].expected_deserialized != FALSE ) ) || - ( ( check[i].expected_serialized != TRUE ) && - ( check[i].expected_serialized != FALSE ) ) || - ( ( check[i].expected_destroyed != TRUE ) && - ( check[i].expected_destroyed != FALSE ) ) ) { +#ifndef H5_HAVE_STDBOOL_H + /* Check for nonsense values if hbool_t is an integral + * type instead of a real Boolean. + */ + ( ( check[i].in_cache != TRUE ) && + ( check[i].in_cache != FALSE ) ) || + ( ( check[i].at_main_addr != TRUE ) && + ( check[i].at_main_addr != FALSE ) ) || + ( ( check[i].is_dirty != TRUE ) && + ( check[i].is_dirty != FALSE ) ) || + ( ( check[i].is_protected != TRUE ) && + ( check[i].is_protected != FALSE ) ) || + ( ( check[i].is_pinned != TRUE ) && + ( check[i].is_pinned != FALSE ) ) || + ( ( check[i].expected_deserialized != TRUE ) && + ( check[i].expected_deserialized != FALSE ) ) || + ( ( check[i].expected_serialized != TRUE ) && + ( check[i].expected_serialized != FALSE ) ) || + ( ( check[i].expected_destroyed != TRUE ) && + ( check[i].expected_destroyed != FALSE ) ) || +#endif /* H5_HAVE_STDBOOL_H */ + ( check[i].expected_size <= (size_t)0 ) + ) { pass = FALSE; HDsnprintf(msg, (size_t)128, @@ -35044,19 +35050,13 @@ check_stats__smoke_check_1(H5F_t * file_ptr) /*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Run tests on the cache code contained in H5C.c - * - * Return: Success: + * Function: main * - * Failure: + * Return: EXIT_SUCCESS/EXIT_FAILURE * - * Programmer: John Mainzer + * Programmer: John Mainzer * 6/24/04 * - * Modifications: - * *------------------------------------------------------------------------- */ @@ -35075,6 +35075,12 @@ main(void) printf(" express_test = %d\n", express_test); printf("=========================================\n"); + if ( create_entry_arrays() < 0 ) { + + printf("ERROR: Unable to create entries arrays. Aborting.\n"); + return EXIT_FAILURE; + } /* end if */ + nerrs += smoke_check_1(express_test); nerrs += smoke_check_2(express_test); nerrs += smoke_check_3(express_test); @@ -35127,6 +35133,13 @@ main(void) nerrs += check_entry_deletions_during_scans(); nerrs += check_stats(); - return(nerrs > 0); + /* can't fail, returns void */ + free_entry_arrays(); + + if ( nerrs > 0 ) + return EXIT_FAILURE; + else + return EXIT_SUCCESS; + } /* main() */ diff --git a/test/cache_common.c b/test/cache_common.c index 924920b..3b075d4 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -62,17 +62,17 @@ hbool_t try_core_file_driver = FALSE; hbool_t core_file_driver_failed = FALSE; const char *failure_mssg = NULL; -static test_entry_t pico_entries[NUM_PICO_ENTRIES], orig_pico_entries[NUM_PICO_ENTRIES]; -static test_entry_t nano_entries[NUM_NANO_ENTRIES], orig_nano_entries[NUM_NANO_ENTRIES]; -static test_entry_t micro_entries[NUM_MICRO_ENTRIES], orig_micro_entries[NUM_MICRO_ENTRIES]; -static test_entry_t tiny_entries[NUM_TINY_ENTRIES], orig_tiny_entries[NUM_TINY_ENTRIES]; -static test_entry_t small_entries[NUM_SMALL_ENTRIES], orig_small_entries[NUM_SMALL_ENTRIES]; -static test_entry_t medium_entries[NUM_MEDIUM_ENTRIES], orig_medium_entries[NUM_MEDIUM_ENTRIES]; -static test_entry_t large_entries[NUM_LARGE_ENTRIES], orig_large_entries[NUM_LARGE_ENTRIES]; -static test_entry_t huge_entries[NUM_HUGE_ENTRIES], orig_huge_entries[NUM_HUGE_ENTRIES]; -static test_entry_t monster_entries[NUM_MONSTER_ENTRIES], orig_monster_entries[NUM_MONSTER_ENTRIES]; -static test_entry_t variable_entries[NUM_VARIABLE_ENTRIES], orig_variable_entries[NUM_VARIABLE_ENTRIES]; -static test_entry_t notify_entries[NUM_NOTIFY_ENTRIES], orig_notify_entries[NUM_NOTIFY_ENTRIES]; +static test_entry_t *pico_entries = NULL, *orig_pico_entries = NULL; +static test_entry_t *nano_entries = NULL, *orig_nano_entries = NULL; +static test_entry_t *micro_entries = NULL, *orig_micro_entries = NULL; +static test_entry_t *tiny_entries = NULL, *orig_tiny_entries = NULL; +static test_entry_t *small_entries = NULL, *orig_small_entries = NULL; +static test_entry_t *medium_entries = NULL, *orig_medium_entries = NULL; +static test_entry_t *large_entries = NULL, *orig_large_entries = NULL; +static test_entry_t *huge_entries = NULL, *orig_huge_entries = NULL; +static test_entry_t *monster_entries = NULL, *orig_monster_entries = NULL; +static test_entry_t *variable_entries = NULL, *orig_variable_entries = NULL; +static test_entry_t *notify_entries = NULL, *orig_notify_entries = NULL; hbool_t orig_entry_arrays_init = FALSE; @@ -225,36 +225,9 @@ static herr_t free_icr(test_entry_t *entry, int32_t entry_type); static void execute_flush_op(H5F_t *file_ptr, struct test_entry_t *entry_ptr, struct flush_op *op_ptr, unsigned *flags_ptr); +test_entry_t *entries[NUMBER_OF_ENTRY_TYPES]; -test_entry_t *entries[NUMBER_OF_ENTRY_TYPES] = -{ - pico_entries, - nano_entries, - micro_entries, - tiny_entries, - small_entries, - medium_entries, - large_entries, - huge_entries, - monster_entries, - variable_entries, - notify_entries -}; - -test_entry_t *orig_entries[NUMBER_OF_ENTRY_TYPES] = -{ - orig_pico_entries, - orig_nano_entries, - orig_micro_entries, - orig_tiny_entries, - orig_small_entries, - orig_medium_entries, - orig_large_entries, - orig_huge_entries, - orig_monster_entries, - orig_variable_entries, - orig_notify_entries -}; +test_entry_t *orig_entries[NUMBER_OF_ENTRY_TYPES]; const int32_t max_indices[NUMBER_OF_ENTRY_TYPES] = { @@ -1707,8 +1680,13 @@ add_flush_op(int target_type, ( type == VARIABLE_ENTRY_TYPE ) ); HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) ); HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) ); - HDassert( ( flag == TRUE ) || ( flag == FALSE ) ); HDassert( new_size <= VARIABLE_ENTRY_SIZE ); +#ifndef H5_HAVE_STDBOOL_H + /* Check for TRUE or FALSE if we're using an integer type instead + * of a real Boolean type. + */ + HDassert( ( flag == TRUE ) || ( flag == FALSE ) ); +#endif /* H5_HAVE_STDBOOL_H */ if ( pass ) { @@ -1934,8 +1912,13 @@ execute_flush_op(H5F_t * file_ptr, ( op_ptr->type < NUMBER_OF_ENTRY_TYPES ) ); HDassert( ( 0 <= op_ptr->idx ) && ( op_ptr->idx <= max_indices[op_ptr->type] ) ); - HDassert( ( op_ptr->flag == FALSE ) || ( op_ptr->flag == TRUE ) ); HDassert( flags_ptr != NULL ); +#ifndef H5_HAVE_STDBOOL_H + /* Check for TRUE or FALSE if we're using an integer type instead + * of a real Boolean type. + */ + HDassert( ( op_ptr->flag == FALSE ) || ( op_ptr->flag == TRUE ) ); +#endif /* H5_HAVE_STDBOOL_H */ if ( pass ) { @@ -2098,6 +2081,188 @@ entry_in_cache(H5C_t * cache_ptr, /*------------------------------------------------------------------------- + * Function: create_entry_arrays + * + * Purpose: Create the entry arrays, both regular and original. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Spring 2016 + * + *------------------------------------------------------------------------- + */ + +herr_t +create_entry_arrays(void) + +{ + /* pico entries */ + if(NULL == (pico_entries = (test_entry_t *)HDcalloc(NUM_PICO_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_pico_entries = (test_entry_t *)HDcalloc(NUM_PICO_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* nano entries */ + if(NULL == (nano_entries = (test_entry_t *)HDcalloc(NUM_NANO_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_nano_entries = (test_entry_t *)HDcalloc(NUM_NANO_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* micro entries */ + if(NULL == (micro_entries = (test_entry_t *)HDcalloc(NUM_MICRO_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_micro_entries = (test_entry_t *)HDcalloc(NUM_MICRO_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* tiny entries */ + if(NULL == (tiny_entries = (test_entry_t *)HDcalloc(NUM_TINY_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_tiny_entries = (test_entry_t *)HDcalloc(NUM_TINY_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* small entries */ + if(NULL == (small_entries = (test_entry_t *)HDcalloc(NUM_SMALL_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_small_entries = (test_entry_t *)HDcalloc(NUM_SMALL_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* medium entries */ + if(NULL == (medium_entries = (test_entry_t *)HDcalloc(NUM_MEDIUM_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_medium_entries = (test_entry_t *)HDcalloc(NUM_MEDIUM_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* large entries */ + if(NULL == (large_entries = (test_entry_t *)HDcalloc(NUM_LARGE_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_large_entries = (test_entry_t *)HDcalloc(NUM_LARGE_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* huge entries */ + if(NULL == (huge_entries = (test_entry_t *)HDcalloc(NUM_HUGE_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_huge_entries = (test_entry_t *)HDcalloc(NUM_HUGE_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* monster entries */ + if(NULL == (monster_entries = (test_entry_t *)HDcalloc(NUM_MONSTER_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_monster_entries = (test_entry_t *)HDcalloc(NUM_MONSTER_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* variable entries */ + if(NULL == (variable_entries = (test_entry_t *)HDcalloc(NUM_VARIABLE_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_variable_entries = (test_entry_t *)HDcalloc(NUM_VARIABLE_ENTRIES, sizeof(test_entry_t)))) + goto error; + + /* notify entries */ + if(NULL == (notify_entries = (test_entry_t *)HDcalloc(NUM_NOTIFY_ENTRIES, sizeof(test_entry_t)))) + goto error; + if(NULL == (orig_notify_entries = (test_entry_t *)HDcalloc(NUM_NOTIFY_ENTRIES, sizeof(test_entry_t)))) + goto error; + + entries[0] = pico_entries; + entries[1] = nano_entries; + entries[2] = micro_entries; + entries[3] = tiny_entries; + entries[4] = small_entries; + entries[5] = medium_entries; + entries[6] = large_entries; + entries[7] = huge_entries; + entries[8] = monster_entries; + entries[9] = variable_entries; + entries[10] = notify_entries; + + orig_entries[0] = orig_pico_entries; + orig_entries[1] = orig_nano_entries; + orig_entries[2] = orig_micro_entries; + orig_entries[3] = orig_tiny_entries; + orig_entries[4] = orig_small_entries; + orig_entries[5] = orig_medium_entries; + orig_entries[6] = orig_large_entries; + orig_entries[7] = orig_huge_entries; + orig_entries[8] = orig_monster_entries; + orig_entries[9] = orig_variable_entries; + orig_entries[10] = orig_notify_entries; + + return SUCCEED; + +error: + free_entry_arrays(); + return FAIL; + +} /* create_entry_arrays() */ + + +/*------------------------------------------------------------------------- + * Function: free_entry_arrays + * + * Purpose: Free the entry arrays, both regular and original. + * + * Return: void + * + * Programmer: Dana Robinson + * Spring 2016 + * + *------------------------------------------------------------------------- + */ + +void +free_entry_arrays(void) + +{ + /* pico entries */ + HDfree(pico_entries); + HDfree(orig_pico_entries); + + /* nano entries */ + HDfree(nano_entries); + HDfree(orig_nano_entries); + + /* micro entries */ + HDfree(micro_entries); + HDfree(orig_micro_entries); + + /* tiny entries */ + HDfree(tiny_entries); + HDfree(orig_tiny_entries); + + /* small entries */ + HDfree(small_entries); + HDfree(orig_small_entries); + + /* medium entries */ + HDfree(medium_entries); + HDfree(orig_medium_entries); + + /* large entries */ + HDfree(large_entries); + HDfree(orig_large_entries); + + /* huge entries */ + HDfree(huge_entries); + HDfree(orig_huge_entries); + + /* monster entries */ + HDfree(monster_entries); + HDfree(orig_monster_entries); + + /* variable entries */ + HDfree(variable_entries); + HDfree(orig_variable_entries); + + /* notify entries */ + HDfree(notify_entries); + HDfree(orig_notify_entries); + + return; + +} /* free_entry_arrays() */ + + +/*------------------------------------------------------------------------- * Function: reset_entries * * Purpose: reset the contents of the entries arrays to known values. diff --git a/test/cache_common.h b/test/cache_common.h index 655e17e..0b22cf2 100644 --- a/test/cache_common.h +++ b/test/cache_common.h @@ -621,6 +621,10 @@ H5TEST_DLL void create_pinned_entry_dependency(H5F_t * file_ptr, int pinned_type, int pinned_idx); +H5TEST_DLL herr_t create_entry_arrays(void); + +H5TEST_DLL void free_entry_arrays(void); + H5TEST_DLL void reset_entries(void); H5TEST_DLL void resize_entry(H5F_t * file_ptr, diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 0cc200c..3bf8790 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -1649,8 +1649,8 @@ check_attribute_rename_tags(hid_t fcpl, int type) hid_t aid = -1; /* Attribute Identifier */ hid_t sid = -1; /* Dataset Identifier */ int verbose = FALSE; /* verbose file outout */ - int data[DIMS][DIMS]; /* data buffer */ - int i,j,k = 0; /* iterators */ + int *data = NULL; /* data buffer */ + int i,j,k = 0; /* iterators */ haddr_t root_tag = 0; haddr_t sbe_tag = 0; haddr_t g_tag = 0; @@ -1664,6 +1664,9 @@ check_attribute_rename_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ + /* Allocate array */ + if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; @@ -1696,10 +1699,10 @@ check_attribute_rename_tags(hid_t fcpl, int type) if ( (aid = H5Acreate2(gid, ATTRNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; /* fill out data buffer */ - for(i=0;i