diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-04-03 19:51:14 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-04-03 19:51:14 (GMT) |
commit | 0fb88ded47762bcafdd4317a3cd48f4c706a011c (patch) | |
tree | f46e14f62d1c6f3ebd1fb9aab18fab97509782bd /test | |
parent | d53775c9468afe01b058e59db8dfc7a4d79f0340 (diff) | |
download | hdf5-0fb88ded47762bcafdd4317a3cd48f4c706a011c.zip hdf5-0fb88ded47762bcafdd4317a3cd48f4c706a011c.tar.gz hdf5-0fb88ded47762bcafdd4317a3cd48f4c706a011c.tar.bz2 |
[svn-r13580] Description:
Add version # and flags to external link format (as fields in a single
byte), in order to accomodate future changes/expansions.
Tested on:
Mac OS X/32 10.4.9 (amazon)
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
FreeBSD/32 6.2 (duty)
FreeBSD/64 6.2 (liberty)
Diffstat (limited to 'test')
-rw-r--r-- | test/be_extlink1.h5 | bin | 896 -> 896 bytes | |||
-rw-r--r-- | test/dt_arith.c | 4 | ||||
-rw-r--r-- | test/error_test.c | 4 | ||||
-rw-r--r-- | test/fheap.c | 2 | ||||
-rw-r--r-- | test/le_extlink1.h5 | bin | 896 -> 896 bytes | |||
-rw-r--r-- | test/links.c | 260 |
6 files changed, 135 insertions, 135 deletions
diff --git a/test/be_extlink1.h5 b/test/be_extlink1.h5 Binary files differindex d8a8347..f800185 100644 --- a/test/be_extlink1.h5 +++ b/test/be_extlink1.h5 diff --git a/test/dt_arith.c b/test/dt_arith.c index 2d761ad..b06147c 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -725,8 +725,8 @@ static int test_particular_fp_integer(void) hbool_t flag; double src_d = (double)SCHAR_MAX; signed char dst_c; - unsigned char *buf1, *buf2; - unsigned char *saved_buf1, *saved_buf2; + unsigned char *buf1 = NULL, *buf2 = NULL; + unsigned char *saved_buf1 = NULL, *saved_buf2 = NULL; size_t src_size1, src_size2; size_t dst_size1, dst_size2; float src_f = (float)INT_MAX; diff --git a/test/error_test.c b/test/error_test.c index 0df5aa5..e8ccacf 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -337,8 +337,8 @@ static herr_t test_long_desc(void) { const char *format="Testing very long description string, %s"; - char *long_desc; - char *full_desc; + char *long_desc = NULL; + char *full_desc = NULL; size_t u; const char *test_FUNC="test_long_desc"; diff --git a/test/fheap.c b/test/fheap.c index f3dd7b3..b3f6986 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -15168,7 +15168,7 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) unsigned char tiny_heap_id[HEAP_ID_LEN]; /* Heap ID for 'tiny' object */ unsigned char huge_heap_id[HEAP_ID_LEN]; /* Heap ID for 'huge' object */ hbool_t id_changed = FALSE; /* Whether the heap ID changed */ - unsigned char *rewrite_obj; /* Pointer to re-write buffer for objects */ + unsigned char *rewrite_obj = NULL; /* Pointer to re-write buffer for objects */ fheap_heap_ids_t keep_ids; /* Structure to retain heap IDs */ h5_stat_size_t empty_size; /* Size of a file with an empty heap */ size_t obj_size; /* Size of object */ diff --git a/test/le_extlink1.h5 b/test/le_extlink1.h5 Binary files differindex 7132ad7..10ed0bc 100644 --- a/test/le_extlink1.h5 +++ b/test/le_extlink1.h5 diff --git a/test/links.c b/test/links.c index ff6a8b8..8b44494 100644 --- a/test/links.c +++ b/test/links.c @@ -1592,8 +1592,8 @@ external_link_root(hid_t fapl, hbool_t new_format) ssize_t name_len; /* Length of object name */ char filename1[NAME_BUF_SIZE]; char filename2[NAME_BUF_SIZE]; - char *file; /* File from external link */ - char *path; /* Path from external link */ + const char *file; /* File from external link */ + const char *path; /* Path from external link */ if(new_format) TESTING("external link to root (w/new group format)") @@ -1627,15 +1627,13 @@ external_link_root(hid_t fapl, hbool_t new_format) goto error; } if(H5Lget_val(fid, "ext_link", objname, sizeof(objname), H5P_DEFAULT) < 0) TEST_ERROR - if(H5Lunpack_elink_val(objname, sb.linklen, &file, &path) < 0) TEST_ERROR - if(HDstrcmp(file, filename1)) - { + if(H5Lunpack_elink_val(objname, sb.linklen, NULL, &file, &path) < 0) TEST_ERROR + if(HDstrcmp(file, filename1)) { H5_FAILED(); puts(" External link file name incorrect"); goto error; } - if(HDstrcmp(path, "/")) - { + if(HDstrcmp(path, "/")) { H5_FAILED(); puts(" External link path incorrect"); goto error; @@ -2591,8 +2589,8 @@ external_link_query(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group IDs */ - char *file_name; /* Name of the file the external link points to */ - char *object_name; /* Name of the object the external link points to */ + const char *file_name; /* Name of the file the external link points to */ + const char *object_name; /* Name of the object the external link points to */ H5G_stat_t sb; /* Object information */ H5L_info_t li; /* Link information */ char filename1[NAME_BUF_SIZE], @@ -2616,7 +2614,7 @@ external_link_query(hid_t fapl, hbool_t new_format) /* Get size of buffer for external link */ if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != (HDstrlen(filename2) + HDstrlen("/dst") + 2)) TEST_ERROR + if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR if (H5L_TYPE_EXTERNAL != li.type) { H5_FAILED(); puts(" Unexpected link class - should have been an external link"); @@ -2642,7 +2640,7 @@ external_link_query(hid_t fapl, hbool_t new_format) /* Get size of buffer for external link */ if(H5Lget_info(fid, "src", &li, H5P_DEFAULT) < 0) TEST_ERROR - if(li.u.val_size != (HDstrlen(filename2) + HDstrlen("/dst") + 2)) TEST_ERROR + if(li.u.val_size != (1 + (HDstrlen(filename2) + 1) + (HDstrlen("/dst") + 1))) TEST_ERROR if (H5L_TYPE_EXTERNAL != li.type) { H5_FAILED(); puts(" Unexpected link class - should have been an external link"); @@ -2653,7 +2651,7 @@ external_link_query(hid_t fapl, hbool_t new_format) if(H5Lget_val(fid, "src", query_buf, (size_t)NAME_BUF_SIZE, H5P_DEFAULT) < 0) TEST_ERROR /* Extract the file and object names from the buffer */ - if(H5Lunpack_elink_val(query_buf, li.u.val_size, &file_name, &object_name) < 0) TEST_ERROR + if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, &file_name, &object_name) < 0) TEST_ERROR /* Compare the file and object names */ if(strcmp(file_name, filename2)) TEST_ERROR @@ -2671,20 +2669,20 @@ external_link_query(hid_t fapl, hbool_t new_format) if(H5Fclose(fid) < 0) TEST_ERROR /* Make sure that passing in NULLs to H5Lunpack_elink_val works */ - if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, NULL) < 0) TEST_ERROR + if(H5Lunpack_elink_val(query_buf, li.u.val_size, NULL, NULL, NULL) < 0) TEST_ERROR /* Make sure that bogus cases trigger errors in H5Lunpack_elink_val */ H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(query_buf, li.u.val_size - 1, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(query_buf, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(NULL, (size_t)0, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY H5E_BEGIN_TRY { - if(H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL) >= 0) TEST_ERROR + if(H5Lunpack_elink_val(NULL, (size_t)1000, NULL, NULL, NULL) >= 0) TEST_ERROR } H5E_END_TRY PASSED(); @@ -3730,133 +3728,127 @@ error: /* Callback functions for UD hard links. */ /* UD_hard_create increments the object's reference count */ static herr_t -UD_hard_create(const char UNUSED * link_name, hid_t loc_group, void * udata, size_t udata_size, hid_t UNUSED lcpl_id) +UD_hard_create(const char UNUSED * link_name, hid_t loc_group, const void *udata, + size_t udata_size, hid_t UNUSED lcpl_id) { haddr_t addr; hid_t target_obj = -1; herr_t ret_value = 0; - if(udata_size != sizeof(haddr_t)) - { - ret_value = -1; - goto done; - } + if(udata_size != sizeof(haddr_t)) { + ret_value = -1; + goto done; + } /* end if */ - addr = *((haddr_t *) udata); + addr = *((const haddr_t *)udata); /* Open the object this link points to */ target_obj= H5Oopen_by_addr(loc_group, addr); - if(target_obj < 0) - { - ret_value = -1; - goto done; - } + if(target_obj < 0) { + ret_value = -1; + goto done; + } /* end if */ /* Increment the reference count of the target object */ - if(H5Oincr_refcount(target_obj) < 0) - { - ret_value = -1; - goto done; - } + if(H5Oincr_refcount(target_obj) < 0) { + ret_value = -1; + goto done; + } /* end if */ done: /* Close the target object if we opened it */ - if(target_obj >= 0) - { - switch(H5Iget_type(target_obj)) - { + if(target_obj >= 0) { + switch(H5Iget_type(target_obj)) { case H5I_GROUP: if(H5Gclose(target_obj) < 0) - ret_value = -1; + ret_value = -1; break; case H5I_DATASET: if(H5Dclose(target_obj) < 0) - ret_value = -1; + ret_value = -1; break; case H5I_DATATYPE: if(H5Tclose(target_obj) < 0) - ret_value = -1; + ret_value = -1; break; default: return -1; - } - } + } /* end switch */ + } /* end if */ return ret_value; -} +} /* end UD_hard_create() */ + +/* Traverse a hard link by opening the object */ +static hid_t +UD_hard_traverse(const char UNUSED *link_name, hid_t cur_group, + const void *udata, size_t udata_size, hid_t UNUSED lapl_id) +{ + haddr_t addr; + hid_t ret_value = -1; + + if(udata_size != sizeof(haddr_t)) + return -1; + + addr = *((const haddr_t *) udata); + + ret_value = H5Oopen_by_addr(cur_group, addr); /* If this fails, our return value will be negative. */ + + return ret_value; +} /* end UD_hard_traverse() */ /* UD_hard_delete decrements the object's reference count */ static herr_t -UD_hard_delete(const char UNUSED * link_name, hid_t file, void * udata, size_t udata_size) +UD_hard_delete(const char UNUSED * link_name, hid_t file, const void *udata, + size_t udata_size) { haddr_t addr; hid_t target_obj = -1; herr_t ret_value = 0; - if(udata_size != sizeof(haddr_t)) - { - ret_value = -1; - goto done; - } + if(udata_size != sizeof(haddr_t)) { + ret_value = -1; + goto done; + } /* end if */ - addr = *((haddr_t *) udata); + addr = *((const haddr_t *) udata); /* Open the object this link points to */ target_obj= H5Oopen_by_addr(file, addr); - if(target_obj < 0) - { - ret_value = -1; - goto done; - } + if(target_obj < 0) { + ret_value = -1; + goto done; + } /* end if */ /* Decrement the reference count of the target object */ - if(H5Odecr_refcount(target_obj) < 0) - { - ret_value = -1; - goto done; - } + if(H5Odecr_refcount(target_obj) < 0) { + ret_value = -1; + goto done; + } /* end if */ done: /* Close the target object if we opened it */ - if(target_obj >= 0) - { - switch(H5Iget_type(target_obj)) - { + if(target_obj >= 0) { + switch(H5Iget_type(target_obj)) { case H5I_GROUP: if(H5Gclose(target_obj) < 0) - ret_value = -1; + ret_value = -1; break; case H5I_DATASET: if(H5Dclose(target_obj) < 0) - ret_value = -1; + ret_value = -1; break; case H5I_DATATYPE: if(H5Tclose(target_obj) < 0) - ret_value = -1; + ret_value = -1; break; default: - return -1; - } - } - - return ret_value; -} - -static hid_t -UD_hard_traverse(const char UNUSED *link_name, hid_t cur_group, void * udata, size_t udata_size, hid_t UNUSED lapl_id) -{ - haddr_t addr; - hid_t ret_value = -1; - - if(udata_size != sizeof(haddr_t)) - return -1; - - addr = *((haddr_t *) udata); - - ret_value = H5Oopen_by_addr(cur_group, addr); /* If this fails, our return value will be negative. */ + return -1; + } /* end switch */ + } /* end if */ return ret_value; -} +} /* end UD_hard_delete() */ const H5L_class_t UD_hard_class[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ @@ -4010,7 +4002,8 @@ ud_hard_links(hid_t fapl) * in the current group named REREG_TARGET_NAME */ static hid_t -UD_rereg_traverse(const char UNUSED * link_name, hid_t cur_group, void UNUSED * udata, size_t UNUSED udata_size, hid_t lapl_id) +UD_rereg_traverse(const char UNUSED * link_name, hid_t cur_group, + const void UNUSED *udata, size_t UNUSED udata_size, hid_t lapl_id) { hid_t ret_value; @@ -4020,7 +4013,7 @@ UD_rereg_traverse(const char UNUSED * link_name, hid_t cur_group, void UNUSED * error: return -1; -} +} /* end UD_rereg_traverse() */ /* This link class has the same ID number as the UD hard links but * has a very different traversal function */ @@ -4194,7 +4187,8 @@ ud_link_reregister(hid_t fapl) /* Callback functions for UD "callback" links. */ /* Creation callback. Called during move as well. */ static herr_t -UD_cb_create(const char * link_name, hid_t loc_group, void * udata, size_t udata_size, hid_t lcpl_id) +UD_cb_create(const char * link_name, hid_t loc_group, const void *udata, + size_t udata_size, hid_t lcpl_id) { if(!link_name) TEST_ERROR if(loc_group < 0) TEST_ERROR @@ -4209,12 +4203,13 @@ UD_cb_create(const char * link_name, hid_t loc_group, void * udata, size_t udata error: return -1; -} +} /* end UD_cb_create() */ static hid_t -UD_cb_traverse(const char * link_name, hid_t cur_group, void * udata, size_t udata_size, hid_t lapl_id) +UD_cb_traverse(const char * link_name, hid_t cur_group, const void *udata, + size_t udata_size, hid_t lapl_id) { - const char *target = (char *) udata; + const char *target = (const char *)udata; hid_t ret_value; if(!link_name) TEST_ERROR @@ -4232,11 +4227,12 @@ UD_cb_traverse(const char * link_name, hid_t cur_group, void * udata, size_t uda error: return -1; -} +} /* end UD_cb_traverse() */ /* Callback for when the link is moved or renamed */ static herr_t -UD_cb_move(const char * new_name, hid_t new_loc, void * udata, size_t udata_size) +UD_cb_move(const char *new_name, hid_t new_loc, const void *udata, + size_t udata_size) { if(!new_name) TEST_ERROR if(new_loc < 0) TEST_ERROR @@ -4250,11 +4246,12 @@ UD_cb_move(const char * new_name, hid_t new_loc, void * udata, size_t udata_size error: return -1; -} +} /* end UD_cb_move() */ /* Callback for when the link is deleted. Also called during move */ static herr_t -UD_cb_delete(const char * link_name, hid_t file, void * udata, size_t udata_size) +UD_cb_delete(const char *link_name, hid_t file, const void *udata, + size_t udata_size) { if(!link_name) TEST_ERROR if(file < 0) TEST_ERROR @@ -4268,11 +4265,12 @@ UD_cb_delete(const char * link_name, hid_t file, void * udata, size_t udata_size error: return -1; -} +} /* end UD_cb_delete() */ /* Callback for when the link is queried */ static ssize_t -UD_cb_query(const char * link_name, void * udata, size_t udata_size, void* buf, size_t buf_size) +UD_cb_query(const char * link_name, const void *udata, size_t udata_size, + void *buf, size_t buf_size) { if(!link_name) TEST_ERROR if(udata_size > 0 && !udata) TEST_ERROR @@ -4281,18 +4279,17 @@ UD_cb_query(const char * link_name, void * udata, size_t udata_size, void* buf, if(strcmp(udata, UD_CB_TARGET)) TEST_ERROR if(udata_size != UD_CB_TARGET_LEN) TEST_ERROR - if(buf) - { + if(buf) { if(buf_size < 16) TEST_ERROR strcpy(buf, "query succeeded"); - } + } /* end if */ /* There are 15 characters and a NULL in "query succeeded" */ return 16; error: return -1; -} +} /* end UD_cb_query() */ const H5L_class_t UD_cb_class[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ @@ -4448,7 +4445,8 @@ ud_callbacks(hid_t fapl, hbool_t new_format) *------------------------------------------------------------------------- */ static hid_t -UD_plist_traverse(const char UNUSED * link_name, hid_t cur_group, void UNUSED * udata, size_t udata_size, hid_t lapl_id) +UD_plist_traverse(const char UNUSED * link_name, hid_t cur_group, + const void UNUSED *udata, size_t udata_size, hid_t lapl_id) { char target[NAME_BUF_SIZE]; hid_t ret_value; @@ -4465,7 +4463,8 @@ UD_plist_traverse(const char UNUSED * link_name, hid_t cur_group, void UNUSED * error: return -1; -} +} /* end UD_plist_traverse() */ + const H5L_class_t UD_plist_class[1] = {{ H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ UD_PLIST_TYPE, /* Link type id number */ @@ -4590,20 +4589,20 @@ lapl_udata(hid_t fapl, hbool_t new_format) */ static herr_t UD_cbsucc_create(const char UNUSED * link_name, hid_t UNUSED loc_group, - void * udata, size_t udata_size, hid_t UNUSED lcpl_id) + const void *udata, size_t udata_size, hid_t UNUSED lcpl_id) { /* Check to make sure that this "soft link" has a target */ if(udata_size < 1 || !udata) return -1; return 0; -} +} /* end UD_cbsucc_create() */ static hid_t -UD_cbsucc_traverse(const char UNUSED * link_name, hid_t cur_group, - void * udata, size_t UNUSED udata_size, hid_t lapl_id) +UD_cbsucc_traverse(const char UNUSED *link_name, hid_t cur_group, + const void *udata, size_t UNUSED udata_size, hid_t lapl_id) { - const char *target = (char *) udata; + const char *target = (const char *)udata; hid_t ret_value; if(!target) goto error; @@ -4614,57 +4613,57 @@ UD_cbsucc_traverse(const char UNUSED * link_name, hid_t cur_group, error: return -1; -} +} /* end UD_cbsucc_traverse() */ /* Failure callback for when the link is moved or renamed */ static herr_t -UD_cbfail_move(const char UNUSED * new_name, hid_t UNUSED new_loc, - void UNUSED * udata, size_t UNUSED udata_size) +UD_cbfail_move(const char UNUSED *new_name, hid_t UNUSED new_loc, + const void UNUSED *udata, size_t UNUSED udata_size) { /* This traversal function will always fail. */ return -1; -} +} /* end UD_cbfail_move() */ /* SuccessCallback for when the link is moved or renamed */ static herr_t -UD_cbsucc_move(const char UNUSED * new_name, hid_t UNUSED new_loc, - void UNUSED * udata, size_t UNUSED udata_size) +UD_cbsucc_move(const char UNUSED *new_name, hid_t UNUSED new_loc, + const void UNUSED *udata, size_t UNUSED udata_size) { /* This traversal function will always succeed. */ return 0; -} +} /* end UD_cbsucc_move() */ /* Callback for when the link is deleted. Also called during move */ static herr_t -UD_cbsucc_delete(const char UNUSED * link_name, hid_t UNUSED file, - void UNUSED * udata, size_t UNUSED udata_size) +UD_cbsucc_delete(const char UNUSED *link_name, hid_t UNUSED file, + const void UNUSED *udata, size_t UNUSED udata_size) { /* This callback will always succeed */ return 0; -} +} /* end UD_cbsucc_delete() */ /* Callback for when the link is deleted. Also called during move */ static herr_t -UD_cbfail_delete(const char UNUSED * link_name, hid_t UNUSED file, - void UNUSED * udata, size_t UNUSED udata_size) +UD_cbfail_delete(const char UNUSED *link_name, hid_t UNUSED file, + const void UNUSED *udata, size_t UNUSED udata_size) { /* This traversal function will always fail. */ /* Note: un-deletable links are in general a very bad idea! */ return -1; -} +} /* end UD_cbfail_delete() */ /* Callback for when the link is queried */ static ssize_t -UD_cbfail_query(const char UNUSED * link_name, void UNUSED * udata, +UD_cbfail_query(const char UNUSED *link_name, const void UNUSED *udata, size_t UNUSED udata_size, void UNUSED *buf, size_t UNUSED buf_size) { /* This traversal function will always fail. */ return -1; -} +} /* end UD_cbfail_query() */ /* Callback for when the link is queried */ static ssize_t -UD_cbfail_on_write_query(const char UNUSED * link_name, void UNUSED * udata, +UD_cbfail_on_write_query(const char UNUSED *link_name, const void UNUSED *udata, size_t UNUSED udata_size, void *buf, size_t UNUSED buf_size) { /* This traversal function will return a buffer size, @@ -4676,11 +4675,12 @@ UD_cbfail_on_write_query(const char UNUSED * link_name, void UNUSED * udata, return -1; return 0; -} +} /* end UD_cbfail_on_write_query() */ /* Callback for when the link is queried */ static ssize_t -UD_cbsucc_query(const char UNUSED * link_name, void UNUSED * udata, size_t UNUSED udata_size, void *buf, size_t buf_size) +UD_cbsucc_query(const char UNUSED *link_name, const void UNUSED *udata, + size_t UNUSED udata_size, void *buf, size_t buf_size) { /* This traversal function will return a buffer size, * but will fail when a buffer is passed in ("writing to the buffer" @@ -4691,7 +4691,7 @@ UD_cbsucc_query(const char UNUSED * link_name, void UNUSED * udata, size_t UNUSE strcpy(buf, "succeed"); return 8; -} +} /* end UD_cbsucc_query() */ /* This class is full of failing callbacks */ const H5L_class_t UD_cbfail_class1[1] = {{ |