diff options
author | Jacob Smith <jake.smith@hdfgroup.org> | 2018-09-20 20:15:49 (GMT) |
---|---|---|
committer | Jacob Smith <jake.smith@hdfgroup.org> | 2018-09-20 20:15:49 (GMT) |
commit | 9dec62e0aedc17dbc170ec683a1af45ef411dc25 (patch) | |
tree | 500bfaec959769ce358ed84d559f81c7418f643c | |
parent | 5f8f703dec2e35d8a69c7bd3d9fb3b3e8e116bee (diff) | |
download | hdf5-9dec62e0aedc17dbc170ec683a1af45ef411dc25.zip hdf5-9dec62e0aedc17dbc170ec683a1af45ef411dc25.tar.gz hdf5-9dec62e0aedc17dbc170ec683a1af45ef411dc25.tar.bz2 |
Modify MTIME size behavior to be closer to expectations (we hope).
Minor code cleanup.
-rw-r--r-- | src/H5Dint.c | 48 | ||||
-rw-r--r-- | test/ohdr_mindset.c | 33 |
2 files changed, 34 insertions, 47 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c index 8c2dcf1..5448316 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -733,6 +733,7 @@ H5D__calculate_minimum_header_size( \ H5T_t *type = NULL; H5O_fill_t *fill_prop = NULL; hbool_t use_at_least_v18 = FALSE; + const char continuation[1] = ""; /* requred for work-around */ size_t ret_value = 0; FUNC_ENTER_NOAPI_NOINIT_NOERR; @@ -777,29 +778,16 @@ H5D__calculate_minimum_header_size( \ fill_prop, 0); -#if 1 /* DEBUG H5Omessage */ /* "Continuation" message size */ -#if 0 - ret_value += H5O_msg_raw_size( - file, - H5O_CONT_ID, - FALSE, - NULL); -#else - { - /* message pointer "tmp" is unused by raw get function, however, a null - * pointer is intercepted by an assert in H5O_msg_size_oh(). + /* message pointer "continuation" is unused by raw get function, however, + * a null pointer would be intercepted by an assert in H5O_msg_size_oh(). */ - char tmp[1] = ""; ret_value += H5O_msg_size_oh( file, ohdr, H5O_CONT_ID, - tmp, + continuation, 0); - } -#endif -#endif /* DEBUG H5Omessage */ /* Fill Value (backwards compatability) message size */ if (fill_prop->buf && !use_at_least_v18) { @@ -843,16 +831,24 @@ H5D__calculate_minimum_header_size( \ } /* Modification Time message size */ - if ((H5O_OH_GET_VERSION(ohdr) > 1) && /* TODO: H5O_VERSION_1 in H5Opkg.h */ - (H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr))) - { - time_t mtime = H5_now(); - ret_value += H5O_msg_size_oh( - file, - ohdr, - H5O_MTIME_NEW_ID, - &mtime, - 0); + if (H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr)) { + /* TODO: 1 -> H5O_VERSION_1 in H5Opkg.h */ + HDassert(H5O_OH_GET_VERSION(ohdr) >= 1); + + if (H5O_OH_GET_VERSION(ohdr) == 1) { + /* v1 object headers store modification time as a message */ + time_t mtime = H5_now(); + ret_value += H5O_msg_size_oh( + file, + ohdr, + H5O_MTIME_NEW_ID, + &mtime, + 0); + } else { /* "version 2" */ + /* TODO: is this backwards? reduce space if _not_ set? */ + /* 4 4-byte (32-bit) fields: atime, mtime, ctime, btime */ + ret_value += 16; + } } FUNC_LEAVE_NOAPI(ret_value); diff --git a/test/ohdr_mindset.c b/test/ohdr_mindset.c index 505ddf4..af6dd1f 100644 --- a/test/ohdr_mindset.c +++ b/test/ohdr_mindset.c @@ -1,5 +1,5 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Tests to verify behavior of minimized object headers. + * Tests to verify behavior of minimized dataset object headers. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "hdf5.h" @@ -406,6 +406,7 @@ if (strcmp((actual), (expected)) != 0) { \ * Macro: PRINT_DSET_OH_COMPARISON(...) * * Pretty-print metadata information about two dataset object headers. + * Please use only at "top level" of test function. * --------------------------------------------------------------------------- */ #define PRINT_DSET_OH_COMPARISON(did1, did2) \ @@ -477,7 +478,7 @@ if (strcmp((actual), (expected)) != 0) { \ /* --------------------------------------------------------------------------- * Function: _create_file() * - * Purpose: Create a file with the name, and record its hid in out parameter. + * Purpose: Create a file with the name, and record its ID in out parameter. * * Return: 0 (success) or -1 (failure) * @@ -505,7 +506,7 @@ _create_file( \ /* --------------------------------------------------------------------------- * Function: _make_dataset() * - * Purpose: Create a dataset and record its hid in out parameter `dset_id`. + * Purpose: Create a dataset and record its ID in out parameter `dset_id`. * * Return: 0 (success) or -1 (failure) * @@ -628,7 +629,8 @@ _oh_getsize(hid_t did, hsize_t *size_out) * Purpose: Compare the TOTAL space used by datasets' object headers. * * - * Return: -1 if an error occurred, else positive #defined indicator value. + * Return: negative value if an error occurred, + * else positive #defined indicator value EQ, LT, GT. * * --------------------------------------------------------------------------- */ @@ -642,7 +644,6 @@ oh_compare( \ if (FAIL == _oh_getsize(did1, &space1)) return -1; - if (FAIL == _oh_getsize(did2, &space2)) return -2; @@ -1276,7 +1277,7 @@ test_minimized_with_filter(void) file_id, \ "xZ", \ dtype_id, \ - dspace_id, \ + dspace_id, \ dcpl_xZ_id, \ &dset_xZ_id) @@ -1422,7 +1423,7 @@ test_modification_times(void) for (i = 0; i < n_cases; i++) { /* -------------- * - * per-test setup * + * per-case setup * * -------------- */ fapl_id = H5P_DEFAULT; @@ -1499,25 +1500,15 @@ test_modification_times(void) PRINT_DSET_OH_COMPARISON(dset_mT_id, dset_mN_id) } - if (cases[i].oh_version == 1) { - /* V1 dataset headers do not support modtime tracking; are equal - */ - JSVERIFY( EQ, oh_compare(dset_xx_id, dset_xT_id), NULL ) - JSVERIFY( EQ, oh_compare(dset_mx_id, dset_mT_id), NULL ) - JSVERIFY( EQ, oh_compare(dset_mN_id, dset_mT_id), NULL ) - } else { - /* V2 dataset headers should support modtime tracking - */ - JSVERIFY( EQ, oh_compare(dset_xx_id, dset_xT_id), NULL ) - JSVERIFY( EQ, oh_compare(dset_mx_id, dset_mT_id), NULL ) - JSVERIFY( LT, oh_compare(dset_mN_id, dset_mT_id), NULL ) - } + JSVERIFY( EQ, oh_compare(dset_xx_id, dset_xT_id), NULL ) + JSVERIFY( EQ, oh_compare(dset_mx_id, dset_mT_id), NULL ) + JSVERIFY( LT, oh_compare(dset_mN_id, dset_mT_id), NULL ) JSVERIFY( LT, oh_compare(dset_mT_id, dset_xT_id), "minimized should always be smaller than unminimized" ) /* ----------------- * - * per-test teardown * + * per-case teardown * * ----------------- */ MUST_CLOSE(dset_xx_id, CLOSE_DATASET) |