From 410d8365d0650b3bc9113fbc9176978f83291fbe Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 15 Dec 2015 11:15:55 -0500 Subject: [svn-r28663] Merge of r28662 from revise_chunks. Whitespace only. --- src/H5B.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/H5B.c b/src/H5B.c index 7f933cd..b26c38b 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -612,6 +612,7 @@ H5B_insert(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr, void /* Check if the root node split */ if(H5B_INS_NOOP == my_ins) { + /* The root node did not split - just return */ HDassert(!split_bt_ud.bt); HGOTO_DONE(SUCCEED) } /* end if */ @@ -2035,7 +2036,7 @@ htri_t H5B_valid(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, haddr_t addr) { H5B_t *bt = NULL; /* The B-tree */ - H5UC_t *rc_shared; /* Ref-counted shared info */ + H5UC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ htri_t ret_value = SUCCEED; /* Return value */ -- cgit v0.12 From b3426914a877877b43c90b6804130076ee1b3c2c Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Tue, 15 Dec 2015 15:52:12 -0500 Subject: [svn-r28669] Changes to correct errors found with -ansi flag. h5tools_dump.c Removed 3 lines commented out with //. h5_vds-percival-unlim.c Changed C++-style comment to C-style comment. Tested with h5committest.new. --- examples/h5_vds-percival-unlim.c | 5 +++-- tools/lib/h5tools_dump.c | 3 --- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/h5_vds-percival-unlim.c b/examples/h5_vds-percival-unlim.c index b5f3ebd..2496c37 100644 --- a/examples/h5_vds-percival-unlim.c +++ b/examples/h5_vds-percival-unlim.c @@ -288,8 +288,9 @@ main (void) /* Read all VDS data */ - //EIP We should be able to do it by using H5S_ALL instead of making selection - // or using H5Sselect_all from vspace. + /* EIP We should be able to do it by using H5S_ALL instead of making selection + * or using H5Sselect_all from vspace. + */ start[0] = 0; start[1] = 0; start[2] = 0; diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index 0d39981..1876e4f 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -1539,7 +1539,6 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont /* Hyperslab info */ hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ - //hsize_t hs_count[H5S_MAX_RANK]; /* size this pass */ hsize_t hs_nelmts; /* elements in request */ /* VL data special information */ @@ -1622,11 +1621,9 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont hs_size[i] = MIN(total_size[i] - hs_offset[i], sm_size[i]); ctx->p_max_idx[i] = ctx->p_min_idx[i] + hs_size[i]; hs_nelmts *= hs_size[i]; -// hs_count[i] = 1; } H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); -// H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_count, hs_size); H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL); } else { -- cgit v0.12 From 1ab7e61c392e471cbb3ec4cd5dfd1c375a2d4562 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 15 Dec 2015 21:27:35 -0500 Subject: [svn-r28678] Updated the cache_tagging test to correctly output tags in the debug/verbose function. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- test/cache_tagging.c | 124 +++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 62 deletions(-) diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 80ba2eb..470f7a1 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -112,103 +112,105 @@ static unsigned check_invalid_tag_application(void); static void print_entry_type_to_screen(int id) { - printf("Type = "); + HDfprintf(stdout, "Type = "); switch (id) { - case 0: - printf("B-tree Node(0)"); + case H5AC_BT_ID: + HDfprintf(stdout, "v1 B-tree Node"); break; - case 1: - printf("Symbol Table Node(1)"); + case H5AC_SNODE_ID: + HDfprintf(stdout, "Symbol Table Node"); break; - case 2: - printf("Local Heap Prefix(2)"); + case H5AC_LHEAP_PRFX_ID: + HDfprintf(stdout, "Local Heap Prefix"); break; - case 3: - printf("Local Heap Data Block(3)"); + case H5AC_LHEAP_DBLK_ID: + HDfprintf(stdout, "Local Heap Data Block"); break; - case 4: - printf("Global Heap(4)"); + case H5AC_GHEAP_ID: + HDfprintf(stdout, "Global Heap"); break; - case 5: - printf("Object Header(5)"); + case H5AC_OHDR_ID: + HDfprintf(stdout, "Object Header"); break; - case 6: - printf("Object Header Chunk(6)"); + case H5AC_OHDR_CHK_ID: + HDfprintf(stdout, "Object Header Chunk"); break; - case 7: - printf("v2 B-tree Header(7)"); + case H5AC_BT2_HDR_ID: + HDfprintf(stdout, "v2 B-tree Header"); break; - case 8: - printf("v2 B-tree Internal Node(8)"); + case H5AC_BT2_INT_ID: + HDfprintf(stdout, "v2 B-tree Internal Node"); break; - case 9: - printf("v2 B-tree Leaf Node(9)"); + case H5AC_BT2_LEAF_ID: + HDfprintf(stdout, "v2 B-tree Leaf Node"); break; - case 10: - printf("Fractal Heap Header(10)"); + case H5AC_FHEAP_HDR_ID: + HDfprintf(stdout, "Fractal Heap Header"); break; - case 11: - printf("Fractal Heap Direct Block(11)"); + case H5AC_FHEAP_DBLOCK_ID: + HDfprintf(stdout, "Fractal Heap Direct Block"); break; - case 12: - printf("Fractal Heap Indirect Block(12)"); + case H5AC_FHEAP_IBLOCK_ID: + HDfprintf(stdout, "Fractal Heap Indirect Block"); break; - case 13: - printf("Free Space Header(13)"); + case H5AC_FSPACE_HDR_ID: + HDfprintf(stdout, "Free Space Header"); break; - case 14: - printf("Free Space Section(14)"); + case H5AC_FSPACE_SINFO_ID: + HDfprintf(stdout, "Free Space Section"); break; - case 15: - printf("Shared Object Header Message Master Table(15)"); + case H5AC_SOHM_TABLE_ID: + HDfprintf(stdout, "Shared Object Header Message Master Table"); break; - case 16: - printf("Shared Message Index Stored As A List(16)"); + case H5AC_SOHM_LIST_ID: + HDfprintf(stdout, "Shared Message Index Stored As A List"); break; - case 17: - printf("Extensible Array Header(17)"); + case H5AC_EARRAY_HDR_ID: + HDfprintf(stdout, "Extensible Array Header"); break; - case 18: - printf("Extensible Array Index Block(18)"); + case H5AC_EARRAY_IBLOCK_ID: + HDfprintf(stdout, "Extensible Array Index Block"); break; - case 19: - printf("Extensible Array Super Block(19)"); + case H5AC_EARRAY_SBLOCK_ID: + HDfprintf(stdout, "Extensible Array Super Block"); break; - case 20: - printf("Extensible Array Data Block(20)"); + case H5AC_EARRAY_DBLOCK_ID: + HDfprintf(stdout, "Extensible Array Data Block"); break; - case 21: - printf("Extensible Array Data Block Page(21)"); + case H5AC_EARRAY_DBLK_PAGE_ID: + HDfprintf(stdout, "Extensible Array Data Block Page"); break; - case 22: - printf("Chunk Proxy(22)"); + case H5AC_FARRAY_HDR_ID: + HDfprintf(stdout, "Fixed Array Header"); break; - case 23: - printf("Fixed Array Header(23)"); + case H5AC_FARRAY_DBLOCK_ID: + HDfprintf(stdout, "Fixed Array Data Block"); break; - case 24: - printf("Fixed Array Data Block(24)"); + case H5AC_FARRAY_DBLK_PAGE_ID: + HDfprintf(stdout, "Fixed Array Data Block Page"); break; - case 25: - printf("Fixed Array Data Block Page(25)"); + case H5AC_SUPERBLOCK_ID: + HDfprintf(stdout, "File Superblock"); break; - case 26: - printf("File Superblock(26)"); + case H5AC_DRVRINFO_ID: + HDfprintf(stdout, "Driver Info Block"); break; - case 27: - printf("Test Entry(27)"); + case H5AC_TEST_ID: + HDfprintf(stdout, "Test Entry"); break; - case 28: - printf("Number of Types(28)"); + case H5AC_NTYPES: + HDfprintf(stdout, "BADNESS: Number of Types"); break; default: - printf("*Unknown*"); + HDfprintf(stdout, "BADNESS: *Unknown*"); break; } /* end switch */ + HDfprintf(stdout, " (%d)", id); + } /* print_entry_type_to_screen */ @@ -225,8 +227,6 @@ print_entry_type_to_screen(int id) * Programmer: Mike McGreevy * January 25, 2010 * - * Modifications: - * *------------------------------------------------------------------------- */ static int print_index(hid_t fid) { -- cgit v0.12 From 0a00732c4d9ba64a0507fd5dfe73929496383074 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 17 Dec 2015 01:31:27 -0500 Subject: [svn-r28696] Minor normalization with revise_chunks. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- src/H5AC.c | 1 + test/accum.c | 118 +++++++++++++++++++++---------------------- test/links.c | 11 ++-- test/objcopy.c | 54 +++++++++++--------- test/ohdr.c | 8 +-- tools/h5dump/h5dumpgentest.c | 24 +++------ 6 files changed, 106 insertions(+), 110 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index 93f1ee4..f5b331f 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -46,6 +46,7 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip Lists */ /****************/ diff --git a/test/accum.c b/test/accum.c index 268b7e1..edfc751 100644 --- a/test/accum.c +++ b/test/accum.c @@ -164,7 +164,7 @@ test_write_read(const H5F_io_info_t *fio_info) /* Allocate buffers */ write_buf = (int *)HDmalloc(1024 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(1024, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)1024, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -175,7 +175,7 @@ test_write_read(const H5F_io_info_t *fio_info) /* Write 1KB at Address 0 */ if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -220,7 +220,7 @@ test_write_read_nonacc_front(const H5F_io_info_t *fio_info) /* Allocate buffers */ write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -234,7 +234,7 @@ test_write_read_nonacc_front(const H5F_io_info_t *fio_info) if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; if(accum_write(1024, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -279,7 +279,7 @@ test_write_read_nonacc_end(const H5F_io_info_t *fio_info) /* Allocate buffers */ write_buf = (int *)HDmalloc(2048 * sizeof(int)); HDassert(write_buf); - read_buf = (int *)HDcalloc(2048, sizeof(int)); + read_buf = (int *)HDcalloc((size_t)2048, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ @@ -293,7 +293,7 @@ test_write_read_nonacc_end(const H5F_io_info_t *fio_info) if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(1024, 1024, read_buf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(write_buf, read_buf, (size_t)1024) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -525,7 +525,7 @@ test_accum_overlap(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -697,7 +697,7 @@ test_accum_overlap_clean(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -876,7 +876,7 @@ test_accum_non_overlap_size(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -943,7 +943,7 @@ test_accum_overlap_size(const H5F_io_info_t *fio_info) /* Allocate buffers */ wbuf = (int32_t *)HDmalloc(4096 * sizeof(int32_t)); HDassert(wbuf); - rbuf = (int32_t *)HDcalloc(4096, sizeof(int32_t)); + rbuf = (int32_t *)HDcalloc((size_t)4096, sizeof(int32_t)); HDassert(rbuf); /* Case 1: No metadata in accumulator */ @@ -1050,11 +1050,11 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read back and verify first write */ if(accum_read((1024 * 1024), (1024 * 1024) - 1, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, (1024 * 1024) - 1) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)((1024 * 1024) - 1)) != 0) TEST_ERROR; /* Read back and verify second write */ if(accum_read((1024 * 1024) - 1024, 1024, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1080,10 +1080,10 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read back and verify both pieces of data */ if(accum_read(1048576, 1048575, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1048576) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1048576) != 0) TEST_ERROR; if(accum_read(5, 1048571, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1048571) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1048571) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1118,7 +1118,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read((1024 * 1024) - 1, 1024, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1158,7 +1158,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 349523) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1195,7 +1195,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read((1024 * 1024) - 5, 10, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 10) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)10) != 0) TEST_ERROR; /* Reset accumulator for next case */ if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1227,7 +1227,7 @@ test_accum_adjust(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(1048571, 349523, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 349523) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)349523) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1310,7 +1310,7 @@ test_read_after(const H5F_io_info_t *fio_info) /* Read in the piece we wrote to disk above, and then verify that the data is as expected */ if(accum_read(512, 512, rbuf) < 0) FAIL_STACK_ERROR; - if(HDmemcmp(wbuf, rbuf, 128) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)128) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1352,13 +1352,13 @@ test_big(const H5F_io_info_t *fio_info) unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t *)HDmalloc(BIG_BUF_SIZE); + wbuf = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf); - wbuf2 = (uint8_t *)HDmalloc(BIG_BUF_SIZE); + wbuf2 = (uint8_t *)HDmalloc((size_t)BIG_BUF_SIZE); HDassert(wbuf2); - rbuf = (uint8_t *)HDcalloc(BIG_BUF_SIZE + 1536, 1); + rbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(rbuf); - zbuf = (uint8_t *)HDcalloc(BIG_BUF_SIZE + 1536, 1); + zbuf = (uint8_t *)HDcalloc((size_t)(BIG_BUF_SIZE + 1536), (size_t)1); HDassert(zbuf); /* Initialize write buffers */ @@ -1376,12 +1376,12 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1393,14 +1393,14 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 1024) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + 1024, 1024) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 2048, (BIG_BUF_SIZE - 2048)) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + 1024, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 2048, (size_t)(BIG_BUF_SIZE - 2048)) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(1024, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1412,13 +1412,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, (BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + (BIG_BUF_SIZE - 512), 512) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)(BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + (BIG_BUF_SIZE - 512), (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(BIG_BUF_SIZE - 512, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1430,13 +1430,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(512, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf + 512, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 512, (BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; + if(HDmemcmp(wbuf + 512, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 512, (size_t)(BIG_BUF_SIZE - 512)) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, 1024, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1453,12 +1453,12 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE); + HDmemset(rbuf, 0, (size_t)BIG_BUF_SIZE); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1475,13 +1475,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; - if(HDmemcmp(wbuf + 512, rbuf + BIG_BUF_SIZE, 512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf + 512, rbuf + BIG_BUF_SIZE, (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 512, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 512); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1502,14 +1502,14 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 1024, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf2, rbuf, BIG_BUF_SIZE) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + BIG_BUF_SIZE, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf, rbuf + BIG_BUF_SIZE + 512, 512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + BIG_BUF_SIZE, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf + BIG_BUF_SIZE + 512, (size_t)512) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1024); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1024)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1531,13 +1531,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 1536, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 1536) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 1536, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)1536) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 1536, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(1536, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1536); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1558,13 +1558,13 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(zbuf, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 512, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 512, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(512, BIG_BUF_SIZE, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 512); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 512)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1585,14 +1585,14 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 1536, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, 1024) != 0) TEST_ERROR; - if(HDmemcmp(zbuf, rbuf + 1024, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 1536, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)1024) != 0) TEST_ERROR; + if(HDmemcmp(zbuf, rbuf + 1024, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 1536, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; /* Reset data in file back to zeros & reset the read buffer */ if(accum_write(0, BIG_BUF_SIZE + 1536, zbuf) < 0) FAIL_STACK_ERROR; - HDmemset(rbuf, 0, BIG_BUF_SIZE + 1536); + HDmemset(rbuf, 0, (size_t)(BIG_BUF_SIZE + 1536)); if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1613,8 +1613,8 @@ test_big(const H5F_io_info_t *fio_info) if(accum_read(0, BIG_BUF_SIZE + 512, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read */ - if(HDmemcmp(wbuf, rbuf, 512) != 0) TEST_ERROR; - if(HDmemcmp(wbuf2, rbuf + 512, BIG_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)512) != 0) TEST_ERROR; + if(HDmemcmp(wbuf2, rbuf + 512, (size_t)BIG_BUF_SIZE) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; @@ -1666,9 +1666,9 @@ test_random_write(const H5F_io_info_t *fio_info) unsigned u; /* Local index variable */ /* Allocate space for the write & read buffers */ - wbuf = (uint8_t *)HDmalloc(RANDOM_BUF_SIZE); + wbuf = (uint8_t *)HDmalloc((size_t)RANDOM_BUF_SIZE); HDassert(wbuf); - rbuf = (uint8_t *)HDcalloc(RANDOM_BUF_SIZE, 1); + rbuf = (uint8_t *)HDcalloc((size_t)RANDOM_BUF_SIZE, (size_t)1); HDassert(rbuf); /* Initialize write buffer */ @@ -1752,7 +1752,7 @@ HDfprintf(stderr, "Random # seed was: %u\n", seed); if(accum_read(RANDOM_BASE_OFF, RANDOM_BUF_SIZE, rbuf) < 0) FAIL_STACK_ERROR; /* Verify data read back in */ - if(HDmemcmp(wbuf, rbuf, RANDOM_BUF_SIZE) != 0) TEST_ERROR; + if(HDmemcmp(wbuf, rbuf, (size_t)RANDOM_BUF_SIZE) != 0) TEST_ERROR; if(accum_reset(fio_info) < 0) FAIL_STACK_ERROR; diff --git a/test/links.c b/test/links.c index db5922b..2886304 100644 --- a/test/links.c +++ b/test/links.c @@ -3848,7 +3848,6 @@ external_set_elink_fapl3(hbool_t new_format) { hid_t core_fapl = -1, stdio_fapl = -1; hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; - int ret; if(new_format) TESTING("H5Pset/get_fapl() (w/new group format)") @@ -3907,11 +3906,11 @@ external_set_elink_fapl3(hbool_t new_format) error: H5E_BEGIN_TRY { - H5Pclose(l_fapl); - H5Pclose(lapl_id); - H5Pclose(new_lapl_id); - H5Pclose(core_fapl); - H5Pclose(stdio_fapl); + H5Pclose(l_fapl); + H5Pclose(lapl_id); + H5Pclose(new_lapl_id); + H5Pclose(core_fapl); + H5Pclose(stdio_fapl); } H5E_END_TRY; return -1; } /* end external_set_elink_fapl3() */ diff --git a/test/objcopy.c b/test/objcopy.c index 82be446..f3806cd 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -1243,12 +1243,11 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) if(offset1 != offset2) TEST_ERROR if(size1 != size2) TEST_ERROR - if(strcmp(name1, name2) != 0) TEST_ERROR + if(HDstrcmp(name1, name2) != 0) TEST_ERROR } - /* Remove external file information from the dcpls */ - - /* reset external file information from the dcpls */ + /* Reset external file information from the dcpls */ + /* (Directly removing default property causes memory leak) */ if (H5P_reset_external_file_test(dcpl) < 0) TEST_ERROR if (H5P_reset_external_file_test(dcpl2) < 0) TEST_ERROR } @@ -2311,7 +2310,7 @@ test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t #endif /* H5_CLEAR_MEMORY */ for(i = 0; i < DIM_SIZE_1; i++) { buf[i].a = i; - buf[i].d = 1.0F / (i + 1); + buf[i].d = (double)1.0F / (double)(i + 1); } /* end for */ /* Initialize the filenames */ @@ -2443,9 +2442,9 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t /* set initial data values */ for(i = 0; i < DIM_SIZE_1; i++) { - buf1d[i] = (float)(i / 2.0F); + buf1d[i] = (float)i / 2.0F; for(j = 0; j < DIM_SIZE_2; j++) - buf2d[i][j] = (float)(i + (j / 100.0F)); + buf2d[i][j] = (float)i + ((float)j / 100.0F); } /* end for */ /* Initialize the filenames */ @@ -2695,10 +2694,10 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED, fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Ocopy(fid_src, NAME_DATASET_CHUNKED2, fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - /* open the dataset for copy */ + /* open the dataset NAME_DATASET_CHUNKED in SRC file */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR - /* open the destination dataset */ + /* open the copied dataset NAME_DATASET_CHUNKED at destination */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the datasets are equal */ @@ -2710,10 +2709,10 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR - /* open the dataset for copy */ + /* open the dataset NAME_DATASET_CHUNKED_SINGLE in SRC file */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR - /* open the destination dataset */ + /* open the copied dataset NAME_DATASET_CHUNKED2 at destination */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the datasets are equal */ @@ -2786,9 +2785,9 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* set initial data values */ for(i = 0; i < DIM_SIZE_1; i++) { - buf1d[i] = (float)(i / 10.0F); + buf1d[i] = (float)i / 10.0F; for(j = 0; j < DIM_SIZE_2; j++) - buf2d[i][j] = (float)(i + (j / 100.0F)); + buf2d[i][j] = (float)i + ((float)j / 100.0F); } /* end for */ /* Initialize the filenames */ @@ -2836,6 +2835,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* Set 2-D dataspace dimensions */ dim2d[0]=DIM_SIZE_1; dim2d[1]=DIM_SIZE_2; @@ -2874,6 +2874,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR @@ -2906,6 +2907,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* close the source dataset */ if(H5Dclose(did) < 0) TEST_ERROR + /* open the dataset for copy */ if((did = H5Dopen2(fid_src, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2994,8 +2996,8 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ - dim2d[0]=DIM_SIZE_1; - dim2d[1]=DIM_SIZE_2; + dim2d[0] = DIM_SIZE_1; + dim2d[1] = DIM_SIZE_2; /* create dataspace */ if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR @@ -3110,7 +3112,7 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t /* set initial data values */ for (i=0; i Date: Thu, 17 Dec 2015 10:10:06 -0500 Subject: [svn-r28702] Description: Fix typo in comment. Tested on: (Unneeded) --- src/H5Aint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Aint.c b/src/H5Aint.c index baa352c..12ffb7d 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1878,7 +1878,7 @@ H5A_set_version(const H5F_t *f, H5A_t *attr) /* Check which version to encode attribute with */ if(use_latest_format) - attr->shared->version = H5O_ATTR_VERSION_LATEST; /* Write out latest version of format */ + attr->shared->version = H5O_ATTR_VERSION_LATEST; /* Write out latest attribute version */ else if(attr->shared->encoding != H5T_CSET_ASCII) attr->shared->version = H5O_ATTR_VERSION_3; /* Write version which includes the character encoding */ else if(type_shared || space_shared) -- cgit v0.12 From 9ceca0f89a0d27a6dfaeb3dd0cab2680281c5b60 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 19 Dec 2015 09:42:15 -0500 Subject: [svn-r28710] Description: Bring r28708 from revise_chunks branch: Fix earray, farray and btree2 use of incorrect file pointer when two files are opened and used to access the data structure. Misc. minor code cleanups as well. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel h5committest forthcoming --- src/H5B2.c | 30 +++------ src/H5B2dbg.c | 61 +++++------------ src/H5B2hdr.c | 83 +++++++++++++++++++++-- src/H5B2pkg.h | 4 ++ src/H5C.c | 93 ++++++++++---------------- src/H5EAhdr.c | 33 +++++----- src/H5FAhdr.c | 3 +- test/Makefile.am | 14 ++-- test/btree2.c | 182 +++++++++++++++++++++++++++++++++++++++++++------- test/dsets.c | 67 +++++++++---------- test/earray.c | 197 +++++++++++++++++++++++++++++++++++++++++++++++-------- test/farray.c | 163 +++++++++++++++++++++++++++++++++++++++++---- 12 files changed, 680 insertions(+), 250 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index 7eb88c4..a171917 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -134,7 +134,6 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ haddr_t hdr_addr; /* B-tree header address */ H5B2_t *ret_value = NULL; /* Return value */ @@ -158,11 +157,8 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "memory allocation failed for v2 B-tree info") /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__NO_FLAGS_SET))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, ctx_udata, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Point v2 B-tree wrapper at header and bump it's ref count */ bt2->hdr = hdr; @@ -180,7 +176,7 @@ H5B2_create(H5F_t *f, hid_t dxpl_id, const H5B2_create_t *cparam, void *ctx_udat ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -209,7 +205,6 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) { H5B2_t *bt2 = NULL; /* Pointer to the B-tree */ H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ H5B2_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -219,11 +214,8 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) HDassert(H5F_addr_defined(addr)); /* Look up the B-tree header */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load B-tree header") + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to protect v2 B-tree header") /* Check for pending heap deletion */ if(hdr->pending_delete) @@ -249,7 +241,7 @@ H5B2_open(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata) ret_value = bt2; done: - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, NULL, "unable to release v2 B-tree header") if(!ret_value && bt2) if(H5B2_close(bt2, dxpl_id) < 0) @@ -1282,7 +1274,7 @@ H5B2_close(H5B2_t *bt2, hid_t dxpl_id) /* Lock the v2 B-tree header into memory */ /* (OK to pass in NULL for callback context, since we know the header must be in the cache) */ - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(bt2->f, dxpl_id, H5AC_BT2_HDR, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(bt2->f, dxpl_id, bt2_addr, NULL, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set the shared v2 B-tree header's file context for this operation */ @@ -1344,7 +1336,6 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, H5B2_remove_t op, void *op_data) { H5B2_hdr_t *hdr = NULL; /* Pointer to the B-tree header */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1357,10 +1348,7 @@ H5B2_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *ctx_udata, #ifdef QAK HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); #endif /* QAK */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = ctx_udata; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__NO_FLAGS_SET))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, ctx_udata, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Remember the callback & context for later */ @@ -1382,7 +1370,7 @@ HDfprintf(stderr, "%s: addr = %a\n", FUNC, addr); done: /* Unprotect the header, if an error occurred */ - if(hdr && H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index ad9f970..73084d2 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -95,7 +95,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -114,19 +113,13 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, addr, &cache_udata, H5AC__READ_ONLY_FLAG))) + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -180,11 +173,8 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_debug() */ @@ -212,7 +202,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -239,14 +228,9 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -309,11 +293,8 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree internal node") @@ -340,7 +321,6 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ - H5B2_hdr_cache_ud_t cache_udata; /* User-data for callback */ void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ @@ -364,20 +344,14 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDassert(nrec > 0); /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { + if(type->crt_dbg_ctx) /* Create debugging context */ if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* - * Load the B-tree header. - */ - cache_udata.f = f; - cache_udata.addr = hdr_addr; - cache_udata.ctx_udata = dbg_ctx; - if(NULL == (hdr = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &cache_udata, H5AC__READ_ONLY_FLAG))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree header") + /* Load the B-tree header */ + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ hdr->f = f; @@ -423,11 +397,8 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent done: if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") - if(hdr) { - hdr->f = NULL; - if(H5AC_unprotect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, hdr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") - } /* end if */ + if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree leaf node") diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 16d8467..25ac141 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -209,10 +209,9 @@ HDmemset(hdr->page, 0, hdr->node_size); } /* end if */ /* Create the callback context, if the callback exists */ - if(hdr->cls->crt_context) { + if(hdr->cls->crt_context) if(NULL == (hdr->cb_ctx = (*hdr->cls->crt_context)(ctx_udata))) HGOTO_ERROR(H5E_BTREE, H5E_CANTCREATE, FAIL, "unable to create v2 B-tree client callback context") - } /* end if */ done: if(ret_value < 0) @@ -488,6 +487,82 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__hdr_protect + * + * Purpose: Convenience wrapper around protecting v2 B-tree header + * + * Return: Non-NULL pointer to header on success/NULL on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +H5B2_hdr_t * +H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, void *ctx_udata, + unsigned flags) +{ + H5B2_hdr_cache_ud_t udata; /* User data for cache callbacks */ + H5B2_hdr_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(f); + HDassert(H5F_addr_defined(hdr_addr)); + + /* only the H5AC__READ_ONLY_FLAG may appear in flags */ + HDassert((flags & (unsigned)(~H5AC__READ_ONLY_FLAG)) == 0); + + /* Set up user data for cache callbacks */ + udata.f = f; + udata.addr = hdr_addr; + udata.ctx_udata = ctx_udata; + + /* Protect the header */ + if(NULL == (ret_value = (H5B2_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_BT2_HDR, hdr_addr, &udata, flags))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, NULL, "unable to load v2 B-tree header, address = %llu", (unsigned long long)hdr_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_protect() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__hdr_unprotect + * + * Purpose: Convenience wrapper around unprotecting v2 B-tree header + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 18 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned cache_flags) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Sanity check */ + HDassert(hdr); + + /* Unprotect the header */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to unprotect v2 B-tree header, address = %llu", (unsigned long long)hdr->addr) + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5B2__hdr_unprotect() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__hdr_free * * Purpose: Free B-tree header info @@ -609,8 +684,8 @@ H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id) done: /* Unprotect the header with appropriate flags */ - if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_HDR, hdr->addr, hdr, cache_flags) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree header") + if(H5B2__hdr_unprotect(hdr, dxpl_id, cache_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release v2 B-tree header") FUNC_LEAVE_NOAPI(ret_value) } /* end H5B2__hdr_delete() */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index d661efa..f58850e 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -302,6 +302,10 @@ H5_DLL herr_t H5B2__hdr_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_fuse_incr(H5B2_hdr_t *hdr); H5_DLL size_t H5B2__hdr_fuse_decr(H5B2_hdr_t *hdr); H5_DLL herr_t H5B2__hdr_dirty(H5B2_hdr_t *hdr); +H5_DLL H5B2_hdr_t *H5B2__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t hdr_addr, + void *ctx_udata, unsigned flags); +H5_DLL herr_t H5B2__hdr_unprotect(H5B2_hdr_t *hdr, hid_t dxpl_id, + unsigned cache_flags); H5_DLL herr_t H5B2__hdr_delete(H5B2_hdr_t *hdr, hid_t dxpl_id); /* Routines for operating on leaf nodes */ diff --git a/src/H5C.c b/src/H5C.c index 2a4b4cf..c78c32c 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -2938,7 +2938,7 @@ done: ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || ( H5C_validate_lru_list(cache_ptr) < 0 ) ) { - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, \ "an extreme sanity check failed on exit.\n"); } #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -6802,7 +6802,7 @@ H5C_flush_invalidate_ring(const H5F_t * f, hid_t dxpl_id, H5C_ring_t ring, /* Get cache entry for this node */ next_entry_ptr = (H5C_cache_entry_t *)H5SL_item(node_ptr); - if ( NULL == next_entry_ptr ) + if(NULL == next_entry_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "next_entry_ptr == NULL ?!?!") HDassert(next_entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); @@ -7240,8 +7240,8 @@ H5C_flush_ring(H5F_t *f, hid_t dxpl_id, H5C_ring_t ring, unsigned flags) #if H5C_DO_EXTREME_SANITY_CHECKS if((H5C_validate_protected_entry_list(cache_ptr) < 0) || - (H5C_validate_pinned_entry_list(cache_ptr) < 0 || - (H5C_validate_lru_list(cache_ptr) < 0)) { + (H5C_validate_pinned_entry_list(cache_ptr) < 0) || + (H5C_validate_lru_list(cache_ptr) < 0)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on entry.\n"); #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ @@ -7604,7 +7604,7 @@ done: * * Refactored function to delay all modifications of the * metadata cache data structures until after any calls - * to the pre-serialize or serialize callbacks. + * to the pre-serialize or serialize callbacks. * * Need to do this, as some pre-serialize or serialize * calls result in calls to the metadata cache and @@ -7668,7 +7668,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ else destroy_entry = destroy; - /* we will write the entry to disk if it exists, is dirty, and if the + /* we will write the entry to disk if it exists, is dirty, and if the * clear only flag is not set. */ if(entry_ptr->is_dirty && !clear_only) @@ -8057,7 +8057,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ /* only log a flush if we actually wrote to disk */ H5C__UPDATE_STATS_FOR_FLUSH(cache_ptr, entry_ptr) - } + } /* end else if */ if(destroy) { if(take_ownership) @@ -8066,7 +8066,7 @@ H5C__flush_single_entry(const H5F_t *f, hid_t dxpl_id, H5C_cache_entry_t *entry_ HDassert(destroy_entry); H5C__UPDATE_STATS_FOR_EVICTION(cache_ptr, entry_ptr, take_ownership) - } + } /* end if */ /* If the entry's type has a 'notify' callback and the entry is about * to be removed from the cache, send a 'before eviction' notice while @@ -8306,12 +8306,12 @@ H5C_load_entry(H5F_t * f, /* verify absence of prohibited or unsupported type flag combinations */ HDassert(!(type->flags & H5C__CLASS_NO_IO_FLAG)); - + /* for now, we do not combine the speculative load and compressed flags */ HDassert(!((type->flags & H5C__CLASS_SPECULATIVE_LOAD_FLAG) && (type->flags & H5C__CLASS_COMPRESSED_FLAG))); - /* Can't see how skip reads could be usefully combined with + /* Can't see how skip reads could be usefully combined with * either the speculative read or compressed flags. Hence disallow. */ HDassert(!((type->flags & H5C__CLASS_SKIP_READS) && @@ -8433,12 +8433,10 @@ H5C_load_entry(H5F_t * f, } /* Allocate the buffer for reading the on-disk entry image */ if(NULL == (image = H5MM_malloc(len + H5C_IMAGE_EXTRA_SPACE))) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "memory allocation failed for on disk image buffer.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed for on disk image buffer.") #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(((uint8_t *)image) + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(image + len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /* Get the on-disk entry image */ @@ -8472,12 +8470,9 @@ H5C_load_entry(H5F_t * f, /* Get the actual image size for the thing */ if(type->image_len(thing, &new_len, &compressed, &compressed_size) < 0) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, \ - "can't retrieve image length") + HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, NULL, "can't retrieve image length") if(new_len == 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "image length is 0") HDassert(((type->flags & H5C__CLASS_COMPRESSED_FLAG) != 0) || @@ -8521,15 +8516,13 @@ H5C_load_entry(H5F_t * f, if(NULL == (new_image = H5MM_realloc(image, new_len + H5C_IMAGE_EXTRA_SPACE))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, \ - "image null after H5MM_realloc()") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "image null after H5MM_realloc()") image = new_image; #if H5C_DO_MEMORY_SANITY_CHECKS - HDmemcpy(((uint8_t *)image) + new_len, - H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); + HDmemcpy(((uint8_t *)image) + new_len, H5C_IMAGE_SANITY_VALUE, H5C_IMAGE_EXTRA_SPACE); #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ @@ -8550,15 +8543,13 @@ H5C_load_entry(H5F_t * f, if ( type->free_icr(thing) < 0 ) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, \ - "free_icr callback failed") + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "free_icr callback failed") /* Go get the on-disk image again */ if(H5F_block_read(f, type->mem_type, addr, new_len, dxpl_id, image) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \ - "Can't read image") + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't read image") /* Deserialize on-disk image into native memory * form again @@ -8621,7 +8612,7 @@ H5C_load_entry(H5F_t * f, * * HDassert( ( dirty == FALSE ) || ( type->id == 5 || type->id == 6 ) ); * - * note that type ids 5 & 6 are associated with object headers in the + * note that type ids 5 & 6 are associated with object headers in the * metadata cache. * * When we get to using H5C for other purposes, we may wish to @@ -8824,8 +8815,8 @@ H5C_make_space_in_cache(H5F_t * f, ( entry_ptr != NULL ) ) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); - HDassert( ! (entry_ptr->is_protected) ); + HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); + HDassert( !(entry_ptr->is_protected) ); HDassert( ! (entry_ptr->is_read_only) ); HDassert( (entry_ptr->ro_ref_count) == 0 ); @@ -8857,8 +8848,8 @@ H5C_make_space_in_cache(H5F_t * f, * last_entry_removed_ptr prior to the call to * H5C__flush_single_entry() so that we can spot * unexpected removals of entries from the cache, - * and set the restart_scan flag if proceeding - * would be likely to cause us to scan an entry + * and set the restart_scan flag if proceeding + * would be likely to cause us to scan an entry * that is no longer in the cache. */ cache_ptr->entries_removed_counter = 0; @@ -8881,7 +8872,6 @@ H5C_make_space_in_cache(H5F_t * f, if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush entry") - } else { /* We have enough space so don't flush clean entry. */ #if H5C_COLLECT_CACHE_STATS @@ -8906,15 +8896,15 @@ H5C_make_space_in_cache(H5F_t * f, if ( didnt_flush_entry ) { - /* epoch markers don't get flushed, and we don't touch + /* epoch markers don't get flushed, and we don't touch * entries that are in the process of being flushed. - * Hence no need for sanity checks, as we haven't - * flushed anything. Thus just set entry_ptr to prev_ptr + * Hence no need for sanity checks, as we haven't + * flushed anything. Thus just set entry_ptr to prev_ptr * and go on. */ entry_ptr = prev_ptr; - } else if ( ( restart_scan ) + } else if ( ( restart_scan ) || ( prev_ptr->is_dirty != prev_is_dirty ) || @@ -9084,10 +9074,8 @@ H5C_validate_lru_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->LRU_list_len < 0 ) || ( cache_ptr->LRU_list_size < 0 ) ) { - + if(cache_ptr->LRU_list_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->LRU_list_len == 1 ) && @@ -9214,10 +9202,8 @@ H5C_validate_pinned_entry_list(H5C_t * cache_ptr) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") } - if ( ( cache_ptr->pel_len < 0 ) || ( cache_ptr->pel_size < 0 ) ) { - + if(cache_ptr->pel_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pel_len == 1 ) && @@ -9337,21 +9323,12 @@ H5C_validate_protected_entry_list(H5C_t * cache_ptr) HDassert( cache_ptr ); HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC ); - if ( ( ( cache_ptr->pl_head_ptr == NULL ) - || - ( cache_ptr->pl_tail_ptr == NULL ) - ) - && - ( cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr ) - ) { - + if(((cache_ptr->pl_head_ptr == NULL) || (cache_ptr->pl_tail_ptr == NULL)) + && (cache_ptr->pl_head_ptr != cache_ptr->pl_tail_ptr)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 1 failed") - } - - if ( ( cache_ptr->pl_len < 0 ) || ( cache_ptr->pl_size < 0 ) ) { + if(cache_ptr->pl_len < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Check 2 failed") - } if ( ( cache_ptr->pl_len == 1 ) && @@ -9682,7 +9659,7 @@ done: * Function: H5C_ignore_tags * * Purpose: Override all assertion frameworks associated with making - * sure proper tags are applied to metadata. + * sure proper tags are applied to cache entries. * * NOTE: This should really only be used in tests that need * to access internal functions without going through @@ -9794,7 +9771,7 @@ done: * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * August 19, 2010 * *------------------------------------------------------------------------- */ @@ -9837,7 +9814,7 @@ done: * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * September 9, 2010 * *------------------------------------------------------------------------- */ @@ -9883,7 +9860,7 @@ H5C_mark_tagged_entries(H5C_t * cache_ptr, haddr_t tag) * Return: FAIL if error is detected, SUCCEED otherwise. * * Programmer: Mike McGreevy - * November 3, 2009 + * November 3, 2010 * *------------------------------------------------------------------------- */ diff --git a/src/H5EAhdr.c b/src/H5EAhdr.c index eff4b54..da15087 100644 --- a/src/H5EAhdr.c +++ b/src/H5EAhdr.c @@ -43,7 +43,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5EApkg.h" /* Extensible Arrays */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ @@ -128,7 +128,7 @@ H5EA__hdr_alloc(H5F_t *f)) /* Allocate space for the shared information */ if(NULL == (hdr = H5FL_CALLOC(H5EA_hdr_t))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set non-zero internal fields */ hdr->addr = HADDR_UNDEF; @@ -390,35 +390,35 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Check for valid parameters */ if(cparam->raw_elmt_size == 0) - H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") + H5E_THROW(H5E_BADVALUE, "element size must be greater than zero") if(cparam->max_nelmts_bits == 0) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be greater than zero") if(cparam->max_nelmts_bits > H5EA_MAX_NELMTS_IDX_MAX) - H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX) + H5E_THROW(H5E_BADVALUE, "max. # of elements bits must be <= %u", (unsigned)H5EA_MAX_NELMTS_IDX_MAX) if(cparam->sup_blk_min_data_ptrs < 2) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be >= two") if(!POWER_OF_TWO(cparam->sup_blk_min_data_ptrs)) - H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") + H5E_THROW(H5E_BADVALUE, "min # of data block pointers in super block must be power of two") if(!POWER_OF_TWO(cparam->data_blk_min_elmts)) - H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") + H5E_THROW(H5E_BADVALUE, "min # of elements per data block must be power of two") dblk_page_nelmts = (size_t)1 << cparam->max_dblk_page_nelmts_bits; if(dblk_page_nelmts < cparam->idx_blk_elmts) - H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block") + H5E_THROW(H5E_BADVALUE, "# of elements per data block page must be greater than # of elements in index block") /* Compute the number of elements in data blocks for first actual super block */ sblk_idx = H5EA_SBLK_FIRST_IDX(cparam->sup_blk_min_data_ptrs); dblk_nelmts = H5EA_SBLK_DBLK_NELMTS(sblk_idx, cparam->data_blk_min_elmts); if(dblk_page_nelmts < dblk_nelmts) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block") + H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be > # of elements in first data block from super block") if(cparam->max_dblk_page_nelmts_bits > cparam->max_nelmts_bits) - H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits") + H5E_THROW(H5E_BADVALUE, "max. # of elements per data block page bits must be <= max. # of elements bits") } #endif /* NDEBUG */ /* Allocate space for the shared information */ if(NULL == (hdr = H5EA__hdr_alloc(f))) - H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") + H5E_THROW(H5E_CANTALLOC, "memory allocation failed for extensible array shared header") /* Set the internal parameters for the array */ hdr->idx_blk_addr = HADDR_UNDEF; @@ -428,15 +428,15 @@ HDfprintf(stderr, "%s: Called\n", FUNC); /* Finish initializing extensible array header */ if(H5EA__hdr_init(hdr, ctx_udata) < 0) - H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") + H5E_THROW(H5E_CANTINIT, "initialization failed for extensible array header") /* Allocate space for the header on disk */ if(HADDR_UNDEF == (hdr->addr = H5MF_alloc(f, H5FD_MEM_EARRAY_HDR, dxpl_id, (hsize_t)hdr->size))) - H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") + H5E_THROW(H5E_CANTALLOC, "file allocation failed for extensible array header") /* Cache the new extensible array header */ if(H5AC_insert_entry(f, dxpl_id, H5AC_EARRAY_HDR, hdr->addr, hdr, H5AC__NO_FLAGS_SET) < 0) - H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") + H5E_THROW(H5E_CANTINSERT, "can't add extensible array header to cache") /* Set address of array header to return */ ret_value = hdr->addr; @@ -616,7 +616,7 @@ END_FUNC(PKG) /* end H5EA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting extensible array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -647,6 +647,7 @@ H5EA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t ea_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5EA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_EARRAY_HDR, ea_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect extensible array header, address = %llu", (unsigned long long)ea_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/src/H5FAhdr.c b/src/H5FAhdr.c index 62b1837..ac9a103 100644 --- a/src/H5FAhdr.c +++ b/src/H5FAhdr.c @@ -397,7 +397,7 @@ END_FUNC(PKG) /* end H5FA__hdr_modified() */ * * Purpose: Convenience wrapper around protecting fixed array header * - * Return: Non-NULL pointer to index block on success/NULL on failure + * Return: Non-NULL pointer to header on success/NULL on failure * * Programmer: Quincey Koziol * koziol@hdfgroup.org @@ -428,6 +428,7 @@ H5FA__hdr_protect(H5F_t *f, hid_t dxpl_id, haddr_t fa_addr, void *ctx_udata, /* Protect the header */ if(NULL == (ret_value = (H5FA_hdr_t *)H5AC_protect(f, dxpl_id, H5AC_FARRAY_HDR, fa_addr, &udata, flags))) H5E_THROW(H5E_CANTPROTECT, "unable to protect fixed array header, address = %llu", (unsigned long long)fa_addr) + ret_value->f = f; /* (Must be set again here, in case the header was already in the cache -QAK) */ CATCH diff --git a/test/Makefile.am b/test/Makefile.am index d9c53d4..8389cc4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -37,16 +37,14 @@ check_SCRIPTS = $(TEST_SCRIPT) # executed, generally most specific tests to least specific tests. # As an exception, long-running tests should occur earlier in the list. # This gives them more time to run when tests are executing in parallel. -# These tests (fheap, btree2) are under development and are not used by -# the library yet. Move them to the end so that their failure do not block -# other current library code tests. -TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ +TEST_PROG= testhdf5 cache cache_api cache_tagging lheap ohdr stab gheap \ + farray earray btree2 fheap \ pool accum hyperslab istore bittests dt_arith \ dtypes dsets cmpd_dset filter_fail extend external efc objcopy links unlink \ big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe enc_dec_plist enc_dec_plist_cross_platform\ getname vfd ntypes dangle dtransform reserved cross_read \ - freespace mf vds farray earray btree2 fheap file_image unregister + freespace mf vds file_image unregister # List programs to be built when testing here. error_test and err_compat are # built at the same time as the other tests, but executed by testerror.sh. @@ -145,9 +143,9 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse multi_file-[rs].h5 core_file plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ - objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log \ + unlink_chunked.h5 btree2.h5 btree2_tmp.h5 objcopy_src.h5 objcopy_dst.h5 \ + objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 farray_tmp.h5 \ + earray.h5 earray_tmp.h5 efc[0-5].h5 log_vfd_out.log \ new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ file_image_core_test.h5.copy unregister_filter_1.h5 unregister_filter_2.h5 \ diff --git a/test/btree2.c b/test/btree2.c index 8f84135..7a2432c 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -31,6 +31,7 @@ const char *FILENAME[] = { "btree2", + "btree2_tmp", NULL }; @@ -108,9 +109,8 @@ create_file(hid_t *file, H5F_t **f, hid_t fapl) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) STACK_ERROR - } /* Success */ return(0); @@ -2810,9 +2810,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -2849,9 +2848,8 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -4909,7 +4907,7 @@ test_remove_level1_collapse(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ ninfo.depth = 0; - ninfo.nrec = INSERT_SPLIT_ROOT_NREC - u; + ninfo.nrec = (uint16_t)(INSERT_SPLIT_ROOT_NREC - u); record = 31; /* Middle record in root node */ if(check_node_info(bt2, dxpl, record, &ninfo) < 0) TEST_ERROR @@ -6379,9 +6377,8 @@ gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam, STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, bt2_addr) < 0) @@ -6535,9 +6532,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-shuffle record #'s */ for(u = 0; u < INSERT_MANY; u++) { @@ -6631,9 +6627,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -6720,9 +6715,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -6806,9 +6800,8 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -7157,9 +7150,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7202,9 +7194,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7260,9 +7251,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7318,9 +7308,8 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) { + if(H5AC_ignore_tags(f) < 0) STACK_ERROR - } /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) @@ -7605,6 +7594,146 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a v2 B-tree twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first B-tree's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, const H5B2_create_t *cparam) +{ + char filename[1024]; /* Filename to use */ + char filename_tmp[1024]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + H5B2_t *bt2_2 = NULL; /* Second v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* + * Display testing message + */ + TESTING("open B-tree twice, through different file handles"); + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + FAIL_STACK_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Re-open v2 B-tree */ + if(NULL == (bt2_2 = H5B2_open(f, dxpl, bt2_addr, f))) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree wrapper */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Close the first v2 B-tree wrapper */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close the file */ + /* (close before second file, to detect error on internal B-tree header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Re-open the file with the v2 B-tree array */ + if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the B-tree through the second file handle */ + if(NULL == (bt2_2 = H5B2_open(f2, dxpl, bt2_addr, f2))) + FAIL_STACK_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close the second v2 B-tree */ + if(H5B2_close(bt2_2, dxpl) < 0) + FAIL_STACK_ERROR + bt2_2 = NULL; + + /* Close file */ + if(H5Fclose(file2) < 0) + FAIL_STACK_ERROR + + /* All tests passed */ + PASSED(); + + /* All tests passed */ + return(0); + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + if(bt2) + H5B2_close(bt2_2, dxpl); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + return(1); +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test the B-tree v2 code @@ -7712,6 +7841,9 @@ main(void) nerrors += test_modify(fapl, &cparam, &tparam); } /* end for */ + /* Test opening B-trees twice */ + nerrors += test_open_twice_diff(fapl, &cparam); + /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); diff --git a/test/dsets.c b/test/dsets.c index c0e8702..a9cda93 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -388,14 +388,14 @@ test_create(hid_t file) static herr_t test_simple_io(const char *env_h5_drvr, hid_t fapl) { - char filename[FILENAME_BUF_SIZE]; - hid_t file = -1, dataset = -1, space = -1, xfer = -1; - int i, j, n; - hsize_t dims[2]; - void *tconv_buf = NULL; - int f = -1; - haddr_t offset; - int rdata[DSET_DIM1][DSET_DIM2]; + char filename[FILENAME_BUF_SIZE]; + hid_t file = -1, dataset = -1, space = -1, xfer = -1; + int i, j, n; + hsize_t dims[2]; + void *tconv_buf = NULL; + int f = -1; + haddr_t offset; + int rdata[DSET_DIM1][DSET_DIM2]; TESTING("simple I/O"); @@ -465,7 +465,8 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) f = HDopen(filename, O_RDONLY, 0); HDlseek(f, (off_t)offset, SEEK_SET); - HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2); + if(HDread(f, rdata, sizeof(int)*DSET_DIM1*DSET_DIM2) < 0) + goto error; /* Check that the values read are the same as the values written */ for(i = 0; i < DSET_DIM1; i++) { @@ -6702,7 +6703,7 @@ test_random_chunks(hid_t fapl) if(H5Fclose(file) < 0) TEST_ERROR; - /* Create file for second test */ + /* Create second file */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR; /* Create dataspace with unlimited maximum dimensions */ @@ -7474,7 +7475,7 @@ test_big_chunks_bypass_cache(hid_t fapl) if(H5Dread(dsid, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rdata2) < 0) for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) - if(rdata2[i] != i) { + if(rdata2[i] != i) { printf(" Read different values than written in the chunk.\n"); printf(" At line %d and index %d, rdata2 = %d. It should be %d.\n", __LINE__, i, rdata2[i], i); TEST_ERROR @@ -9145,38 +9146,38 @@ main(void) nerrors += (test_simple_io(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_compact_io(my_fapl) < 0 ? 1 : 0); nerrors += (test_max_compact(my_fapl) < 0 ? 1 : 0); - nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); + nerrors += (test_conv_buffer(file) < 0 ? 1 : 0); nerrors += (test_tconv(file) < 0 ? 1 : 0); nerrors += (test_filters(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_onebyte_shuffle(file) < 0 ? 1 : 0); - nerrors += (test_nbit_int(file) < 0 ? 1 : 0); - nerrors += (test_nbit_float(file) < 0 ? 1 : 0); - nerrors += (test_nbit_double(file) < 0 ? 1 : 0); - nerrors += (test_nbit_array(file) < 0 ? 1 : 0); + nerrors += (test_nbit_int(file) < 0 ? 1 : 0); + nerrors += (test_nbit_float(file) < 0 ? 1 : 0); + nerrors += (test_nbit_double(file) < 0 ? 1 : 0); + nerrors += (test_nbit_array(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_2(file) < 0 ? 1 : 0); nerrors += (test_nbit_compound_3(file) < 0 ? 1 : 0); nerrors += (test_nbit_int_size(file) < 0 ? 1 : 0); nerrors += (test_nbit_flt_size(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_int(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); - nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_int_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_float_2(file) < 0 ? 1 : 0); + nerrors += (test_scaleoffset_double(file) < 0 ? 1 : 0); nerrors += (test_scaleoffset_double_2(file) < 0 ? 1 : 0); - nerrors += (test_multiopen (file) < 0 ? 1 : 0); - nerrors += (test_types(file) < 0 ? 1 : 0); - nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); + nerrors += (test_multiopen (file) < 0 ? 1 : 0); + nerrors += (test_types(file) < 0 ? 1 : 0); + nerrors += (test_userblock_offset(envval, my_fapl) < 0 ? 1 : 0); nerrors += (test_missing_filter(file) < 0 ? 1 : 0); - nerrors += (test_can_apply(file) < 0 ? 1 : 0); - nerrors += (test_can_apply2(file) < 0 ? 1 : 0); - nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); + nerrors += (test_can_apply(file) < 0 ? 1 : 0); + nerrors += (test_can_apply2(file) < 0 ? 1 : 0); + nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0); nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0); - nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); - nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); + nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0); + nerrors += (test_copy_dcpl(file, my_fapl) < 0 ? 1 : 0); nerrors += (test_filter_delete(file) < 0 ? 1 : 0); - nerrors += (test_filters_endianess() < 0 ? 1 : 0); - nerrors += (test_zero_dims(file) < 0 ? 1 : 0); + nerrors += (test_filters_endianess() < 0 ? 1 : 0); + nerrors += (test_zero_dims(file) < 0 ? 1 : 0); nerrors += (test_missing_chunk(file) < 0 ? 1 : 0); nerrors += (test_random_chunks(my_fapl) < 0 ? 1 : 0); #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -9186,9 +9187,9 @@ main(void) nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_big_chunks_bypass_cache(my_fapl) < 0 ? 1 : 0); nerrors += (test_chunk_expand(my_fapl) < 0 ? 1 : 0); - nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); - nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); - nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); + nerrors += (test_layout_extend(my_fapl) < 0 ? 1 : 0); + nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); + nerrors += (test_zero_dim_dset(my_fapl) < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; diff --git a/test/earray.c b/test/earray.c index 368ee42..95733e9 100644 --- a/test/earray.c +++ b/test/earray.c @@ -185,6 +185,7 @@ static herr_t earray_cache_test_free_icr(void *thing); /* Local variables */ const char *FILENAME[] = { "earray", + "earray_tmp", NULL }; @@ -332,10 +333,10 @@ finish_tparam(earray_test_param_t *tparam) *------------------------------------------------------------------------- */ static int -create_file(hid_t fapl, hid_t *file, H5F_t **f) +create_file(unsigned flags, hid_t fapl, hid_t *file, H5F_t **f) { /* Create the file to work on */ - if((*file = H5Fcreate(filename_g, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + if((*file = H5Fcreate(filename_g, flags, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ @@ -343,9 +344,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -454,17 +454,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(ea) { + if(ea && *ea) { if(H5EA_close(*ea, dxpl) < 0) FAIL_STACK_ERROR *ea = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -475,15 +477,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(ea) { + if(ea) if(NULL == (*ea = H5EA_open(*f, dxpl, ea_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -893,7 +893,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1008,7 +1008,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE /* Set invalid max. # of elements per data block page bits */ if(test_cparam.idx_blk_elmts > 0) { HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(H5VM_log2_gen((uint64_t)test_cparam.idx_blk_elmts) - 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1035,7 +1035,7 @@ test_create(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR_UNUSE TEST_ERROR } /* end if */ HDmemcpy(&test_cparam, cparam, sizeof(test_cparam)); - test_cparam.max_dblk_page_nelmts_bits = test_cparam.max_nelmts_bits + 1; + test_cparam.max_dblk_page_nelmts_bits = (uint8_t)(test_cparam.max_nelmts_bits + 1); H5E_BEGIN_TRY { ea = H5EA_create(f, H5P_DATASET_XFER_DEFAULT, &test_cparam, NULL); } H5E_END_TRY; @@ -1115,7 +1115,7 @@ test_reopen(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1188,7 +1188,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1271,6 +1271,148 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open an extensible array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first extensible array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) +{ + char filename_tmp[EARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5EA_t *ea = NULL; /* Extensible array wrapper */ + H5EA_t *ea2 = NULL; /* Extensible array wrapper */ + haddr_t ea_addr = HADDR_UNDEF; /* Array address in file */ + + /* Create file & retrieve pointer to internal file object */ + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) + TEST_ERROR + + /* + * Display testing message + */ + TESTING("open extensible array twice, through different file handles"); + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &ea, &ea_addr, NULL) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (ea2 = H5EA_open(f, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the second extensible array wrapper */ + if(H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &ea, ea_addr, tparam) < 0) + TEST_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea, cparam) < 0) + TEST_ERROR + + /* Close the first extensible array wrapper */ + if(H5EA_close(ea, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + ea = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the extensible array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the extensible array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the extensible array through the second file handle */ + if(NULL == (ea2 = H5EA_open(f2, H5P_DATASET_XFER_DEFAULT, ea_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(ea2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, ea2, ea_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(ea) + H5EA_close(ea, H5P_DATASET_XFER_DEFAULT); + if(ea2) + H5EA_close(ea2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened extensible array (& open deleted array) @@ -1294,7 +1436,7 @@ test_delete_open(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) h5_stat_size_t file_size; /* File size, after deleting array */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1483,7 +1625,7 @@ test_flush_depend(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t H5_ATTR hsize_t idx; /* Index value of element */ /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* @@ -1758,7 +1900,7 @@ eiter_fw_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_fw_max(const void *_eiter) { const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter; @@ -1976,7 +2118,7 @@ eiter_rv_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rv_max(const void *_eiter) { const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter; @@ -2228,7 +2370,7 @@ eiter_rnd_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_rnd_max(const void *_eiter) { const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter; @@ -2449,7 +2591,7 @@ eiter_cyc_next(void *_eiter) * *------------------------------------------------------------------------- */ -static hssize_t +static H5_ATTR_PURE hssize_t eiter_cyc_max(const void *_eiter) { const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter; @@ -2537,7 +2679,7 @@ test_set_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING(test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ @@ -2711,7 +2853,7 @@ test_skip_elmts(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam, TESTING(test_str); /* Create file & retrieve pointer to internal file object */ - if(create_file(fapl, &file, &f) < 0) + if(create_file(H5F_ACC_TRUNC, fapl, &file, &f) < 0) TEST_ERROR /* Create array */ @@ -2871,7 +3013,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -2922,6 +3064,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); nerrors += test_flush_depend(fapl, &cparam, &tparam); diff --git a/test/farray.c b/test/farray.c index e3e59da..50a9856 100644 --- a/test/farray.c +++ b/test/farray.c @@ -102,6 +102,7 @@ struct farray_test_param_t { /* Local variables */ const char *FILENAME[] = { "farray", + "farray_tmp", NULL }; @@ -159,9 +160,8 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Success */ return(0); @@ -274,17 +274,19 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, /* (actually will close & re-open the file as well) */ if(tparam->reopen_array) { /* Close array, if given */ - if(fa) { + if(fa && *fa) { if(H5FA_close(*fa, dxpl) < 0) FAIL_STACK_ERROR *fa = NULL; } /* end if */ /* Close file */ - if(H5Fclose(*file) < 0) - FAIL_STACK_ERROR - *file = (-1); - *f = NULL; + if(*file) { + if(H5Fclose(*file) < 0) + FAIL_STACK_ERROR + *file = (-1); + *f = NULL; + } /* end if */ /* Re-open the file */ if((*file = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) @@ -295,15 +297,13 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(*f) < 0) { + if(H5AC_ignore_tags(*f) < 0) FAIL_STACK_ERROR - } /* Re-open array, if given */ - if(fa) { + if(fa) if(NULL == (*fa = H5FA_open(*f, dxpl, fa_addr, NULL))) FAIL_STACK_ERROR - } /* end if */ } /* end if */ /* Success */ @@ -722,6 +722,144 @@ error: /*------------------------------------------------------------------------- + * Function: test_open_twice_diff + * + * Purpose: Open a fixed array twice, through different "top" file + * handles, with an intermediate file open that takes the "shared" + * file handle from the first fixed array's file pointer. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 18, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_open_twice_diff(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) +{ + char filename_tmp[FARRAY_FILENAME_LEN]; /* Temporary file name */ + hid_t file = -1; /* File ID */ + hid_t file2 = -1; /* File ID */ + hid_t file0 = -1; /* File ID */ + hid_t file00 = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5F_t *f2 = NULL; /* Internal file object pointer */ + H5FA_t *fa = NULL; /* Fixed array wrapper */ + H5FA_t *fa2 = NULL; /* Fixed array wrapper */ + haddr_t fa_addr = HADDR_UNDEF; /* Array address in file */ + + /* + * Display testing message + */ + TESTING("open fixed array twice, through different file handles"); + + /* Create file & retrieve pointer to internal file object */ + if(create_file(fapl, &file, &f) < 0) + TEST_ERROR + + /* Create array */ + if(create_array(f, H5P_DATASET_XFER_DEFAULT, cparam, &fa, &fa_addr) < 0) + TEST_ERROR + + /* Open the array again, through the first file handle */ + if(NULL == (fa2 = H5FA_open(f, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa, cparam) < 0) + TEST_ERROR + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the second fixed array wrapper */ + if(H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa2 = NULL; + + /* Re-open the file */ + /* (So that there is something holding the file open when the extensible + * array is closed) + */ + if((file0 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the file */ + if(reopen_file(&file, &f, fapl, H5P_DATASET_XFER_DEFAULT, &fa, fa_addr, tparam) < 0) + TEST_ERROR + + /* Close the first fixed array wrapper */ + if(H5FA_close(fa, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + fa = NULL; + + /* Close the first file */ + /* (close before second file, to detect error on internal array header's + * shared file information) + */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = -1; + + /* Open a different file */ + /* (This re-allocates the 'top' file pointer and assigns it a different + * 'shared' file pointer, making the file pointer in the fixed array's + * header stale) + */ + h5_fixname(FILENAME[1], fapl, filename_tmp, sizeof(filename_tmp)); + if((file00 = H5Fcreate(filename_tmp, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file with the fixed array */ + if((file2 = H5Fopen(filename_g, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Open the fixed array through the second file handle */ + if(NULL == (fa2 = H5FA_open(f2, H5P_DATASET_XFER_DEFAULT, fa_addr, NULL))) + FAIL_STACK_ERROR + + /* Verify the creation parameters */ + if(verify_cparam(fa2, cparam) < 0) + TEST_ERROR + + /* Close the extra file handles */ + if(H5Fclose(file0) < 0) + FAIL_STACK_ERROR + if(H5Fclose(file00) < 0) + FAIL_STACK_ERROR + + /* Close array, delete array, close file & verify file is empty */ + if(finish(file2, fapl, f2, fa2, fa_addr) < 0) + TEST_ERROR + + /* All tests passed */ + PASSED() + + return 0; + +error: + H5E_BEGIN_TRY { + if(fa) + H5FA_close(fa, H5P_DATASET_XFER_DEFAULT); + if(fa2) + H5FA_close(fa2, H5P_DATASET_XFER_DEFAULT); + H5Fclose(file); + H5Fclose(file2); + H5Fclose(file0); + H5Fclose(file00); + } H5E_END_TRY; + + return 1; +} /* test_open_twice_diff() */ + + +/*------------------------------------------------------------------------- * Function: test_delete_open * * Purpose: Delete opened fixed array (& open deleted array) @@ -1535,7 +1673,7 @@ main(void) /* Seed random #'s */ curr_time = HDtime(NULL); - HDsrandom((unsigned long)curr_time); + HDsrandom((unsigned)curr_time); /* Create an empty file to retrieve size */ { @@ -1586,6 +1724,7 @@ main(void) nerrors += test_create(fapl, &cparam, &tparam); nerrors += test_reopen(fapl, &cparam, &tparam); nerrors += test_open_twice(fapl, &cparam, &tparam); + nerrors += test_open_twice_diff(fapl, &cparam, &tparam); nerrors += test_delete_open(fapl, &cparam, &tparam); /* Iterate over the type of capacity tests */ -- cgit v0.12 From 4a25e5b788b6264eaed93de45a55a333b204a037 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 21 Dec 2015 17:22:55 -0500 Subject: [svn-r28717] Description: Minor change to align w/revise_chunks branch Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (too minor for h5committest) --- src/H5Dchunk.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index ab621ca..efd94c0 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1885,6 +1885,9 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, void *chunk = NULL; /* Pointer to locked chunk buffer */ htri_t cacheable; /* Whether the chunk is cacheable */ + /* Set chunk's [scaled] coordinates */ + io_info->store->chunk.scaled = chunk_info->scaled; + /* Determine if we should use the chunk cache */ if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") @@ -1895,9 +1898,6 @@ H5D__chunk_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, H5_CHECK_OVERFLOW(type_info->src_type_size, /*From:*/ size_t, /*To:*/ uint32_t); src_accessed_bytes = chunk_info->chunk_points * (uint32_t)type_info->src_type_size; - /* Set chunk's [scaled] coordinates */ - io_info->store->chunk.scaled = chunk_info->scaled; - /* Lock the chunk into the cache */ if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, FALSE))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") @@ -2011,6 +2011,9 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert((H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length > 0) || (!H5F_addr_defined(udata.chunk_block.offset) && udata.chunk_block.length == 0)); + /* Set chunk's [scaled] coordinates */ + io_info->store->chunk.scaled = chunk_info->scaled; + /* Determine if we should use the chunk cache */ if((cacheable = H5D__chunk_cacheable(io_info, udata.chunk_block.offset, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't tell if chunk is cacheable") @@ -2029,9 +2032,6 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, fm->fsel_type == H5S_SEL_POINTS) entire_chunk = FALSE; - /* Set chunk's [scaled] coordinates */ - io_info->store->chunk.scaled = chunk_info->scaled; - /* Lock the chunk into the cache */ if(NULL == (chunk = H5D__chunk_lock(io_info, &udata, entire_chunk))) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "unable to read raw data chunk") @@ -3684,9 +3684,6 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, } /* end if */ /* Insert the chunk record into the index */ - /* (Note that this isn't safe, from a SWMR perspective, unlike - * serial operation. -QAK - */ if(need_insert && ops->insert) if((ops->insert)(&idx_info, &udata, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert chunk addr into index") -- cgit v0.12 From 6f83966fb9709ebd30e41d70f1bfd36ddce79636 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 22 Dec 2015 15:12:08 -0500 Subject: [svn-r28723] Description: Bring over rest of performance improvements for extending chunked datasets and normalize against revise_chunks branch. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel) (h5committest forthcoming) --- src/H5Dchunk.c | 184 ++++++++++++++++++++++++++++++++++++++++++------------- src/H5Dint.c | 5 ++ src/H5Dlayout.c | 6 +- src/H5Dpkg.h | 9 ++- src/H5Oprivate.h | 4 ++ src/H5Pdcpl.c | 38 ++++++++---- 6 files changed, 187 insertions(+), 59 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index efd94c0..2e000e3 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -72,6 +72,10 @@ #define H5D_CHUNK_GET_NODE_INFO(map, node) (map->use_single ? map->single_chunk_info : (H5D_chunk_info_t *)H5SL_item(node)) #define H5D_CHUNK_GET_NEXT_NODE(map, node) (map->use_single ? (H5SL_node_t *)NULL : H5SL_next(node)) +/* Sanity check on chunk index types: commonly used by a lot of routines in this file */ +#define H5D_CHUNK_STORAGE_INDEX_CHK(storage) \ + HDassert((H5D_CHUNK_IDX_BTREE == storage->idx_type && H5D_COPS_BTREE == storage->ops)); + /* * Feature: If this constant is defined then every cache preemption and load * causes a character to be printed on the standard error stream: @@ -215,7 +219,7 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, /* Helper routines */ static herr_t H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, - const hsize_t *curr_dims); + const hsize_t *curr_dims, const hsize_t *max_dims); static void *H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline); static void *H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline); static void *H5D__chunk_mem_realloc(void *chk, size_t size, @@ -244,7 +248,8 @@ static herr_t H5D__chunk_cache_prune(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, size_t size); static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata); static herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, - const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert); + const H5F_block_t *old_chunk, H5F_block_t *new_chunk, hbool_t *need_insert, + hsize_t scaled[]); #ifdef H5_HAVE_PARALLEL static herr_t H5D__chunk_collective_fill(const H5D_t *dset, hid_t dxpl_id, H5D_chunk_coll_info_t *chunk_info, size_t chunk_size, const void *fill_buf); @@ -377,7 +382,7 @@ H5D__chunk_direct_write(const H5D_t *dset, hid_t dxpl_id, uint32_t filters, /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, &old_chunk, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate chunk") /* Make sure the address of the chunk is returned. */ @@ -430,7 +435,8 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims) +H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, + const hsize_t *curr_dims, const hsize_t *max_dims) { unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -443,17 +449,21 @@ H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize HDassert(curr_dims); /* Compute the # of chunks in dataset dimensions */ - for(u = 0, layout->nchunks = 1; u < ndims; u++) { + for(u = 0, layout->nchunks = 1, layout->max_nchunks = 1; u < ndims; u++) { /* Round up to the next integer # of chunks, to accomodate partial chunks */ layout->chunks[u] = ((curr_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; + layout->max_chunks[u] = ((max_dims[u] + layout->dim[u]) - 1) / layout->dim[u]; /* Accumulate the # of chunks */ layout->nchunks *= layout->chunks[u]; + layout->max_nchunks *= layout->max_chunks[u]; } /* end for */ /* Get the "down" sizes for each dimension */ if(H5VM_array_down(ndims, layout->chunks, layout->down_chunks) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") + if(H5VM_array_down(ndims, layout->max_chunks, layout->max_down_chunks) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't compute 'down' chunk size value") done: FUNC_LEAVE_NOAPI(ret_value) @@ -483,7 +493,7 @@ H5D__chunk_set_info(const H5D_t *dset) HDassert(dset); /* Set the base layout information */ - if(H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims) < 0) + if(H5D__chunk_set_info_real(&dset->shared->layout.u.chunk, dset->shared->ndims, dset->shared->curr_dims, dset->shared->max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") /* Call the index's "resize" callback */ @@ -596,6 +606,7 @@ H5D__chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ H5P_genplist_t *dapl; /* Data access property list object pointer */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -603,6 +614,7 @@ H5D__chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, hid_t dapl_id) /* Sanity check */ HDassert(f); HDassert(dset); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID") @@ -686,12 +698,14 @@ done: hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage) { + const H5O_storage_chunk_t *sc = &(storage->u.chunk); hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR /* Sanity checks */ HDassert(storage); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Query index layer */ ret_value = (storage->u.chunk.ops->is_space_alloc)(&storage->u.chunk); @@ -1343,6 +1357,9 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); new_chunk_info->scaled[fm->f_ndims] = 0; + /* Copy the chunk's scaled coordinates */ + HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); + /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { H5D__free_chunk_info(new_chunk_info, NULL, NULL); @@ -1600,6 +1617,7 @@ H5D__chunk_file_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, /* Set the chunk's scaled coordinates */ HDmemcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); chunk_info->scaled[fm->f_ndims] = 0; + HDmemcpy(chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->sel_chunks,chunk_info,&chunk_info->index) < 0) { @@ -2056,7 +2074,7 @@ H5D__chunk_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, udata.chunk_block.length = io_info->dset->shared->layout.u.chunk.size; /* Allocate the chunk */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, chunk_info->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Make sure the address of the chunk is returned. */ @@ -2221,12 +2239,14 @@ H5D__chunk_dest(H5D_t *dset, hid_t dxpl_id) H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Dataset's chunk cache */ H5D_rdcc_ent_t *ent = NULL, *next = NULL; /* Pointer to current & next cache entries */ int nerrors = 0; /* Accumulated count of errors */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL) /* Sanity checks */ HDassert(dset); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Fill the DXPL cache values for later use */ if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) @@ -2287,6 +2307,7 @@ H5D_chunk_idx_reset(H5O_storage_chunk_t *storage, hbool_t reset_addr) /* Sanity checks */ HDassert(storage); HDassert(storage->ops); + H5D_CHUNK_STORAGE_INDEX_CHK(storage); /* Reset index structures */ if((storage->ops->reset)(storage, reset_addr) < 0) @@ -2351,6 +2372,7 @@ H5D__chunk_cinfo_cache_update(H5D_chunk_cached_t *last, const H5D_chunk_ud_t *ud HDmemcpy(last->scaled, udata->common.scaled, sizeof(hsize_t) * udata->common.layout->ndims); last->addr = udata->chunk_block.offset; H5_CHECKED_ASSIGN(last->nbytes, uint32_t, udata->chunk_block.length, hsize_t); + last->chunk_idx = udata->chunk_idx; last->filter_mask = udata->filter_mask; /* Indicate that the cached info is valid */ @@ -2397,6 +2419,7 @@ H5D__chunk_cinfo_cache_found(const H5D_chunk_cached_t *last, H5D_chunk_ud_t *uda /* Retrieve the information from the cache */ udata->chunk_block.offset = last->addr; udata->chunk_block.length = last->nbytes; + udata->chunk_idx = last->chunk_idx; udata->filter_mask = last->filter_mask; /* Indicate that the data was found */ @@ -2427,6 +2450,7 @@ herr_t H5D__chunk_create(const H5D_t *dset /*in,out*/, hid_t dxpl_id) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2435,6 +2459,8 @@ H5D__chunk_create(const H5D_t *dset /*in,out*/, hid_t dxpl_id) HDassert(dset); HDassert(H5D_CHUNKED == dset->shared->layout.type); HDassert(dset->shared->layout.u.chunk.ndims > 0 && dset->shared->layout.u.chunk.ndims <= H5O_LAYOUT_NDIMS); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); + #ifndef NDEBUG { unsigned u; /* Local index variable */ @@ -2527,12 +2553,14 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ hbool_t found = FALSE; /* In cache? */ unsigned u; /* Counter */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(dset); HDassert(dset->shared->layout.u.chunk.ndims > 0); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(scaled); HDassert(udata); @@ -2563,6 +2591,7 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, if(found) { udata->chunk_block.offset = ent->chunk_block.offset; udata->chunk_block.length = ent->chunk_block.length;; + udata->chunk_idx = ent->chunk_idx; } /* end if */ else { /* Invalidate idx_hint, to signal that the chunk is not in cache */ @@ -2614,12 +2643,14 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t { void *buf = NULL; /* Temporary buffer */ hbool_t point_of_no_return = FALSE; + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC_TAG(dxpl_id, dset->oloc.addr, FAIL) HDassert(dset); HDassert(dset->shared); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(dxpl_cache); HDassert(ent); HDassert(!ent->locked); @@ -2638,6 +2669,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t udata.chunk_block.offset = ent->chunk_block.offset; udata.chunk_block.length = dset->shared->layout.u.chunk.size; udata.filter_mask = 0; + udata.chunk_idx = ent->chunk_idx; /* Should the chunk be filtered before writing it to disk? */ if(dset->shared->dcpl_cache.pline.nused) { @@ -2697,7 +2729,7 @@ H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t /* Create the chunk it if it doesn't exist, or reallocate the chunk * if its size changed. */ - if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, &(ent->chunk_block), &udata.chunk_block, &need_insert, ent->scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Update the chunk entry's info, in case it was allocated or relocated */ @@ -2804,8 +2836,19 @@ H5D__chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t rdcc->tail = ent->prev; ent->prev = ent->next = NULL; - /* Only clear hash table slot if chunk was not marked as deleted already */ - if(!ent->deleted) + /* Unlink from temporary list */ + if(ent->tmp_prev) { + HDassert(rdcc->tmp_head->tmp_next); + ent->tmp_prev->tmp_next = ent->tmp_next; + if(ent->tmp_next) { + ent->tmp_next->tmp_prev = ent->tmp_prev; + ent->tmp_next = NULL; + } /* end if */ + ent->tmp_prev = NULL; + } /* end if */ + else + /* Only clear hash table slot if the chunk was not on the temporary list + */ rdcc->slot[ent->idx] = NULL; /* Remove from cache */ @@ -2980,6 +3023,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, HDassert(udata); HDassert(dset); HDassert(TRUE == H5P_isa_class(io_info->dxpl_id, H5P_DATASET_XFER)); + HDassert(!rdcc->tmp_head); /* Get the chunk's size */ HDassert(layout->u.chunk.size > 0); @@ -2999,7 +3043,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, unsigned u; /*counters */ /* Make sure this is the right chunk */ - for(u = 0; u < layout->u.chunk.ndims; u++) + for(u = 0; u < layout->u.chunk.ndims - 1; u++) HDassert(io_info->store->chunk.scaled[u] == ent->scaled[u]); } #endif /* NDEBUG */ @@ -3147,6 +3191,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, /* Initialize the new entry */ ent->chunk_block.offset = chunk_addr; ent->chunk_block.length = chunk_alloc; + ent->chunk_idx = udata->chunk_idx; HDmemcpy(ent->scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); H5_CHECKED_ASSIGN(ent->rd_count, uint32_t, chunk_size, size_t); H5_CHECKED_ASSIGN(ent->wr_count, uint32_t, chunk_size, size_t); @@ -3167,6 +3212,9 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, } /* end if */ else rdcc->head = rdcc->tail = ent; + ent->tmp_next = NULL; + ent->tmp_prev = NULL; + } /* end if */ else /* We did not add the chunk to cache */ @@ -3255,7 +3303,9 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, HDmemset(&fake_ent, 0, sizeof(fake_ent)); fake_ent.dirty = TRUE; HDmemcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); + HDmemcpy(fake_ent.scaled, udata->common.scaled, sizeof(hsize_t) * layout->u.chunk.ndims); HDassert(layout->u.chunk.size > 0); + fake_ent.chunk_idx = udata->chunk_idx; fake_ent.chunk_block.offset = udata->chunk_block.offset; fake_ent.chunk_block.length = udata->chunk_block.length; fake_ent.chunk = (uint8_t *)chunk; @@ -3344,12 +3394,14 @@ H5D__chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes) H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ hsize_t chunk_bytes = 0; /* Number of bytes allocated for chunks */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(dset); HDassert(dset->shared); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Fill the DXPL cache values for later use */ if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) @@ -3426,6 +3478,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, unsigned op_dim; /* Current operating dimension */ H5D_fill_buf_info_t fb_info; /* Dataset's fill buffer info */ hbool_t fb_info_init = FALSE; /* Whether the fill value buffer has been initialized */ + const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dxpl_id, dset->oloc.addr, FAIL) @@ -3433,6 +3486,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, /* Check args */ HDassert(dset && H5D_CHUNKED == layout->type); HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(TRUE == H5P_isa_class(dxpl_id, H5P_DATASET_XFER)); /* Retrieve the dataset dimensions */ @@ -3552,6 +3606,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, * Note that min_unalloc & max_unalloc are in scaled coordinates. * */ + chunk_size = orig_chunk_size; for(op_dim = 0; op_dim < space_ndims; op_dim++) { H5D_chunk_ud_t udata; /* User data for querying chunk info */ int i; /* Local index variable */ @@ -3570,18 +3625,11 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, while(!carry) { hbool_t need_insert = FALSE; /* Whether the chunk needs to be inserted into the index */ - /* Reset size of chunk in bytes, in case filtered size changes */ - chunk_size = orig_chunk_size; - + /* Look up this chunk */ + if(H5D__chunk_lookup(dset, dxpl_id, scaled, &udata) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") #ifndef NDEBUG /* None of the chunks should be allocated */ - { - /* Look up this chunk */ - if(H5D__chunk_lookup(dset, dxpl_id, scaled, &udata) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "error looking up chunk address") - - HDassert(!H5F_addr_defined(udata.chunk_block.offset)); - } /* end block */ /* Make sure the chunk is really in the dataset and outside the * original dimensions */ @@ -3636,6 +3684,8 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, /* Keep the number of bytes the chunk turned in to */ chunk_size = nbytes; } /* end if */ + else + chunk_size = layout->u.chunk.size; } /* end if */ /* Initialize the chunk information */ @@ -3647,7 +3697,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, udata.filter_mask = filter_mask; /* Allocate the chunk (with all processes) */ - if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(&idx_info, NULL, &udata.chunk_block, &need_insert, scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") HDassert(H5F_addr_defined(udata.chunk_block.offset)); @@ -4139,6 +4189,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) hsize_t hyper_start[H5O_LAYOUT_NDIMS]; /* Starting location of hyperslab */ uint32_t elmts_per_chunk; /* Elements in chunk */ unsigned u; /* Local index variable */ + const H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4146,6 +4197,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* Check args */ HDassert(dset && H5D_CHUNKED == layout->type); HDassert(layout->u.chunk.ndims > 0 && layout->u.chunk.ndims <= H5O_LAYOUT_NDIMS); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(dxpl_cache); /* Fill the DXPL cache values for later use */ @@ -4284,6 +4336,8 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) while(!carry) { int i; /* Local index variable */ + udata.common.scaled = scaled; + if(0 == ndims_outside_fill) { HDassert(fill_dim[op_dim]); HDassert(scaled[op_dim] == min_mod_chunk_sc[op_dim]); @@ -4322,7 +4376,7 @@ H5D__chunk_prune_by_extent(H5D_t *dset, hid_t dxpl_id, const hsize_t *old_dim) /* Remove the chunk from disk, if present */ if(H5F_addr_defined(chk_udata.chunk_block.offset)) { /* Update the offset in idx_udata */ - idx_udata.scaled = scaled; + idx_udata.scaled = udata.common.scaled; /* Remove the chunk from disk */ if((layout->storage.u.chunk.ops->remove)(&idx_info, &idx_udata) < 0) @@ -4444,12 +4498,14 @@ H5D__chunk_addrmap(const H5D_io_info_t *io_info, haddr_t chunk_addr[]) H5D_chk_idx_info_t idx_info; /* Chunked index info */ const H5D_t *dset = io_info->dset; /* Local pointer to dataset info */ H5D_chunk_it_ud2_t udata; /* User data for iteration callback */ + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE HDassert(dset); HDassert(dset->shared); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(chunk_addr); /* Set up user data for B-tree callback */ @@ -4497,6 +4553,7 @@ H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) H5O_pline_t pline; /* I/O pipeline message */ hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read from the file */ htri_t exists; /* Flag if header message of interest exists */ + H5O_storage_chunk_t *sc = &(storage->u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -4505,6 +4562,7 @@ H5D__chunk_delete(H5F_t *f, hid_t dxpl_id, H5O_t *oh, H5O_storage_t *storage) HDassert(f); HDassert(oh); HDassert(storage); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Check for I/O pipeline message */ if((exists = H5O_msg_exists_oh(oh, H5O_PLINE_ID)) < 0) @@ -4571,6 +4629,8 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id) { H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /*raw data chunk cache */ H5D_rdcc_ent_t *ent, *next; /*cache entry */ + H5D_rdcc_ent_t tmp_head; /* Sentinel entry for temporary entry list */ + H5D_rdcc_ent_t *tmp_tail; /* Tail pointer for temporary entry list */ H5D_dxpl_cache_t _dxpl_cache; /* Data transfer property cache buffer */ H5D_dxpl_cache_t *dxpl_cache = &_dxpl_cache; /* Data transfer property cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -4588,6 +4648,11 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id) if(H5D__get_dxpl_cache(dxpl_id, &dxpl_cache) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") + /* Add temporary entry list to rdcc */ + (void)HDmemset(&tmp_head, 0, sizeof(tmp_head)); + rdcc->tmp_head = &tmp_head; + tmp_tail = &tmp_head; + /* Recompute the index for each cached chunk that is in a dataset */ for(ent = rdcc->head; ent; ent = next) { unsigned old_idx; /* Previous index number */ @@ -4608,37 +4673,58 @@ H5D__chunk_update_cache(H5D_t *dset, hid_t dxpl_id) HDassert(old_ent->locked == FALSE); HDassert(old_ent->deleted == FALSE); - /* Mark the old entry as deleted, but do not evict (yet). - * Make sure we do not make any calls to the index + /* Insert the old entry into the temporary list, but do not + * evict (yet). Make sure we do not make any calls to the index * until all chunks have updated indices! */ - old_ent->deleted = TRUE; + HDassert(!old_ent->tmp_next); + HDassert(!old_ent->tmp_prev); + tmp_tail->tmp_next = old_ent; + old_ent->tmp_prev = tmp_tail; + tmp_tail = old_ent; } /* end if */ /* Insert this chunk into correct location in hash table */ rdcc->slot[ent->idx] = ent; - /* If this chunk was previously marked as deleted and therefore - * not in the hash table, reset the deleted flag. + /* If this chunk was previously on the temporary list and therefore + * not in the hash table, remove it from the temporary list. * Otherwise clear the old hash table slot. */ - if(ent->deleted) - ent->deleted = FALSE; + if(ent->tmp_prev) { + HDassert(tmp_head.tmp_next); + HDassert(tmp_tail != &tmp_head); + ent->tmp_prev->tmp_next = ent->tmp_next; + if(ent->tmp_next) { + ent->tmp_next->tmp_prev = ent->tmp_prev; + ent->tmp_next = NULL; + } /* end if */ + else { + HDassert(tmp_tail == ent); + tmp_tail = ent->tmp_prev; + } /* end else */ + ent->tmp_prev = NULL; + } /* end if */ else rdcc->slot[old_idx] = NULL; } /* end if */ } /* end for */ - /* Evict chunks that are still marked as deleted */ - for(ent = rdcc->head; ent; ent = next) { - /* Get the pointer to the next cache entry */ - next = ent->next; + /* tmp_tail is no longer needed, and will be invalidated by + * H5D_chunk_cache_evict anyways. */ + tmp_tail = NULL; + + /* Evict chunks that are still on the temporary list */ + while(tmp_head.tmp_next) { + ent = tmp_head.tmp_next; /* Remove the old entry from the cache */ - if(ent->deleted) - if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") - } /* end for */ + if(H5D__chunk_cache_evict(dset, dxpl_id, dxpl_cache, ent, TRUE) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks") + } /* end while */ done: + /* Remove temporary list from rdcc */ + rdcc->tmp_head = NULL; + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__chunk_update_cache() */ @@ -4803,8 +4889,11 @@ H5D__chunk_copy_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) udata->buf_size = buf_size; } /* end if */ + udata_dst.chunk_idx = H5VM_array_offset_pre(udata_dst.common.layout->ndims - 1, + udata_dst.common.layout->down_chunks, udata_dst.common.scaled); + /* Allocate chunk in the file */ - if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert) < 0) + if(H5D__chunk_file_alloc(udata->idx_info_dst, NULL, &udata_dst.chunk_block, &need_insert, udata_dst.common.scaled) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINSERT, FAIL, "unable to insert/resize chunk on chunk level") /* Write chunk data to destination file */ @@ -4850,6 +4939,9 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, H5D_chunk_it_ud3_t udata; /* User data for iteration callback */ H5D_chk_idx_info_t idx_info_dst; /* Dest. chunked index info */ H5D_chk_idx_info_t idx_info_src; /* Source chunked index info */ + int sndims; /* Rank of dataspace */ + hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ + hsize_t max_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ H5O_pline_t _pline; /* Temporary pipeline info */ const H5O_pline_t *pline; /* Pointer to pipeline info to use */ H5T_path_t *tpath_src_mem = NULL, *tpath_mem_dst = NULL; /* Datatype conversion paths */ @@ -4873,9 +4965,11 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, /* Check args */ HDassert(f_src); HDassert(storage_src); + H5D_CHUNK_STORAGE_INDEX_CHK(storage_src); HDassert(layout_src); HDassert(f_dst); HDassert(storage_dst); + H5D_CHUNK_STORAGE_INDEX_CHK(storage_dst); HDassert(ds_extent_src); HDassert(dt_src); @@ -4893,17 +4987,15 @@ H5D__chunk_copy(H5F_t *f_src, H5O_storage_chunk_t *storage_src, /* Initialize layout information */ { - hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Curr. size of dataset dimensions */ - int sndims; /* Rank of dataspace */ unsigned ndims; /* Rank of dataspace */ /* Get the dim info for dataset */ - if((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, NULL)) < 0) + if((sndims = H5S_extent_get_dims(ds_extent_src, curr_dims, max_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataspace dimensions") H5_CHECKED_ASSIGN(ndims, unsigned, sndims, int); /* Set the source layout chunk information */ - if(H5D__chunk_set_info_real(layout_src, ndims, curr_dims) < 0) + if(H5D__chunk_set_info_real(layout_src, ndims, curr_dims, max_dims) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set layout's chunk info") } /* end block */ @@ -5105,6 +5197,7 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5O_layout_t H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5S_t *space = NULL; /* Dataset's dataspace */ H5O_pline_t pline; /* I/O pipeline message */ + H5O_storage_chunk_t *sc = &(layout->storage.u.chunk); htri_t exists; /* Flag if header message of interest exists */ hbool_t idx_info_init = FALSE; /* Whether the chunk index info has been initialized */ hbool_t pline_read = FALSE; /* Whether the I/O pipeline message was read */ @@ -5117,6 +5210,7 @@ H5D__chunk_bh_info(const H5O_loc_t *loc, hid_t dxpl_id, H5O_t *oh, H5O_layout_t HDassert(loc->file); HDassert(H5F_addr_defined(loc->addr)); HDassert(layout); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); HDassert(index_size); /* Check for I/O pipeline message */ @@ -5226,12 +5320,14 @@ H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) herr_t H5D__chunk_dump_index(H5D_t *dset, hid_t dxpl_id, FILE *stream) { + H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ HDassert(dset); + H5D_CHUNK_STORAGE_INDEX_CHK(sc); /* Only display info if stream is defined */ if(stream) { @@ -5449,7 +5545,7 @@ done: */ static herr_t H5D__chunk_file_alloc(const H5D_chk_idx_info_t *idx_info, const H5F_block_t *old_chunk, - H5F_block_t *new_chunk, hbool_t *need_insert) + H5F_block_t *new_chunk, hbool_t *need_insert, hsize_t scaled[]) { hbool_t alloc_chunk = FALSE; /* Whether to allocate chunk */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 4ec48bb..ab2f8d0 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -718,6 +718,7 @@ static herr_t H5D__cache_dataspace_info(const H5D_t *dset) { int sndims; /* Signed number of dimensions of dataspace rank */ + unsigned u; /* Local index value */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -730,6 +731,10 @@ H5D__cache_dataspace_info(const H5D_t *dset) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't cache dataspace dimensions") dset->shared->ndims = (unsigned)sndims; + /* Compute the inital 'power2up' values */ + for(u = 0; u < dset->shared->ndims; u++) + dset->shared->curr_power2up[u] = H5VM_power2up(dset->shared->curr_dims[u]); + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__cache_dataspace_info() */ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 8676d7c..16ff81b 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -150,6 +150,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ switch(layout->type) { case H5D_COMPACT: + /* This information only present in older versions of message */ /* Size of raw data */ ret_value += 2; if(include_compact_data) @@ -157,6 +158,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ break; case H5D_CONTIGUOUS: + /* This information only present in older versions of message */ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ break; @@ -206,7 +208,7 @@ herr_t H5D__layout_oh_create(H5F_t *file, hid_t dxpl_id, H5O_t *oh, H5D_t *dset, hid_t dapl_id) { - H5O_layout_t *layout; /* Dataset's layout information */ + H5O_layout_t *layout; /* Dataset's layout information */ const H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ herr_t ret_value = SUCCEED; /* Return value */ @@ -401,7 +403,7 @@ done: /*------------------------------------------------------------------------- * Function: H5D__layout_oh_write * - * Purpose: Write layout/pline/efl information for dataset + * Purpose: Write layout information for dataset * * Return: Success: SUCCEED * Failure: FAIL diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index e9e87af..06e763c 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -240,7 +240,7 @@ typedef struct H5D_chk_idx_info_t { typedef struct H5D_chunk_rec_t { hsize_t scaled[H5O_LAYOUT_NDIMS]; /* Logical offset to start */ uint32_t nbytes; /* Size of stored data */ - unsigned filter_mask; /* Excluded filters */ + uint32_t filter_mask; /* Excluded filters */ haddr_t chunk_addr; /* Address of chunk in file */ } H5D_chunk_rec_t; @@ -264,6 +264,7 @@ typedef struct H5D_chunk_ud_t { unsigned idx_hint; /*index of chunk in cache, if present */ H5F_block_t chunk_block; /*offset/length of chunk in file */ unsigned filter_mask; /*excluded filters */ + hsize_t chunk_idx; /*chunk index for EA, FA indexing */ } H5D_chunk_ud_t; /* Typedef for "generic" chunk callbacks */ @@ -363,6 +364,7 @@ typedef struct H5D_chunk_cached_t { hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled offset of chunk*/ haddr_t addr; /*file address of chunk */ uint32_t nbytes; /*size of stored data */ + hsize_t chunk_idx; /*index of chunk in dataset */ unsigned filter_mask; /*excluded filters */ } H5D_chunk_cached_t; @@ -379,6 +381,7 @@ typedef struct H5D_rdcc_t { double w0; /* Chunk preemption policy */ struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ + struct H5D_rdcc_ent_t *tmp_head; /* Head of temporary doubly linked list. Chunks on this list are not in the hash table (slot). The head entry is a sentinel (does not refer to an actual chunk). */ size_t nbytes_used; /* Current cached raw data in bytes */ int nused; /* Number of chunk slots in use */ H5D_chunk_cached_t last; /* Cached copy of last chunk information */ @@ -422,6 +425,7 @@ typedef struct H5D_shared_t { /* Cached dataspace info */ unsigned ndims; /* The dataset's dataspace rank */ hsize_t curr_dims[H5S_MAX_RANK]; /* The curr. size of dataset dimensions */ + hsize_t curr_power2up[H5S_MAX_RANK]; /* The curr. dim sizes, rounded up to next power of 2 */ hsize_t max_dims[H5S_MAX_RANK]; /* The max. size of dataset dimensions */ /* Buffered/cached information for types of raw data storage*/ @@ -502,10 +506,13 @@ typedef struct H5D_rdcc_ent_t { uint32_t rd_count; /*bytes remaining to be read */ uint32_t wr_count; /*bytes remaining to be written */ H5F_block_t chunk_block; /*offset/length of chunk in file */ + hsize_t chunk_idx; /*index of chunk in dataset */ uint8_t *chunk; /*the unfiltered chunk data */ unsigned idx; /*index in hash table */ struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ } H5D_rdcc_ent_t; typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 0d77a83..9235d6c 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -506,10 +506,14 @@ typedef struct H5O_storage_t { typedef struct H5O_layout_chunk_t { unsigned ndims; /* Num dimensions in chunk */ uint32_t dim[H5O_LAYOUT_NDIMS]; /* Size of chunk in elements */ + unsigned enc_bytes_per_dim; /* Encoded # of bytes for storing each chunk dimension */ uint32_t size; /* Size of chunk in bytes */ hsize_t nchunks; /* Number of chunks in dataset */ + hsize_t max_nchunks; /* Max. number of chunks in dataset */ hsize_t chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset dimension */ + hsize_t max_chunks[H5O_LAYOUT_NDIMS]; /* # of chunks in each dataset's max. dimension */ hsize_t down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each dimension */ + hsize_t max_down_chunks[H5O_LAYOUT_NDIMS]; /* "down" size of number of chunks in each max dim */ } H5O_layout_chunk_t; typedef struct H5O_layout_t { diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 145e1b5..03d987f 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -29,14 +29,14 @@ /****************/ #include "H5Pmodule.h" /* This source code file is part of the H5P module */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ /***********/ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ +#include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ @@ -45,6 +45,7 @@ #include "H5Ppkg.h" /* Property lists */ #include "H5Sprivate.h" /* Dataspaces */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VMprivate.h" /* Vectors and arrays */ #include "H5Zprivate.h" /* Data filters */ @@ -55,28 +56,28 @@ /* Define default layout information */ #define H5D_DEF_STORAGE_COMPACT_INIT {(hbool_t)FALSE, (size_t)0, NULL} #define H5D_DEF_STORAGE_CONTIG_INIT {HADDR_UNDEF, (hsize_t)0} -#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, NULL, {{HADDR_UNDEF, NULL}}} -#define H5D_DEF_LAYOUT_CHUNK_INIT {(unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (uint32_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} +#define H5D_DEF_STORAGE_CHUNK_INIT {H5D_CHUNK_IDX_BTREE, HADDR_UNDEF, H5D_COPS_BTREE, {{HADDR_UNDEF, NULL}}} +#define H5D_DEF_LAYOUT_CHUNK_INIT {(unsigned)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, (unsigned)0, (uint32_t)0, (hsize_t)0, (hsize_t)0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} #define H5D_DEF_STORAGE_VIRTUAL_INIT {{HADDR_UNDEF, 0}, 0, NULL, 0, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, H5D_VDS_ERROR, HSIZE_UNDEF, -1, -1, FALSE} #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER #define H5D_DEF_STORAGE_COMPACT {H5D_COMPACT, { .compact = H5D_DEF_STORAGE_COMPACT_INIT }} #define H5D_DEF_STORAGE_CONTIG {H5D_CONTIGUOUS, { .contig = H5D_DEF_STORAGE_CONTIG_INIT }} #define H5D_DEF_STORAGE_CHUNK {H5D_CHUNKED, { .chunk = H5D_DEF_STORAGE_CHUNK_INIT }} #define H5D_DEF_STORAGE_VIRTUAL {H5D_VIRTUAL, { .virt = H5D_DEF_STORAGE_VIRTUAL_INIT }} -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_VIRTUAL} +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_COMPACT, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_COMPACT} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CONTIG, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CONTIG} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, H5D_LOPS_CHUNK, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_CHUNK} +#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, H5D_LOPS_VIRTUAL, {H5D_DEF_LAYOUT_CHUNK_INIT}, H5D_DEF_STORAGE_VIRTUAL} #else /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* Note that the compact & chunked layout initialization values are using the * contiguous layout initialization in the union, because the contiguous * layout is first in the union. These values are overridden in the * H5P__init_def_layout() routine. -QAK */ -#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} -#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_3, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_COMPACT {H5D_COMPACT, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CONTIG {H5D_CONTIGUOUS, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_CHUNK {H5D_CHUNKED, H5O_LAYOUT_VERSION_DEFAULT, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} +#define H5D_DEF_LAYOUT_VIRTUAL {H5D_VIRTUAL, H5O_LAYOUT_VERSION_4, NULL, {H5D_DEF_LAYOUT_CHUNK_INIT}, {H5D_CONTIGUOUS, H5D_DEF_STORAGE_CONTIG_INIT}} #endif /* H5_HAVE_C99_DESIGNATED_INITIALIZER */ /* ======== Dataset creation properties ======== */ @@ -1997,6 +1998,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) H5P_genplist_t *plist; /* Property list pointer */ H5O_layout_t chunk_layout; /* Layout information for setting chunk info */ uint64_t chunk_nelmts; /* Number of elements in chunk */ + unsigned max_enc_bytes_per_dim; /* Max. number of bytes required to encode this dimension */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2024,7 +2026,10 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) HDmemcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g)); HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim)); chunk_nelmts = 1; + max_enc_bytes_per_dim = 0; for(u = 0; u < (unsigned)ndims; u++) { + unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */ + if(dim[u] == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be positive") if(dim[u] != (dim[u] & 0xffffffff)) @@ -2033,7 +2038,16 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) if(chunk_nelmts > (uint64_t)0xffffffff) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of elements in chunk must be < 4GB") chunk_layout.u.chunk.dim[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */ + + /* Get encoded size of dim, in bytes */ + enc_bytes_per_dim = (H5VM_log2_gen(dim[u]) + 8) / 8; + + /* Check if this is the largest value so far */ + if(enc_bytes_per_dim > max_enc_bytes_per_dim) + max_enc_bytes_per_dim = enc_bytes_per_dim; } /* end for */ + HDassert(max_enc_bytes_per_dim > 0 && max_enc_bytes_per_dim <= 8); + chunk_layout.u.chunk.enc_bytes_per_dim = max_enc_bytes_per_dim; /* Get the plist structure */ if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE))) -- cgit v0.12 From 6d8b831b3125ce66e23aba1f3ec16a03e00b5b82 Mon Sep 17 00:00:00 2001 From: HDF Tester Date: Sun, 27 Dec 2015 23:20:23 -0500 Subject: [svn-r28730] Snapshot version 1.9 release 233 --- README.txt | 2 +- c++/src/cpp_doc_config | 2 +- config/lt_vers.am | 2 +- configure.ac | 2 +- release_docs/RELEASE.txt | 2 +- src/H5public.h | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.txt b/README.txt index 291e8a6..6dfd021 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.233 released on 2015-10-06 +HDF5 version 1.9.234 currently under development Please refer to the release_docs/INSTALL file for installation instructions. ------------------------------------------------------------------------------ diff --git a/c++/src/cpp_doc_config b/c++/src/cpp_doc_config index 7060fd2..623f9c7 100644 --- a/c++/src/cpp_doc_config +++ b/c++/src/cpp_doc_config @@ -38,7 +38,7 @@ PROJECT_NAME = "HDF5 C++ API" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = "1.9.233 currently under development" +PROJECT_NUMBER = "1.9.234 currently under development" # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/config/lt_vers.am b/config/lt_vers.am index 401bcb9..a3b7634 100644 --- a/config/lt_vers.am +++ b/config/lt_vers.am @@ -19,7 +19,7 @@ # After making changes, run bin/reconfigure to update other configure related # files like Makefile.in. LT_VERS_INTERFACE = 6 -LT_VERS_REVISION = 223 +LT_VERS_REVISION = 224 LT_VERS_AGE = 0 ## If the API changes *at all*, increment LT_VERS_INTERFACE and diff --git a/configure.ac b/configure.ac index 0c3514c..0e853a8 100644 --- a/configure.ac +++ b/configure.ac @@ -26,7 +26,7 @@ AC_PREREQ([2.69]) ## NOTE: Do not forget to change the version number here when we do a ## release!!! ## -AC_INIT([HDF5], [1.9.232], [help@hdfgroup.org]) +AC_INIT([HDF5], [1.9.234], [help@hdfgroup.org]) AC_CONFIG_SRCDIR([src/H5.c]) AC_CONFIG_HEADERS([src/H5config.h]) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 1cfe382..2c9c79f 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.9.233 released on 2015-10-06 +HDF5 version 1.9.234 currently under development ================================================================================ diff --git a/src/H5public.h b/src/H5public.h index 5b95fb7..554ad26 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -94,10 +94,10 @@ extern "C" { /* Version numbers */ #define H5_VERS_MAJOR 1 /* For major interface/format changes */ #define H5_VERS_MINOR 9 /* For minor interface/format changes */ -#define H5_VERS_RELEASE 233 /* For tweaks, bug-fixes, or development */ +#define H5_VERS_RELEASE 234 /* For tweaks, bug-fixes, or development */ #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */ /* Empty string for real releases. */ -#define H5_VERS_INFO "HDF5 library version: 1.9.233" /* Full version string */ +#define H5_VERS_INFO "HDF5 library version: 1.9.234" /* Full version string */ #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \ H5_VERS_RELEASE) -- cgit v0.12 From b5504be6cc6f61b5a8ce78f243b81b6afe9d13c9 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 29 Dec 2015 12:06:36 -0500 Subject: [svn-r28742] Description: Add 'update' operation to v2 B-trees, which will insert a new record, or modify an existing one, depending on if the record exists or not. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5Abtree2.c | 8 +- src/H5B2.c | 74 +- src/H5B2dbg.c | 44 +- src/H5B2int.c | 401 +++++++ src/H5B2pkg.h | 27 +- src/H5B2private.h | 5 +- src/H5B2test.c | 168 ++- src/H5Gbtree2.c | 8 +- src/H5HFbtree2.c | 57 +- src/H5SMbtree2.c | 44 +- test/btree2.c | 2902 ++++++++++++++++++++++++++++++++++++++++++++------ tools/misc/h5debug.c | 4 + 12 files changed, 3227 insertions(+), 515 deletions(-) diff --git a/src/H5Abtree2.c b/src/H5Abtree2.c index 972fb0b..716ad4a 100644 --- a/src/H5Abtree2.c +++ b/src/H5Abtree2.c @@ -116,9 +116,7 @@ const H5B2_class_t H5A_BT2_NAME[1]={{ /* B-tree class information */ H5A__dense_btree2_name_compare, /* Record comparison callback */ H5A__dense_btree2_name_encode, /* Record encoding callback */ H5A__dense_btree2_name_decode, /* Record decoding callback */ - H5A__dense_btree2_name_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5A__dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of attributes */ @@ -132,9 +130,7 @@ const H5B2_class_t H5A_BT2_CORDER[1]={{ /* B-tree class information */ H5A__dense_btree2_corder_compare, /* Record comparison callback */ H5A__dense_btree2_corder_encode, /* Record encoding callback */ H5A__dense_btree2_corder_decode, /* Record decoding callback */ - H5A__dense_btree2_corder_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5A__dense_btree2_corder_debug /* Record debugging callback */ }}; diff --git a/src/H5B2.c b/src/H5B2.c index a171917..c105a93 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -86,6 +86,7 @@ extern const H5B2_class_t H5G_BT2_CORDER[1]; extern const H5B2_class_t H5SM_INDEX[1]; extern const H5B2_class_t H5A_BT2_NAME[1]; extern const H5B2_class_t H5A_BT2_CORDER[1]; +extern const H5B2_class_t H5B2_TEST2[1]; const H5B2_class_t *const H5B2_client_class_g[] = { H5B2_TEST, /* 0 - H5B2_TEST_ID */ @@ -98,6 +99,7 @@ const H5B2_class_t *const H5B2_client_class_g[] = { H5SM_INDEX, /* 7 - H5B2_SOHM_INDEX_ID */ H5A_BT2_NAME, /* 8 - H5B2_ATTR_DENSE_NAME_ID */ H5A_BT2_CORDER, /* 9 - H5B2_ATTR_DENSE_CORDER_ID */ + H5B2_TEST2, /* 10 - H5B2_TEST_ID */ }; @@ -282,36 +284,78 @@ H5B2_insert(H5B2_t *bt2, hid_t dxpl_id, void *udata) /* Get the v2 B-tree header */ hdr = bt2->hdr; + /* Insert the record */ + if(H5B2__insert_hdr(hdr, dxpl_id, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2_insert() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2_update + * + * Purpose: Insert or modify a record to the B-tree. + * If the record exists already, it is modified as if H5B2_modify + * was called). If it doesn't exist, it is inserted as if + * H5B2_insert was called. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 23 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2_update(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, void *op_data) +{ + H5B2_hdr_t *hdr; /* Pointer to the B-tree header */ + H5B2_update_status_t status = H5B2_UPDATE_UNKNOWN; /* Whether the record was inserted/modified */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments. */ + HDassert(bt2); + HDassert(udata); + + /* Set the shared v2 B-tree header's file context for this operation */ + bt2->hdr->f = bt2->f; + + /* Get the v2 B-tree header */ + hdr = bt2->hdr; + /* Check if the root node is allocated yet */ if(!H5F_addr_defined(hdr->root.addr)) { /* Create root node as leaf node in B-tree */ if(H5B2__create_leaf(hdr, dxpl_id, &(hdr->root)) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") } /* end if */ - /* Check if we need to split the root node (equiv. to a 1->2 node split) */ - else if(hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { - /* Split root node */ - if(H5B2__split_root(hdr, dxpl_id) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split root node") - } /* end if */ /* Attempt to insert record into B-tree */ if(hdr->depth > 0) { - if(H5B2__insert_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") + if(H5B2__update_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, &status, H5B2_POS_ROOT, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to update record in B-tree internal node") } /* end if */ else { - if(H5B2__insert_leaf(hdr, dxpl_id, &hdr->root, H5B2_POS_ROOT, udata) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") + if(H5B2__update_leaf(hdr, dxpl_id, &hdr->root, &status, H5B2_POS_ROOT, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to update record in B-tree leaf node") } /* end else */ - /* Mark B-tree header as dirty */ - if(H5B2__hdr_dirty(hdr) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") + /* Sanity check */ + HDassert(H5B2_UPDATE_UNKNOWN != status); + + /* Use insert algorithm if nodes to leaf full */ + if(H5B2_UPDATE_INSERT_CHILD_FULL == status) + if(H5B2__insert_hdr(hdr, dxpl_id, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5B2_insert() */ +} /* H5B2_update() */ /*------------------------------------------------------------------------- @@ -1202,7 +1246,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, /* Unlock current node */ if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr.addr, leaf, leaf_flags) < 0) HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release B-tree node") - } + } /* end block */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5B2dbg.c b/src/H5B2dbg.c index 73084d2..ddff9e9 100644 --- a/src/H5B2dbg.c +++ b/src/H5B2dbg.c @@ -92,7 +92,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, const H5B2_class_t *type, haddr_t obj_addr) { H5B2_hdr_t *hdr = NULL; /* B-tree header info */ - void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value = SUCCEED; /* Return value */ @@ -109,17 +108,9 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); - HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || - (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); - - /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) - /* Create debugging context */ - if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree header") /* Set file pointer for this B-tree operation */ @@ -171,8 +162,6 @@ H5B2__hdr_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, } /* end for */ done: - if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") @@ -199,7 +188,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_internal_t *internal = NULL; /* B-tree internal node */ - void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value=SUCCEED; /* Return value */ @@ -215,21 +203,12 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); - HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || - (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(H5F_addr_defined(obj_addr)); HDassert(nrec > 0); - /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) { - /* Create debugging context */ - if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - } /* end if */ - /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -279,7 +258,7 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_INT_NREC(internal, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_INT_NREC(internal, hdr, u), dbg_ctx); + (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_INT_NREC(internal, hdr, u), hdr->cb_ctx); } /* end for */ /* Print final node pointer */ @@ -291,8 +270,6 @@ H5B2__int_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, internal->node_ptrs[u].addr); done: - if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release v2 B-tree header") if(internal && H5AC_unprotect(f, dxpl_id, H5AC_BT2_INT, addr, internal, H5AC__NO_FLAGS_SET) < 0) @@ -321,7 +298,6 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent { H5B2_hdr_t *hdr = NULL; /* B-tree header */ H5B2_leaf_t *leaf = NULL; /* B-tree leaf node */ - void *dbg_ctx = NULL; /* v2 B-tree debugging context */ unsigned u; /* Local index variable */ char temp_str[128]; /* Temporary string, for formatting */ herr_t ret_value = SUCCEED; /* Return value */ @@ -337,20 +313,12 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDassert(indent >= 0); HDassert(fwidth >= 0); HDassert(type); - HDassert((type->crt_dbg_ctx && type->dst_dbg_ctx) || - (NULL == type->crt_dbg_ctx && NULL == type->dst_dbg_ctx)); HDassert(H5F_addr_defined(hdr_addr)); HDassert(H5F_addr_defined(obj_addr)); HDassert(nrec > 0); - /* Check for debugging context callback available */ - if(type->crt_dbg_ctx) - /* Create debugging context */ - if(NULL == (dbg_ctx = (type->crt_dbg_ctx)(f, dxpl_id, obj_addr))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTGET, FAIL, "unable to create v2 B-tree debugging context") - /* Load the B-tree header */ - if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, dbg_ctx, H5AC__READ_ONLY_FLAG))) + if(NULL == (hdr = H5B2__hdr_protect(f, dxpl_id, hdr_addr, f, H5AC__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect v2 B-tree header") /* Set file pointer for this B-tree operation */ @@ -391,12 +359,10 @@ H5B2__leaf_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), temp_str); HDassert(H5B2_LEAF_NREC(leaf, hdr, u)); - (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_LEAF_NREC(leaf, hdr, u), dbg_ctx); + (void)(type->debug)(stream, indent + 6, MAX (0, fwidth-6), H5B2_LEAF_NREC(leaf, hdr, u), hdr->cb_ctx); } /* end for */ done: - if(dbg_ctx && (type->dst_dbg_ctx)(dbg_ctx) < 0) - HDONE_ERROR(H5E_BTREE, H5E_CANTRELEASE, FAIL, "unable to release v2 B-tree debugging context") if(hdr && H5B2__hdr_unprotect(hdr, dxpl_id, H5AC__NO_FLAGS_SET) < 0) HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree header") if(leaf && H5AC_unprotect(f, dxpl_id, H5AC_BT2_LEAF, addr, leaf, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5B2int.c b/src/H5B2int.c index b8c9634..363d903 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1513,6 +1513,62 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__insert_hdr + * + * Purpose: Adds a new record to the B-tree. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 23 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__insert_hdr(H5B2_hdr_t *hdr, hid_t dxpl_id, void *udata) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments. */ + HDassert(hdr); + HDassert(udata); + + /* Check if the root node is allocated yet */ + if(!H5F_addr_defined(hdr->root.addr)) { + /* Create root node as leaf node in B-tree */ + if(H5B2__create_leaf(hdr, dxpl_id, &(hdr->root)) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create root node") + } /* end if */ + /* Check if we need to split the root node (equiv. to a 1->2 node split) */ + else if(hdr->root.node_nrec == hdr->node_info[hdr->depth].split_nrec) { + /* Split root node */ + if(H5B2__split_root(hdr, dxpl_id) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to split root node") + } /* end if */ + + /* Attempt to insert record into B-tree */ + if(hdr->depth > 0) { + if(H5B2__insert_internal(hdr, dxpl_id, hdr->depth, NULL, &hdr->root, H5B2_POS_ROOT, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree internal node") + } /* end if */ + else { + if(H5B2__insert_leaf(hdr, dxpl_id, &hdr->root, H5B2_POS_ROOT, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into B-tree leaf node") + } /* end else */ + + /* Mark B-tree header as dirty */ + if(H5B2__hdr_dirty(hdr) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTMARKDIRTY, FAIL, "unable to mark B-tree header dirty") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2__insert_hdr() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__insert_leaf * * Purpose: Adds a new record to a B-tree leaf node. @@ -1644,6 +1700,9 @@ H5B2__insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, if(NULL == (internal = H5B2__protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC__NO_FLAGS_SET))) HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") + /* Sanity check number of records */ + HDassert(internal->nrec == curr_node_ptr->node_nrec); + /* Split or redistribute child node pointers, if necessary */ { int cmp; /* Comparison value of records */ @@ -1755,6 +1814,348 @@ done: /*------------------------------------------------------------------------- + * Function: H5B2__update_leaf + * + * Purpose: Insert or modify a record in a B-tree leaf node. + * If the record exists already, it is modified as if H5B2_modify + * was called). If it doesn't exist, it is inserted as if + * H5B2_insert was called. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 23 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr, + H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *udata, + H5B2_modify_t op, void *op_data) +{ + H5B2_leaf_t *leaf; /* Pointer to leaf node */ + unsigned leaf_flags = H5AC__NO_FLAGS_SET; /* Flags for unprotecting the leaf node */ + int cmp = -1; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments. */ + HDassert(hdr); + HDassert(curr_node_ptr); + HDassert(H5F_addr_defined(curr_node_ptr->addr)); + + /* Lock current B-tree node */ + if(NULL == (leaf = H5B2__protect_leaf(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree leaf node") + + /* Sanity check number of records */ + HDassert(curr_node_ptr->all_nrec == curr_node_ptr->node_nrec); + HDassert(leaf->nrec == curr_node_ptr->node_nrec); + + /* Check for inserting into empty leaf */ + if(leaf->nrec == 0) + idx = 0; + else { + /* Find correct location to insert this record */ + cmp = H5B2__locate_record(hdr->cls, leaf->nrec, hdr->nat_off, leaf->leaf_native, udata, &idx); + + /* Check for inserting a record */ + if(0 != cmp) { + /* Check if the leaf node is full */ + if(curr_node_ptr->node_nrec == hdr->node_info[0].split_nrec) { + /* Indicate that the leaf is full, but we need to insert */ + *status = H5B2_UPDATE_INSERT_CHILD_FULL; + + /* Let calling routine handle insertion */ + HGOTO_DONE(SUCCEED) + } /* end if */ + + /* Adjust index to leave room for record to insert */ + if(cmp > 0) + idx++; + + /* Make room for new record */ + if(idx < leaf->nrec) + HDmemmove(H5B2_LEAF_NREC(leaf, hdr, idx + 1), H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size * (leaf->nrec - idx)); + } /* end if */ + } /* end else */ + + /* Check for modifying existing record */ + if(0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + + /* Make callback for current record */ + if((op)(H5B2_LEAF_NREC(leaf, hdr, idx), op_data, &changed) < 0) { + /* Make certain that the callback didn't modify the value if it failed */ + HDassert(changed == FALSE); + + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + } /* end if */ + + /* Mark the node as dirty if it changed */ + leaf_flags |= (changed ? H5AC__DIRTIED_FLAG : 0); + + /* Indicate that the record was modified */ + *status = H5B2_UPDATE_MODIFY_DONE; + } /* end if */ + else { + /* Must have a leaf node with enough space to insert a record now */ + HDassert(curr_node_ptr->node_nrec < hdr->node_info[0].max_nrec); + + /* Make callback to store record in native form */ + if((hdr->cls->store)(H5B2_LEAF_NREC(leaf, hdr, idx), udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into leaf node") + + /* Mark the node as dirty if it changed */ + leaf_flags |= H5AC__DIRTIED_FLAG; + + /* Indicate that the record was inserted */ + *status = H5B2_UPDATE_INSERT_DONE; + + /* Update record count for node pointer to current node */ + curr_node_ptr->all_nrec++; + curr_node_ptr->node_nrec++; + + /* Update record count for current node */ + leaf->nrec++; + } /* end else */ + + /* Check for new record being the min or max for the tree */ + /* (Don't use 'else' for the idx check, to allow for root leaf node) */ + if(H5B2_POS_MIDDLE != curr_pos) { + if(idx == 0) { + if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if(hdr->min_native_rec == NULL) + if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") + HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); + } /* end if */ + } /* end if */ + if(idx == (unsigned)(leaf->nrec - 1)) { + if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { + if(hdr->max_native_rec == NULL) + if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") + HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); + } /* end if */ + } /* end if */ + } /* end if */ + +done: + /* Release the B-tree leaf node */ + if(leaf && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_LEAF, curr_node_ptr->addr, leaf, leaf_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release leaf B-tree node") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2__update_leaf() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__update_internal + * + * Purpose: Insert or modify a record in a B-tree leaf node. + * If the record exists already, it is modified as if H5B2_modify + * was called). If it doesn't exist, it is inserted as if + * H5B2_insert was called. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * koziol@hdfgroup.org + * Dec 24 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5B2__update_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, + unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, + H5B2_update_status_t *status, H5B2_nodepos_t curr_pos, void *udata, + H5B2_modify_t op, void *op_data) +{ + H5B2_internal_t *internal = NULL; /* Pointer to internal node */ + unsigned internal_flags = H5AC__NO_FLAGS_SET; + int cmp; /* Comparison value of records */ + unsigned idx; /* Location of record which matches key */ + H5B2_nodepos_t next_pos = H5B2_POS_MIDDLE; /* Position of node */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments. */ + HDassert(hdr); + HDassert(depth > 0); + HDassert(curr_node_ptr); + HDassert(H5F_addr_defined(curr_node_ptr->addr)); + + /* Lock current B-tree node */ + if(NULL == (internal = H5B2__protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC__NO_FLAGS_SET))) + HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node") + + /* Sanity check number of records */ + HDassert(internal->nrec == curr_node_ptr->node_nrec); + + /* Locate node pointer for child */ + cmp = H5B2__locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native, udata, &idx); + + /* Check for modifying existing record */ + if(0 == cmp) { + hbool_t changed = FALSE; /* Whether the 'modify' callback changed the record */ + + /* Make callback for current record */ + if((op)(H5B2_INT_NREC(internal, hdr, idx), op_data, &changed) < 0) { + /* Make certain that the callback didn't modify the value if it failed */ + HDassert(changed == FALSE); + + HGOTO_ERROR(H5E_BTREE, H5E_CANTMODIFY, FAIL, "'modify' callback failed for B-tree update operation") + } /* end if */ + + /* Mark the node as dirty if it changed */ + internal_flags |= (changed ? H5AC__DIRTIED_FLAG : 0); + + /* Indicate that the record was modified */ + *status = H5B2_UPDATE_MODIFY_DONE; + } /* end if */ + else { + /* Adjust index to leave room for node to insert */ + if(cmp > 0) + idx++; + + /* Check if this node is left/right-most */ + if(H5B2_POS_MIDDLE != curr_pos) { + if(idx == 0) { + if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) + next_pos = H5B2_POS_LEFT; + } /* end if */ + else if(idx == internal->nrec) { + if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) + next_pos = H5B2_POS_RIGHT; + } /* end else */ + } /* end if */ + + /* Attempt to update record in child */ + if(depth > 1) { + if(H5B2__update_internal(hdr, dxpl_id, (uint16_t)(depth - 1), &internal_flags, &internal->node_ptrs[idx], status, next_pos, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in internal B-tree node") + } /* end if */ + else { + if(H5B2__update_leaf(hdr, dxpl_id, &internal->node_ptrs[idx], status, next_pos, udata, op, op_data) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "unable to update record in leaf B-tree node") + } /* end else */ + + /* Take actions based on child's status report */ + switch(*status) { + case H5B2_UPDATE_MODIFY_DONE: + /* No action */ + break; + + case H5B2_UPDATE_INSERT_DONE: + /* Mark node as dirty */ + internal_flags |= H5AC__DIRTIED_FLAG; + + /* Update total record count for node pointer to current node */ + curr_node_ptr->all_nrec++; + break; + + case H5B2_UPDATE_INSERT_CHILD_FULL: + /* Split/redistribute this node */ + if(internal->nrec == hdr->node_info[depth].split_nrec) { + hbool_t could_split = FALSE; /* Whether the child node could split */ + +#ifdef QAK +HDfprintf(stderr, "%s: idx = %u, internal->nrec = %u\n", FUNC, idx, internal->nrec); +HDfprintf(stderr, "%s: hdr->node_info[%u].split_nrec = %u\n", FUNC, (unsigned)depth, (unsigned)hdr->node_info[depth].split_nrec); +HDfprintf(stderr, "%s: hdr->node_info[%u].split_nrec = %u\n", FUNC, (unsigned)(depth - 1), (unsigned)hdr->node_info[depth - 1].split_nrec); +#endif /* QAK */ + if(idx == 0) { /* Left-most child */ +#ifdef QAK +HDfprintf(stderr, "%s: Left-most child\n", FUNC); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)idx, (unsigned)internal->node_ptrs[idx].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx + 1), (unsigned)internal->node_ptrs[idx + 1].node_nrec); +#endif /* QAK */ + /* Check for left-most child and its neighbor being close to full */ + if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + } /* end if */ + else if(idx == internal->nrec) { /* Right-most child */ +#ifdef QAK +HDfprintf(stderr, "%s: Right-most child\n", FUNC); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx - 1), (unsigned)internal->node_ptrs[idx - 1].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)idx, (unsigned)internal->node_ptrs[idx].node_nrec); +#endif /* QAK */ + /* Check for right-most child and its neighbor being close to full */ + if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + } /* end else-if */ + else { /* Middle child */ +#ifdef QAK +HDfprintf(stderr, "%s: Middle child\n", FUNC); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx - 1), (unsigned)internal->node_ptrs[idx - 1].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)idx, (unsigned)internal->node_ptrs[idx].node_nrec); +HDfprintf(stderr, "%s: internal->node_ptrs[%u].node_nrec = %u\n", FUNC, (unsigned)(idx + 1), (unsigned)internal->node_ptrs[idx + 1].node_nrec); +#endif /* QAK */ + /* Check for middle child and its left neighbor being close to full */ + if((internal->node_ptrs[idx - 1].node_nrec + internal->node_ptrs[idx].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + /* Check for middle child and its right neighbor being close to full */ + else if((internal->node_ptrs[idx].node_nrec + internal->node_ptrs[idx + 1].node_nrec) + >= ((hdr->node_info[depth - 1].split_nrec * 2) - 1)) + could_split = TRUE; + } /* end if */ + + /* If this node is full and the child node insertion could + * cause a split, punt back up to caller, leaving the + * "insert child full" status. + */ + if(could_split) { + /* Release the internal B-tree node */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + internal = NULL; + +#ifdef QAK +HDfprintf(stderr, "%s: Punting back to caller\n", FUNC); +#endif /* QAK */ + /* Punt back to caller */ + HGOTO_DONE(SUCCEED); + } /* end if */ + } /* end if */ + + /* Release the internal B-tree node */ + if(H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + internal = NULL; + + /* Indicate that the record was inserted */ + *status = H5B2_UPDATE_INSERT_DONE; + + /* Dodge sideways into inserting a record into this node */ + if(H5B2__insert_internal(hdr, dxpl_id, depth, parent_cache_info_flags_ptr, curr_node_ptr, curr_pos, udata) < 0) + HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, FAIL, "unable to insert record into internal B-tree node") + break; + + case H5B2_UPDATE_UNKNOWN: + default: + HDassert(0 && "Invalid update status"); + HGOTO_ERROR(H5E_BTREE, H5E_CANTUPDATE, FAIL, "invalid update status") + } /* end switch */ + } /* end else */ + +done: + /* Release the internal B-tree node */ + if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, internal_flags) < 0) + HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5B2__update_internal() */ + + +/*------------------------------------------------------------------------- * Function: H5B2__create_leaf * * Purpose: Creates empty leaf node of a B-tree and update node pointer diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index f58850e..d6b6c04 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -228,6 +228,14 @@ typedef enum H5B2_nodepos_t { H5B2_POS_MIDDLE /* Node is neither right or left-most in tree */ } H5B2_nodepos_t; +/* Update status */ +typedef enum H5B2_update_status_t { + H5B2_UPDATE_UNKNOWN, /* Unknown update status (initial state) */ + H5B2_UPDATE_MODIFY_DONE, /* Update successfully modified existing record */ + H5B2_UPDATE_INSERT_DONE, /* Update inserted record successfully */ + H5B2_UPDATE_INSERT_CHILD_FULL /* Update will insert record, but child is full */ +} H5B2_update_status_t; + /* Callback info for loading a free space header into the cache */ typedef struct H5B2_hdr_cache_ud_t { H5F_t *f; /* File that v2 b-tree header is within */ @@ -252,7 +260,7 @@ typedef struct H5B2_leaf_cache_ud_t { #ifdef H5B2_TESTING /* Node information for testing */ -typedef struct { +typedef struct H5B2_node_info_test_t { unsigned depth; /* Depth of node */ unsigned nrec; /* Number of records in node */ } H5B2_node_info_test_t; @@ -281,6 +289,13 @@ H5FL_EXTERN(H5B2_leaf_t); /* Internal v2 B-tree testing class */ #ifdef H5B2_TESTING H5_DLLVAR const H5B2_class_t H5B2_TEST[1]; +H5_DLLVAR const H5B2_class_t H5B2_TEST2[1]; + +/* B-tree record for testing H5B2_TEST2 class */ +typedef struct H5B2_test_rec_t { + hsize_t key; /* Key for record */ + hsize_t val; /* Value for record */ +} H5B2_test_rec_t; #endif /* H5B2_TESTING */ /* Array of v2 B-tree client ID -> client class mappings */ @@ -327,12 +342,22 @@ H5_DLL herr_t H5B2__leaf_free(H5B2_leaf_t *l); H5_DLL herr_t H5B2__internal_free(H5B2_internal_t *i); /* Routines for inserting records */ +H5_DLL herr_t H5B2__insert_hdr(H5B2_hdr_t *hdr, hid_t dxpl_id, void *udata); H5_DLL herr_t H5B2__insert_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, unsigned *parent_cache_info_flags_ptr, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata); H5_DLL herr_t H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr, H5B2_nodepos_t curr_pos, void *udata); +/* Routines for update records */ +H5_DLL herr_t H5B2__update_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, + uint16_t depth, unsigned *parent_cache_info_flags_ptr, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, + H5B2_node_ptr_t *curr_node_ptr, H5B2_update_status_t *status, + H5B2_nodepos_t curr_pos, void *udata, H5B2_modify_t op, void *op_data); + /* Routines for iterating over nodes/records */ H5_DLL herr_t H5B2__iterate_node(H5B2_hdr_t *hdr, hid_t dxpl_id, uint16_t depth, const H5B2_node_ptr_t *curr_node, H5B2_operator_t op, void *op_data); diff --git a/src/H5B2private.h b/src/H5B2private.h index 9e3c2d7..ff94680 100644 --- a/src/H5B2private.h +++ b/src/H5B2private.h @@ -54,6 +54,7 @@ typedef enum H5B2_subid_t { H5B2_SOHM_INDEX_ID, /* B-tree is an index for shared object header messages */ H5B2_ATTR_DENSE_NAME_ID, /* B-tree is for indexing 'name' field for "dense" attribute storage on objects */ H5B2_ATTR_DENSE_CORDER_ID, /* B-tree is for indexing 'creation order' field for "dense" attribute storage on objects */ + H5B2_TEST2_ID, /* Another B-tree is for testing (do not use for actual data) */ H5B2_NUM_BTREE_ID /* Number of B-tree IDs (must be last) */ } H5B2_subid_t; @@ -94,8 +95,6 @@ struct H5B2_class_t { herr_t (*decode)(const uint8_t *raw, void *record, void *ctx); /* Decode record from disk storage form to native form */ herr_t (*debug)(FILE *stream, int indent, int fwidth, /* Print a record for debugging */ const void *record, const void *ctx); - void *(*crt_dbg_ctx)(H5F_t *f, hid_t dxpl_id, haddr_t obj_addr); /* Create debugging context */ - herr_t (*dst_dbg_ctx)(void *dbg_ctx); /* Destroy debugging context */ }; /* v2 B-tree creation parameters */ @@ -140,6 +139,8 @@ H5_DLL herr_t H5B2_neighbor(H5B2_t *bt2, hid_t dxpl_id, H5B2_compare_t range, void *udata, H5B2_found_t op, void *op_data); H5_DLL herr_t H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, void *op_data); +H5_DLL herr_t H5B2_update(H5B2_t *bt2, hid_t dxpl_id, void *udata, + H5B2_modify_t op, void *op_data); H5_DLL herr_t H5B2_remove(H5B2_t *b2, hid_t dxpl_id, void *udata, H5B2_remove_t op, void *op_data); H5_DLL herr_t H5B2_remove_by_idx(H5B2_t *bt2, hid_t dxpl_id, diff --git a/src/H5B2test.c b/src/H5B2test.c index 87fddf7..e0c96fb 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -61,6 +61,7 @@ typedef struct H5B2_test_ctx_t { /* Local Prototypes */ /********************/ +/* v2 B-tree driver callbacks for 'test' B-trees */ static void *H5B2__test_crt_context(void *udata); static herr_t H5B2__test_dst_context(void *ctx); static herr_t H5B2__test_store(void *nrecord, const void *udata); @@ -69,13 +70,21 @@ static herr_t H5B2__test_encode(uint8_t *raw, const void *nrecord, void *ctx); static herr_t H5B2__test_decode(const uint8_t *raw, void *nrecord, void *ctx); static herr_t H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); -static void *H5B2__test_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); + +/* v2 B-tree driver callbacks for 'test2' B-trees */ +static herr_t H5B2__test2_store(void *nrecord, const void *udata); +static herr_t H5B2__test2_compare(const void *rec1, const void *rec2); +static herr_t H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *ctx); +static herr_t H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *ctx); +static herr_t H5B2__test2_debug(FILE *stream, int indent, int fwidth, + const void *record, const void *_udata); /*********************/ /* Package Variables */ /*********************/ +/* Class structure for testing simple B-tree records */ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ H5B2_TEST_ID, /* Type of B-tree */ "H5B2_TEST_ID", /* Name of B-tree class */ @@ -86,9 +95,21 @@ const H5B2_class_t H5B2_TEST[1]={{ /* B-tree class information */ H5B2__test_compare, /* Record comparison callback */ H5B2__test_encode, /* Record encoding callback */ H5B2__test_decode, /* Record decoding callback */ - H5B2__test_debug, /* Record debugging callback */ - H5B2__test_crt_dbg_context, /* Create debugging context */ - H5B2__test_dst_context /* Destroy debugging context */ + H5B2__test_debug /* Record debugging callback */ +}}; + +/* Class structure for testing key/value B-tree records */ +const H5B2_class_t H5B2_TEST2[1]={{ /* B-tree class information */ + H5B2_TEST2_ID, /* Type of B-tree */ + "H5B2_TEST2_ID", /* Name of B-tree class */ + sizeof(H5B2_test_rec_t), /* Size of native record */ + H5B2__test_crt_context, /* Create client callback context */ + H5B2__test_dst_context, /* Destroy client callback context */ + H5B2__test2_store, /* Record storage callback */ + H5B2__test2_compare, /* Record comparison callback */ + H5B2__test2_encode, /* Record encoding callback */ + H5B2__test2_decode, /* Record decoding callback */ + H5B2__test2_debug /* Record debugging callback */ }}; @@ -310,42 +331,139 @@ H5B2__test_debug(FILE *stream, int indent, int fwidth, const void *record, /*------------------------------------------------------------------------- - * Function: H5B2__test_crt_dbg_context + * Function: H5B2__test2_store * - * Purpose: Create context for debugging callback + * Purpose: Store native information into record for B-tree * - * Return: Success: non-NULL - * Failure: NULL + * Return: Success: non-negative + * Failure: negative * * Programmer: Quincey Koziol - * Tuesday, December 1, 2009 + * Friday, December 25, 2015 * *------------------------------------------------------------------------- */ -static void * -H5B2__test_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) +static herr_t +H5B2__test2_store(void *nrecord, const void *udata) { - H5B2_test_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ + FUNC_ENTER_STATIC_NOERR - FUNC_ENTER_STATIC + *(H5B2_test_rec_t *)nrecord = *(const H5B2_test_rec_t *)udata; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_store() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_compare + * + * Purpose: Compare two native information records, according to some key + * + * Return: <0 if rec1 < rec2 + * =0 if rec1 == rec2 + * >0 if rec1 > rec2 + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_compare(const void *rec1, const void *rec2) +{ + FUNC_ENTER_STATIC_NOERR + + FUNC_LEAVE_NOAPI((herr_t)(((const H5B2_test_rec_t *)rec1)->key - ((const H5B2_test_rec_t *)rec2)->key)) +} /* H5B2__test2_compare() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_encode + * + * Purpose: Encode native information into raw form for storing on disk + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_encode(uint8_t *raw, const void *nrecord, void *_ctx) +{ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ + + FUNC_ENTER_STATIC_NOERR /* Sanity check */ - HDassert(f); + HDassert(ctx); - /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5B2_test_ctx_t))) - HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, NULL, "can't allocate callback context") + H5F_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); + H5F_ENCODE_LENGTH_LEN(raw, ((const H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); - /* Determine the size of addresses & lengths in the file */ - ctx->sizeof_size = H5F_SIZEOF_SIZE(f); + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_encode() */ - /* Set return value */ - ret_value = ctx; + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_decode + * + * Purpose: Decode raw disk form of record into native form + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_decode(const uint8_t *raw, void *nrecord, void *_ctx) +{ + H5B2_test_ctx_t *ctx = (H5B2_test_ctx_t *)_ctx; /* Callback context structure */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5B2__test_crt_dbg_context() */ + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(ctx); + + H5F_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->key, ctx->sizeof_size); + H5F_DECODE_LENGTH_LEN(raw, ((H5B2_test_rec_t *)nrecord)->val, ctx->sizeof_size); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_decode() */ + + +/*------------------------------------------------------------------------- + * Function: H5B2__test2_debug + * + * Purpose: Debug native form of record + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5B2__test2_debug(FILE *stream, int indent, int fwidth, const void *record, + const void H5_ATTR_UNUSED *_udata) +{ + FUNC_ENTER_STATIC_NOERR + + HDassert(record); + + HDfprintf(stream, "%*s%-*s (%Hu, %Hu)\n", indent, "", fwidth, "Record:", + ((const H5B2_test_rec_t *)record)->key, + ((const H5B2_test_rec_t *)record)->val); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5B2__test2_debug() */ /*------------------------------------------------------------------------- diff --git a/src/H5Gbtree2.c b/src/H5Gbtree2.c index b464930..1a99b12 100644 --- a/src/H5Gbtree2.c +++ b/src/H5Gbtree2.c @@ -114,9 +114,7 @@ const H5B2_class_t H5G_BT2_NAME[1]={{ /* B-tree class information */ H5G_dense_btree2_name_compare, /* Record comparison callback */ H5G_dense_btree2_name_encode, /* Record encoding callback */ H5G_dense_btree2_name_decode, /* Record decoding callback */ - H5G_dense_btree2_name_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5G_dense_btree2_name_debug /* Record debugging callback */ }}; /* v2 B-tree class for indexing 'creation order' field of links */ @@ -130,9 +128,7 @@ const H5B2_class_t H5G_BT2_CORDER[1]={{ /* B-tree class information */ H5G_dense_btree2_corder_compare, /* Record comparison callback */ H5G_dense_btree2_corder_encode, /* Record encoding callback */ H5G_dense_btree2_corder_decode, /* Record decoding callback */ - H5G_dense_btree2_corder_debug, /* Record debugging callback */ - NULL, /* Create debugging context */ - NULL /* Destroy debugging context */ + H5G_dense_btree2_corder_debug /* Record debugging callback */ }}; /*****************************/ diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index d82de93..a79bf58 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -71,7 +71,6 @@ typedef struct H5HF_huge_bt2_ctx_t { /* Common callbacks */ static void *H5HF__huge_bt2_crt_context(void *udata); static herr_t H5HF__huge_bt2_dst_context(void *ctx); -static void *H5HF__huge_bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /* Callbacks for indirect objects */ static herr_t H5HF__huge_bt2_indir_store(void *native, const void *udata); @@ -127,9 +126,7 @@ const H5B2_class_t H5HF_HUGE_BT2_INDIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_indir_compare, /* Record comparison callback */ H5HF__huge_bt2_indir_encode, /* Record encoding callback */ H5HF__huge_bt2_indir_decode, /* Record decoding callback */ - H5HF__huge_bt2_indir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_indir_debug /* Record debugging callback */ }}; /* v2 B-tree class for indirectly accessed, filtered 'huge' objects */ @@ -143,9 +140,7 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_INDIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_filt_indir_compare, /* Record comparison callback */ H5HF__huge_bt2_filt_indir_encode, /* Record encoding callback */ H5HF__huge_bt2_filt_indir_decode, /* Record decoding callback */ - H5HF__huge_bt2_filt_indir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_filt_indir_debug /* Record debugging callback */ }}; /* v2 B-tree class for directly accessed 'huge' objects */ @@ -159,9 +154,7 @@ const H5B2_class_t H5HF_HUGE_BT2_DIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_dir_compare, /* Record comparison callback */ H5HF__huge_bt2_dir_encode, /* Record encoding callback */ H5HF__huge_bt2_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_dir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_dir_debug /* Record debugging callback */ }}; /* v2 B-tree class for directly accessed, filtered 'huge' objects */ @@ -175,9 +168,7 @@ const H5B2_class_t H5HF_HUGE_BT2_FILT_DIR[1]={{ /* B-tree class information */ H5HF__huge_bt2_filt_dir_compare, /* Record comparison callback */ H5HF__huge_bt2_filt_dir_encode, /* Record encoding callback */ H5HF__huge_bt2_filt_dir_decode, /* Record decoding callback */ - H5HF__huge_bt2_filt_dir_debug, /* Record debugging callback */ - H5HF__huge_bt2_crt_dbg_context, /* Create debugging context */ - H5HF__huge_bt2_dst_context /* Destroy debugging context */ + H5HF__huge_bt2_filt_dir_debug /* Record debugging callback */ }}; /*****************************/ @@ -270,46 +261,6 @@ H5HF__huge_bt2_dst_context(void *_ctx) /*------------------------------------------------------------------------- - * Function: H5HF__huge_bt2_crt_dbg_context - * - * Purpose: Create context for debugging callback - * - * Return: Success: non-NULL - * Failure: NULL - * - * Programmer: Quincey Koziol - * Tuesday, December 1, 2009 - * - *------------------------------------------------------------------------- - */ -static void * -H5HF__huge_bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) -{ - H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(f); - - /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5HF_huge_bt2_ctx_t))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") - - /* Determine the size of addresses & lengths in the file */ - ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); - ctx->sizeof_size = H5F_SIZEOF_SIZE(f); - - /* Set return value */ - ret_value = ctx; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5HF__huge_bt2_crt_dbg_context() */ - - -/*------------------------------------------------------------------------- * Function: H5HF__huge_bt2_indir_found * * Purpose: Retrieve record for indirectly accessed 'huge' object, when diff --git a/src/H5SMbtree2.c b/src/H5SMbtree2.c index e533ae8..0110c1e 100644 --- a/src/H5SMbtree2.c +++ b/src/H5SMbtree2.c @@ -50,7 +50,6 @@ static herr_t H5SM__bt2_dst_context(void *ctx); static herr_t H5SM__bt2_store(void *native, const void *udata); static herr_t H5SM__bt2_debug(FILE *stream, int indent, int fwidth, const void *record, const void *_udata); -static void *H5SM__bt2_crt_dbg_context(H5F_t *f, hid_t dxpl_id, haddr_t addr); /*****************************/ @@ -67,9 +66,7 @@ const H5B2_class_t H5SM_INDEX[1]={{ /* B-tree class information */ H5SM__message_compare, /* Record comparison callback */ H5SM__message_encode, /* Record encoding callback */ H5SM__message_decode, /* Record decoding callback */ - H5SM__bt2_debug, /* Record debugging callback */ - H5SM__bt2_crt_dbg_context, /* Create debugging context */ - H5SM__bt2_dst_context /* Destroy debugging context */ + H5SM__bt2_debug /* Record debugging callback */ }}; @@ -218,45 +215,6 @@ H5SM__bt2_debug(FILE *stream, int indent, int fwidth, /*------------------------------------------------------------------------- - * Function: H5SM__bt2_crt_dbg_context - * - * Purpose: Create context for debugging callback - * - * Return: Success: non-NULL - * Failure: NULL - * - * Programmer: Quincey Koziol - * Tuesday, December 1, 2009 - * - *------------------------------------------------------------------------- - */ -static void * -H5SM__bt2_crt_dbg_context(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t H5_ATTR_UNUSED addr) -{ - H5SM_bt2_ctx_t *ctx; /* Callback context structure */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* Sanity check */ - HDassert(f); - - /* Allocate callback context */ - if(NULL == (ctx = H5FL_MALLOC(H5SM_bt2_ctx_t))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate callback context") - - /* Determine the size of addresses & lengths in the file */ - ctx->sizeof_addr = H5F_SIZEOF_ADDR(f); - - /* Set return value */ - ret_value = ctx; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5SM__bt2_crt_dbg_context() */ - - -/*------------------------------------------------------------------------- * Function: H5SM_bt2_convert_to_list_op * * Purpose: An H5B2_remove_t callback function to convert a SOHM diff --git a/test/btree2.c b/test/btree2.c index 7a2432c..04c94fd 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -36,8 +36,11 @@ const char *FILENAME[] = { }; #define INSERT_SPLIT_ROOT_NREC 63 -#define INSERT_MANY (1000*1000) -#define FIND_MANY (INSERT_MANY/100) +#define INSERT_SPLIT_ROOT_NREC_REC 64 +#define INSERT_MANY (1000 * 1000) +#define INSERT_MANY_REC (2600 * 1000) +#define FIND_MANY (INSERT_MANY / 100) +#define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 #define DELETE_SMALL 20 #define DELETE_MEDIUM 200 @@ -63,7 +66,7 @@ typedef struct bt2_test_param_t { *------------------------------------------------------------------------- */ static int -init_cparam(H5B2_create_t *cparam) +init_cparam(H5B2_create_t *cparam, H5B2_create_t *cparam2) { /* Wipe out background */ HDmemset(cparam, 0, sizeof(*cparam)); @@ -75,6 +78,16 @@ init_cparam(H5B2_create_t *cparam) cparam->split_percent = 100; cparam->merge_percent = 40; + /* Wipe out background */ + HDmemset(cparam2, 0, sizeof(*cparam2)); + + /* General parameters */ + cparam2->cls = H5B2_TEST2; + cparam2->node_size = (size_t)1024; + cparam2->rrec_size = (size_t)16; + cparam2->split_percent = 100; + cparam2->merge_percent = 40; + return(0); } /* init_cparam() */ @@ -154,6 +167,47 @@ error: /*------------------------------------------------------------------------- + * Function: reopen_file + * + * Purpose: Re-open the file + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Monday, December 28, 2015 + * + *------------------------------------------------------------------------- + */ +static int +reopen_file(hid_t *file, H5F_t **f, hid_t fapl) +{ + char filename[1024]; /* Filename to use */ + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Create the file to work on */ + if((*file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (*f = (H5F_t *)H5I_object(*file))) + STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(*f) < 0) + STACK_ERROR + + /* Success */ + return(0); + +error: + return(-1); +} /* end create_file() */ + + +/*------------------------------------------------------------------------- * Function: reopen_btree * * Purpose: Perform common "re-open" operations on B-tree for testing @@ -237,11 +291,11 @@ error: *------------------------------------------------------------------------- */ static int -check_node_depth(H5B2_t *bt2, hid_t dxpl, hsize_t record, unsigned depth) +check_node_depth(H5B2_t *bt2, hid_t dxpl, void *record, unsigned depth) { int rec_depth; /* Depth of record in B-tree */ - if((rec_depth = H5B2_get_node_depth_test(bt2, dxpl, &record)) < 0) + if((rec_depth = H5B2_get_node_depth_test(bt2, dxpl, record)) < 0) FAIL_STACK_ERROR if((unsigned)rec_depth != depth) TEST_ERROR @@ -285,7 +339,7 @@ check_node_info(H5B2_t *bt2, hid_t dxpl, hsize_t record, error: return(-1); -} /* end check_node_depth() */ +} /* end check_node_info() */ /*------------------------------------------------------------------------- @@ -294,7 +348,6 @@ error: * Purpose: v2 B-tree iterator callback * * Return: Success: 0 - * * Failure: 1 * * Programmer: Quincey Koziol @@ -317,12 +370,41 @@ iter_cb(const void *_record, void *_op_data) /*------------------------------------------------------------------------- + * Function: iter_rec_cb + * + * Purpose: v2 B-tree iterator callback for H5B2_test_rec_t records + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +iter_rec_cb(const void *_record, void *_op_data) +{ + const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; + H5B2_test_rec_t *idx = (H5B2_test_rec_t *)_op_data; + + if(record->key != idx->key) + return(H5_ITER_ERROR); + if(record->val != idx->val) + return(H5_ITER_ERROR); + + idx->key++; + idx->val += 2; + return(H5_ITER_CONT); +} /* end iter_rec_cb() */ + + +/*------------------------------------------------------------------------- * Function: find_cb * * Purpose: v2 B-tree find callback * * Return: Success: TRUE/FALSE - * * Failure: FAIL * * Programmer: Quincey Koziol @@ -344,6 +426,33 @@ find_cb(const void *_record, void *_op_data) /*------------------------------------------------------------------------- + * Function: find_rec_cb + * + * Purpose: v2 B-tree find callback for H5B2_test_rec_t records + * + * Return: Success: TRUE/FALSE + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +find_rec_cb(const void *_record, void *_op_data) +{ + const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; + H5B2_test_rec_t *search = (H5B2_test_rec_t *)_op_data; + + if(record->key != search->key) + return(FALSE); + + search->val = record->val; + return(TRUE); +} /* end find_rec_cb() */ + + +/*------------------------------------------------------------------------- * Function: find_dec_cb * * Purpose: v2 B-tree find callback for indexing in decreasing order @@ -372,6 +481,34 @@ find_dec_cb(const void *_record, void *_op_data) /*------------------------------------------------------------------------- + * Function: index_rec_cb + * + * Purpose: v2 B-tree index callback for H5B2_test_rec_t records + * + * Return: Success: TRUE/FALSE + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +index_rec_cb(const void *_record, void *_op_data) +{ + const H5B2_test_rec_t *record = (const H5B2_test_rec_t *)_record; + H5B2_test_rec_t *search = (H5B2_test_rec_t *)_op_data; + + HDassert(record); + HDassert(search); + + search->key = record->key; + search->val = record->val; + return(TRUE); +} /* end index_rec_cb() */ + + +/*------------------------------------------------------------------------- * Function: neighbor_cb * * Purpose: v2 B-tree neighbor callback @@ -425,6 +562,57 @@ modify_cb(void *_record, void *_op_data, hbool_t *changed) /*------------------------------------------------------------------------- + * Function: modify_rec_cb + * + * Purpose: v2 B-tree modify callback for H5B2_test_rec_t records + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Friday, December 25, 2015 + * + *------------------------------------------------------------------------- + */ +static int +modify_rec_cb(void *_record, void *_op_data, hbool_t *changed) +{ + H5B2_test_rec_t *record = (H5B2_test_rec_t *)_record; + H5B2_test_rec_t *modify = (H5B2_test_rec_t *)_op_data; + + HDassert(record->key == modify->key); + record->val = modify->val; + *changed = TRUE; + + return(0); +} /* end modify_rec_cb() */ + + +/*------------------------------------------------------------------------- + * Function: no_modify_cb + * + * Purpose: v2 B-tree modify callback for updates which shouldn't change + * the record (ie. inserting not modifying) + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Wednesday, December 23, 2015 + * + *------------------------------------------------------------------------- + */ +static int +no_modify_cb(void H5_ATTR_UNUSED *_record, void H5_ATTR_UNUSED *_op_data, + hbool_t *changed) +{ + *changed = FALSE; + + return(1); +} /* end no_modify_cb() */ + + +/*------------------------------------------------------------------------- * Function: remove_cb * * Purpose: v2 B-tree remove callback @@ -717,7 +905,8 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC - 1); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)0) < 0) + record = (hsize_t)33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -734,7 +923,8 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)1) < 0) + record = (hsize_t)33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -755,7 +945,8 @@ test_insert_split_root(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + 2); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)33, (unsigned)1) < 0) + record = (hsize_t)33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -889,7 +1080,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)INSERT_SPLIT_ROOT_NREC, (unsigned)1) < 0) + record = (hsize_t)INSERT_SPLIT_ROOT_NREC; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -909,7 +1101,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1), (unsigned)1) < 0) + record = (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -940,7 +1133,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)(INSERT_SPLIT_ROOT_NREC / 2), (unsigned)1) < 0) + record = (hsize_t)(INSERT_SPLIT_ROOT_NREC / 2); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -959,7 +1153,8 @@ test_insert_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1), (unsigned)1) < 0) + record = (hsize_t)((INSERT_SPLIT_ROOT_NREC / 2) + (INSERT_SPLIT_ROOT_NREC / 4) + 1); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -1041,7 +1236,7 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1061,10 +1256,10 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 31; - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 63; - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -1096,7 +1291,7 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1115,9 +1310,11 @@ test_insert_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)62, (unsigned)1) < 0) + record = 62; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0) + record = 94; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -1202,7 +1399,7 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (2 * INSERT_SPLIT_ROOT_NREC); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1222,10 +1419,10 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC + (INSERT_SPLIT_ROOT_NREC / 2) + 1); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1244,9 +1441,11 @@ test_insert_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)52, (unsigned)1) < 0) + record = 52; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)105, (unsigned)1) < 0) + record = 105; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1343,7 +1542,7 @@ test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = (2 * INSERT_SPLIT_ROOT_NREC) + (INSERT_SPLIT_ROOT_NREC / 2); - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1362,11 +1561,14 @@ test_insert_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = 3 * INSERT_SPLIT_ROOT_NREC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)62, (unsigned)1) < 0) + record = 62; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0) + record = 94; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)126, (unsigned)1) < 0) + record = 126; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1464,7 +1666,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)948, (unsigned)2) < 0) + record = 948; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1513,7 +1716,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, FAIL_STACK_ERROR /* Check with B-tree */ - if(check_node_depth(bt2, dxpl, (hsize_t)948, (unsigned)2) < 0) + record = 948; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR /* Attempt to find existant record in internal node of level-2 B-tree */ @@ -1522,7 +1726,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, FAIL_STACK_ERROR /* Check with B-tree */ - if(check_node_depth(bt2, dxpl, (hsize_t)505, (unsigned)1) < 0) + record = 505; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Attempt to find existant record in leaf of level-2 B-tree */ @@ -1531,7 +1736,8 @@ test_insert_make_level2(hid_t fapl, const H5B2_create_t *cparam, FAIL_STACK_ERROR /* Check with B-tree */ - if(check_node_depth(bt2, dxpl, (hsize_t)555, (unsigned)0) < 0) + record = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Attempt to index non-existant record in level-2 B-tree */ @@ -1642,11 +1848,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1859, (unsigned)1) < 0) + record = 1859; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1921, (unsigned)0) < 0) + record = 1921; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1663,11 +1872,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1875, (unsigned)1) < 0) + record = 1875; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1922, (unsigned)0) < 0) + record = 1922; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1683,11 +1895,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 29) + (INSERT_SPLIT_ROOT_NREC / 2) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)94, (unsigned)1) < 0) + record = 94; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)32, (unsigned)0) < 0) + record = 32; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Add more records to left-most leaf, to force a 2->1 split and then a @@ -1704,11 +1919,14 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)47, (unsigned)1) < 0) + record = 47; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)0, (unsigned)0) < 0) + record = 0; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1724,13 +1942,17 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + 1; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) /* Record in root node */ + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) /* Record in root node */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)535, (unsigned)1) < 0) /* Record in middle node before insertion point */ + record = 535; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)630, (unsigned)1) < 0) /* Record in middle node after insertion point */ + record = 630; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)568, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ + record = 568; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ TEST_ERROR /* Add more records to middle leaf, to force a split and a 3 node redistribution on middle leaf */ @@ -1745,13 +1967,17 @@ test_insert_level2_leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 30) + (INSERT_SPLIT_ROOT_NREC / 2) + 2; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)1008, (unsigned)2) < 0) /* Record in root node */ + record = 1008; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) /* Record in root node */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)524, (unsigned)1) < 0) /* Record in middle node before insertion point */ + record = 524; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node before insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)577, (unsigned)1) < 0) /* Record in middle node after insertion point */ + record = 577; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) /* Record in middle node after insertion point */ TEST_ERROR - if(check_node_depth(bt2, dxpl, (hsize_t)568, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ + record = 568; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) /* Record in leaf node just after insertion point */ TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1851,13 +2077,13 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 1797; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1859; /* Right-most record in right-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -1877,16 +2103,16 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 1828; /* Next-to-right-most record in right-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1860; /* Right-most record in right-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1891; /* Right-most record in right-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1903,13 +2129,13 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 63; /* Left-most record in left-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 1; /* Left-most record in left-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Add another record to left-most leaf, to force a 1->2 node split on left leaf */ @@ -1923,16 +2149,16 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 63; /* Left-most record in left-most internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 32; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 0; /* Left-most record in left-most leaf */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -1949,16 +2175,16 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 504; /* Record in internal node just before insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 568; /* Record in internal node just after insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 506; /* Record in leaf node just after insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Add another record to middle leaf, to force a node split on middle leaf */ @@ -1972,19 +2198,19 @@ test_insert_level2_leaf_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 946; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 504; /* Left-most record of split in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 537; /* Middle record of split in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 568; /* Right-most record of split in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 506; /* Record in leaf node just after insertion point */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2081,13 +2307,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1318; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3114; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3145; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2105,13 +2331,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1822; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3114; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3146; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2128,13 +2354,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1822; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 436; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 374; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Force left-most internal node to redistribute */ @@ -2150,13 +2376,13 @@ test_insert_level2_2internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1570; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 61; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 0; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2253,13 +2479,13 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 2759; /* Record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 4555; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 4586; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2277,16 +2503,16 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 2759; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3704; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 4555; /* Right-most record in right internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 4387; /* Right-most record in right leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR PASSED(); @@ -2303,13 +2529,13 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 2759; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 932; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 870; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Force left-most internal node to split */ @@ -2325,16 +2551,16 @@ test_insert_level2_2internal_split(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 870; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 1814; /* Next-to-left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 61; /* Left-most record in left internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 0; /* Left-most record in left leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2436,19 +2662,19 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 2267; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3199; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3137; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2468,19 +2694,19 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3104; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3137; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3135; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2498,21 +2724,21 @@ test_insert_level2_3internal_redistrib(hid_t fapl, const H5B2_create_t *cparam, if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR record = 1574; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR record = 3104; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR #ifdef NONE record = 2862; /* Record to left of insertion point in right internal node (now) */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR #endif /* NONE */ record = 3137; /* Record to right of insertion point in right internal node (now) */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 3135; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR /* Check for closing & re-opening the B-tree */ @@ -2588,126 +2814,2129 @@ test_insert_level2_3internal_split(hid_t fapl, const H5B2_create_t *cparam, */ TESTING("B-tree insert: split 3 internals to 4 in level 2 B-tree"); - /* Create the file for the test */ - if(create_file(&file, &f, fapl) < 0) + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 3 internal nodes */ + /* (and fill right internal node) */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 31); u++) { + record = u; + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC * 74); u++) { + record = u + ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3); + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 74; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record = 1889; /* Left record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 3703; /* Right record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 1952; /* Record to left of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2884; /* Record to right of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2822; /* Record just after insertion point in leaf node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Insert records to fill up middle internal node */ + for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { + record = u + (INSERT_SPLIT_ROOT_NREC * 31); + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record = 1889; /* Left record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 3703; /* Right record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 2789; /* Record to left of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2822; /* Record to right of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2823; /* Record just above insertion point in leaf node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert record to split middle internal node */ + record = u + (INSERT_SPLIT_ROOT_NREC * 31); + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record = 1889; /* Left record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 2789; /* Middle record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + record = 3703; /* Right record in root node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR +#ifdef NONE + record = 3049; /* Record to left of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR +#endif /* NONE */ + record = 2822; /* Record to right of insertion point in middle internal node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record = 2823; /* Record just above insertion point in leaf node */ + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx = 0; + if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_insert_level2_3internal_split() */ + + +/*------------------------------------------------------------------------- + * Function: test_insert_lots + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts many + * records in random order, enough to make at a level 4 B-tree. + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, February 19, 2005 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_insert_lots(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + char filename[1024]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + hsize_t record; /* Record to insert into tree */ + hsize_t idx; /* Index within B-tree, for iterator */ + time_t curr_time; /* Current time, for seeding random number generator */ + hsize_t *records; /* Record #'s for random insertion */ + unsigned u; /* Local index variable */ + unsigned swap_idx; /* Location to swap with when shuffling */ + hsize_t temp_rec; /* Temporary record */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + hsize_t nrec; /* Number of records in B-tree */ + herr_t ret; /* Generic error return value */ + + /* Initialize random number seed */ + curr_time=HDtime(NULL); +#ifdef QAK +curr_time=1109170019; +HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); +#endif /* QAK */ + HDsrandom((unsigned)curr_time); + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree insert: create random level 4 B-tree"); + + /* Allocate space for the records */ + if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) + TEST_ERROR + + /* Initialize record #'s */ + for(u = 0; u < INSERT_MANY; u++) + records[u] = u; + + /* Shuffle record #'s */ + for(u = 0; u < INSERT_MANY; u++) { + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + temp_rec = records[u]; + records[u] = records[swap_idx]; + records[swap_idx] = temp_rec; + } /* end for */ + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Create the file to work on */ + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + STACK_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert random records */ + for(u = 0; u < INSERT_MANY; u++) { + record = records[u]; + if(H5B2_insert(bt2, dxpl, &record) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 4; + bt2_stat.nrecords = INSERT_MANY; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + STACK_ERROR + + /* Re-open the file */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if(H5AC_ignore_tags(f) < 0) + STACK_ERROR + + /* Re-open v2 B-tree */ + if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) + FAIL_STACK_ERROR + + /* Check up on B-tree after re-open */ + bt2_stat.depth = 4; + bt2_stat.nrecords = INSERT_MANY; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx = 0; + if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx != INSERT_MANY) + TEST_ERROR + + /* Attempt to find non-existant record in level-4 B-tree */ + /* (Should not be found, but not fail) */ + idx = INSERT_MANY * 2; + if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE) + TEST_ERROR + + /* Find random records */ + for(u = 0; u < FIND_MANY; u++) { + /* Pick random record */ + idx = (hsize_t)(HDrandom()%INSERT_MANY); + + /* Attempt to find existant record in root of level-4 B-tree */ + if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE) + FAIL_STACK_ERROR + } /* end for */ + + /* Attempt to index non-existant record in level-4 B-tree, in increasing & decreasing order */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_DEC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Find random records */ + for(u = 0; u < FIND_MANY; u++) { + /* Pick random record */ + idx = (hsize_t)(HDrandom() % INSERT_MANY); + + /* Attempt to find existant record in root of level-4 B-tree */ + /* (in increasing order) */ + if(H5B2_index(bt2, dxpl, H5_ITER_INC, idx, find_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Attempt to find existant record in root of level-4 B-tree */ + /* (in decreasing order) */ + if(H5B2_index(bt2, dxpl, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0) + FAIL_STACK_ERROR + } /* end for */ + + PASSED(); + + TESTING("B-tree insert: attempt duplicate record in level 4 B-tree"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + record = INSERT_MANY / 2; + H5E_BEGIN_TRY { + ret = H5B2_insert(bt2, dxpl, &record); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Query the number of records in the B-tree */ + if(H5B2_get_nrec(bt2, &nrec) < 0) + FAIL_STACK_ERROR + + /* Make certain that the # of records is correct */ + if(nrec != INSERT_MANY) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + TEST_ERROR + + PASSED(); + + HDfree(records); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + HDfree(records); + return 1; +} /* test_insert_lots() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_basic + * + * Purpose: Basic tests for the v2 B-tree update operation + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Wednesday, December 23, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_basic(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + herr_t ret; /* Generic error return value */ + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* + * Test insert record into empty v2 B-tree + */ + TESTING("B-tree update: inserting first record in empty B-tree"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + record.key = 42; + record.val = 72; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in B-tree with 1 record */ + /* (Should not be found, but not fail) */ + find.key = 10; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Try again with NULL 'op' */ + /* (Should not be found, but not fail) */ + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in B-tree with 1 record */ + find.key = 42; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != 72) + TEST_ERROR + + /* Try again with NULL 'op' */ + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != TRUE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with 1 record */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with 1 record */ + find.key = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 72) + TEST_ERROR + + PASSED(); + + + /* + * Test update only record into v2 B-tree + */ + TESTING("B-tree update: update only record in B-tree"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + modify.key = 42; + modify.val = 43; + if(H5B2_update(bt2, dxpl, &modify, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in B-tree with 1 record */ + /* (Should not be found, but not fail) */ + find.key = 10; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Try again with NULL 'op' */ + /* (Should not be found, but not fail) */ + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != FALSE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find modified record in B-tree with 1 record */ + find.key = 42; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != 43) + TEST_ERROR + + /* Try again with NULL 'op' */ + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, NULL, NULL) != TRUE) + FAIL_STACK_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with 1 record */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with 1 record */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 43) + TEST_ERROR + + PASSED(); + + + /* + * Test inserting more records into v2 B-tree + */ + TESTING("B-tree update: insert several records"); + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* + * Test inserting second record into v2 B-tree, before all other records + */ + record.key = 34; + record.val = 11; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* + * Test inserting third record into v2 B-tree, after all other records + */ + record.key = 56; + record.val = 12; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* + * Test inserting fourth record into v2 B-tree, in the middle of other records + */ + record.key = 38; + record.val = 13; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in level-0 B-tree with several records */ + /* (Should not be found, but not fail) */ + find.key = 10; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in level-0 B-tree with several records */ + find.key = 56; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + TEST_ERROR + if(find.val != 12) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with several records */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with several records */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 34) + TEST_ERROR + if(find.val != 11) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 38) + TEST_ERROR + if(find.val != 13) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 43) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 56) + TEST_ERROR + if(find.val != 12) + TEST_ERROR + + PASSED(); + + + /* + * Test updating all existing records in v2 B-tree + */ + TESTING("B-tree update: update several records"); + + record.key = 34; + modify.key = 34; + modify.val = 21; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + record.key = 38; + modify.key = 38; + modify.val = 23; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + record.key = 42; + modify.key = 42; + modify.val = 24; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + record.key = 56; + modify.key = 56; + modify.val = 22; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + + /* Attempt to find non-existant record in level-0 B-tree with several records */ + /* (Should not be found, but not fail) */ + find.key = 41; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in level-0 B-tree with several record */ + find.key = 56; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + TEST_ERROR + if(find.val != 22) + TEST_ERROR + + /* Attempt to index non-existant record in B-tree with several records */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)4, index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in B-tree with several records */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 34) + TEST_ERROR + if(find.val != 21) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 38) + TEST_ERROR + if(find.val != 23) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)2, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 42) + TEST_ERROR + if(find.val != 24) + TEST_ERROR + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)3, index_rec_cb, &find) < 0) + TEST_ERROR + if(find.key != 56) + TEST_ERROR + if(find.val != 22) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close the file */ + if(H5Fclose(file) < 0) + TEST_ERROR + + PASSED(); + + + /* All tests passed */ + return(0); + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* test_update_basic() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_split_root + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It also continues to add a few more records to each of the + * left and right leaf nodes after the split + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Wednesday, December 23, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_split_root(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ + + /* + * Test inserting enough records into v2 B-tree to split the root node + */ + TESTING("B-tree update: split root"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert records to fill root leaf node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC - 1); u++) { + record.key = u + 2; + record.val = u * 2 + 4; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 0; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC - 1); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert record to split root leaf node */ + record.key = INSERT_SPLIT_ROOT_NREC_REC + 1; + record.val = (INSERT_SPLIT_ROOT_NREC_REC - 1) * 2 + 4; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 2; + idx.val = 4; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Modify all records */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + 2; + modify.key = u + 2; + modify.val = u * 2 + 5; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 2; + idx.val = 5; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + TEST_ERROR + + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert a couple more records, on the left side of the B-tree */ + record.key = 0; + record.val = 1; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = 1; + record.val = 3; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC + 2); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 33; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 1; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC + 2)) + TEST_ERROR + + /* Attempt to find non-existant record in level-1 B-tree */ + /* (Should not be found, but not fail) */ + find.key = 800; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in root of level-1 B-tree */ + find.key = 33; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.key != 33) + TEST_ERROR + if(find.val != 67) + TEST_ERROR + + /* Attempt to find existant record in leaf of level-1 B-tree */ + find.key = 56; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.key != 56) + TEST_ERROR + if(find.val != 113) + TEST_ERROR + + /* Attempt to index non-existant record in level-1 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC + 2), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in root of level-1 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)33, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 33) + TEST_ERROR + if(find.val != 67) + TEST_ERROR + + /* Attempt to index existing record in left leaf of level-1 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)0, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 0) + TEST_ERROR + if(find.val != 1) + TEST_ERROR + + /* Attempt to index existing record in right leaf of level-1 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)50, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 50) + TEST_ERROR + if(find.val != 101) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + if(H5Fclose(file) < 0) + TEST_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_split_root() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_2leaf_redistrib + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * redistribution + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: redistribute 2 leaves in level 1 B-tree (l->r)"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + record.val = u + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = INSERT_SPLIT_ROOT_NREC_REC; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Force redistribution from left node into right node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { + record.key = u; + record.val = u + 9; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) + (INSERT_SPLIT_ROOT_NREC_REC / 4); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: redistribute 2 leaves in level 1 B-tree (r->l)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = u + 9; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force redistribution from left node into right node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 9; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) + (INSERT_SPLIT_ROOT_NREC_REC / 4) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_2leaf_redistrib() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_side_split + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * split, adding another node to the B-tree + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_side_split(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: split side leaf into 2 leaves in level 1 B-tree (l->r)"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force left node to split */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = u + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 31; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 64; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: split side leaf into 2 leaves in level 1 B-tree (r->l)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = u + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force right node to split */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = u + INSERT_SPLIT_ROOT_NREC_REC + 10; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 63; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 95; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_side_split() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_3leaf_redistrib + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * split, adding another node to the B-tree, then continues to + * add records until a 3 node redistribution occurs + * + * Return: Success: 0 + * + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: redistribute 3 leaves in level 1 B-tree"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + (INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (2 * INSERT_SPLIT_ROOT_NREC_REC); + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force left node to split */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 2 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = INSERT_SPLIT_ROOT_NREC_REC + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Insert records to force middle node to redistribute */ + for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC_REC / 2) + 1); u++) { + record.key = u + INSERT_SPLIT_ROOT_NREC_REC; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = (2 * INSERT_SPLIT_ROOT_NREC_REC) + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 52; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 107; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 2) + (INSERT_SPLIT_ROOT_NREC_REC / 2) + 1)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_3leaf_redistrib() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_level1_middle_split + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to split the root node and force the tree to depth 1. + * It continues to add a more records to the each of the + * left and right leaf nodes after the split to force a 2 node + * split, adding another node to the B-tree, then continues to + * add records until a 3 node split occurs + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_level1_middle_split(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + unsigned u; /* Local index variable */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: split middle leaf into 2 leaves in level 1 B-tree"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 leaves */ + for(u = 0; u < INSERT_SPLIT_ROOT_NREC_REC; u++) { + record.key = u + (INSERT_SPLIT_ROOT_NREC_REC * 2); + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = (2 * INSERT_SPLIT_ROOT_NREC_REC) + (INSERT_SPLIT_ROOT_NREC_REC / 2) - 1; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Force split from left node into right node */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 2); u++) { + record.key = u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 1; + bt2_stat.nrecords = 3 * INSERT_SPLIT_ROOT_NREC_REC; + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 63; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 95; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + record.key = 128; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != (INSERT_SPLIT_ROOT_NREC_REC * 3)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + /* Close file */ + if(H5Fclose(file) < 0) + STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + if(bt2) + H5B2_close(bt2, dxpl); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* test_update_level1_middle_split() */ + + +/*------------------------------------------------------------------------- + * Function: test_update_make_level2 + * + * Purpose: Basic tests for the B-tree v2 code. This test inserts enough + * records to make a level 2 B-tree + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Quincey Koziol + * Saturday, December 26, 2015 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_update_make_level2(hid_t fapl, const H5B2_create_t *cparam, + const bt2_test_param_t *tparam) +{ + hid_t file = -1; /* File ID */ + H5F_t *f = NULL; /* Internal file object pointer */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ + haddr_t bt2_addr; /* Address of B-tree created */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t idx; /* Index within B-tree, for iterator */ + H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ + unsigned u; /* Local index variable */ + herr_t ret; /* Generic error return value */ + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: make level 2 B-tree (l->r)"); + + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) + TEST_ERROR + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 internal nodes */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + record.key = u + 2; /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = u + 4; /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 1347; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Add some extra records to left-most leaf */ + record.key = 0; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = 1; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to middle leaf */ + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 9) + 2; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 9) + 3; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) + TEST_ERROR + + /* Attempt to find non-existant record in level-2 B-tree */ + /* (Should not be found, but not fail) */ + find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in root of level-2 B-tree */ + find.key = 1347; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (1347 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 1347; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Attempt to find existant record in internal node of level-2 B-tree */ + find.key = 513; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (513 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 513; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) + TEST_ERROR + + /* Attempt to find existant record in leaf of level-2 B-tree */ + find.key = 555; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (555 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Attempt to index non-existant record in level-2 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in root of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1347, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 1347) + TEST_ERROR + if(find.val != (1347 * 2)) + TEST_ERROR + + /* Attempt to index existing record in internal node of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 513) + TEST_ERROR + if(find.val != (513 * 2)) + TEST_ERROR + + /* Attempt to index existing record in leaf of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 555) + TEST_ERROR + if(find.val != (555 * 2)) + TEST_ERROR + + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: make level 2 B-tree (r->l)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 internal nodes */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 1) - u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 1) - (u +2); /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + + /* Check up on B-tree */ + bt2_stat.depth = 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); + if(check_stats(bt2, &bt2_stat) < 0) + TEST_ERROR + record.key = 1344; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + /* Add some extra records to right-most leaf */ + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 2; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 3; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to middle leaf */ + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)); + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 1; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + TEST_ERROR + + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) + FAIL_STACK_ERROR + + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 4)) + TEST_ERROR + + /* Attempt to find non-existant record in level-2 B-tree */ + /* (Should not be found, but not fail) */ + find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) + TEST_ERROR + + /* Attempt to find existant record in root of level-2 B-tree */ + find.key = 1344; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (1344 * 2)) + TEST_ERROR + + /* Check with B-tree */ + record.key = 1344; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) + TEST_ERROR + + /* Attempt to find existant record in internal node of level-2 B-tree */ + find.key = 512; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (512 * 2)) TEST_ERROR - /* Create the v2 B-tree & get its address */ - if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + /* Check with B-tree */ + record.key = 512; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - /* Insert enough records to force root to split into 3 internal nodes */ - /* (and fill right internal node) */ - for(u = 0; u < (INSERT_SPLIT_ROOT_NREC * 31); u++) { - record = u; - if(H5B2_insert(bt2, dxpl, &record) < 0) - FAIL_STACK_ERROR - } /* end for */ - for(; u < (INSERT_SPLIT_ROOT_NREC * 74); u++) { - record = u + ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3); - if(H5B2_insert(bt2, dxpl, &record) < 0) - FAIL_STACK_ERROR - } /* end for */ + /* Attempt to find existant record in leaf of level-2 B-tree */ + find.key = 555; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (555 * 2)) + TEST_ERROR - /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + /* Check with B-tree */ + record.key = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR - /* Check up on B-tree */ - bt2_stat.depth = 2; - bt2_stat.nrecords = INSERT_SPLIT_ROOT_NREC * 74; - if(check_stats(bt2, &bt2_stat) < 0) + /* Attempt to index non-existant record in level-2 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + + /* Attempt to index existing record in root of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1344, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 1344) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(find.val != (1344 * 2)) TEST_ERROR - record = 1952; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + + /* Attempt to index existing record in internal node of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)512, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 512) TEST_ERROR - record = 2884; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(find.val != (512 * 2)) TEST_ERROR - record = 2822; /* Record just after insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + + /* Attempt to index existing record in leaf of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 555) + TEST_ERROR + if(find.val != (555 * 2)) TEST_ERROR - /* Insert records to fill up middle internal node */ - for(u = 0; u < ((INSERT_SPLIT_ROOT_NREC * 13) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2); u++) { - record = u + (INSERT_SPLIT_ROOT_NREC * 31); - if(H5B2_insert(bt2, dxpl, &record) < 0) + /* Close the v2 B-tree */ + if(H5B2_close(bt2, dxpl) < 0) + FAIL_STACK_ERROR + bt2 = NULL; + + PASSED(); + + + /* + * Test inserting many records into v2 B-tree + */ + TESTING("B-tree update: make level 2 B-tree (l+r->middle)"); + + /* Create the v2 B-tree & get its address */ + if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) + TEST_ERROR + + /* Insert enough records to force root to split into 2 internal nodes */ + for(u = 0; u < (INSERT_SPLIT_ROOT_NREC_REC * 9); u++) { + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 3) - u; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + } /* end for */ + for(; u < (INSERT_SPLIT_ROOT_NREC_REC * 41); u++) { + record.key = u - ((INSERT_SPLIT_ROOT_NREC_REC * 9) - 2); /* Leave a gap for later insertion */ + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ bt2_stat.depth = 2; - bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 2; + bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC_REC * 41); if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) - TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) - TEST_ERROR - record = 2789; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) - TEST_ERROR - record = 2822; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + record.key = 1345; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR - record = 2823; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + + /* Check for closing & re-opening the B-tree */ + if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) TEST_ERROR + /* Add some extra records to right-most leaf */ + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 4; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = (INSERT_SPLIT_ROOT_NREC_REC * 41) + 5; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to middle leaf */ + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 2; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = ((INSERT_SPLIT_ROOT_NREC_REC * 41) - (INSERT_SPLIT_ROOT_NREC_REC * 9)) + 3; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + + /* Add some extra records to left-most leaf */ + record.key = 0; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + record.key = 1; + record.val = record.key * 2; + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) + FAIL_STACK_ERROR + /* Check for closing & re-opening the B-tree */ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - /* Insert record to split middle internal node */ - record = u + (INSERT_SPLIT_ROOT_NREC * 31); - if(H5B2_insert(bt2, dxpl, &record) < 0) + + /* Iterate over B-tree to check records have been inserted correctly */ + idx.key = 0; + idx.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &idx) < 0) FAIL_STACK_ERROR - /* Check up on B-tree */ - bt2_stat.depth = 2; - bt2_stat.nrecords = (INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3; - if(check_stats(bt2, &bt2_stat) < 0) + /* Make certain that the index is correct */ + if(idx.key != ((INSERT_SPLIT_ROOT_NREC_REC * 41) + 6)) TEST_ERROR - record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + + /* Attempt to find non-existant record in level-2 B-tree */ + /* (Should not be found, but not fail) */ + find.key = INSERT_SPLIT_ROOT_NREC_REC * 42; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) TEST_ERROR - record = 2789; /* Middle record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(find.val != (hsize_t)-1) TEST_ERROR - record = 3703; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + + /* Attempt to find existant record in root of level-2 B-tree */ + find.key = 1345; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (1345 * 2)) TEST_ERROR -#ifdef NONE - record = 3049; /* Record to left of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + + /* Check with B-tree */ + record.key = 1345; + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR -#endif /* NONE */ - record = 2822; /* Record to right of insertion point in middle internal node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + + /* Attempt to find existant record in internal node of level-2 B-tree */ + find.key = 513; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (513 * 2)) TEST_ERROR - record = 2823; /* Record just above insertion point in leaf node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + + /* Check with B-tree */ + record.key = 513; + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR - /* Check for closing & re-opening the B-tree */ - if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) + /* Attempt to find existant record in leaf of level-2 B-tree */ + find.key = 555; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) + FAIL_STACK_ERROR + if(find.val != (555 * 2)) TEST_ERROR - /* Iterate over B-tree to check records have been inserted correctly */ - idx = 0; - if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + /* Check with B-tree */ + record.key = 555; + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) + TEST_ERROR + + /* Attempt to index non-existant record in level-2 B-tree */ + H5E_BEGIN_TRY { + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_SPLIT_ROOT_NREC_REC * 42), index_rec_cb, NULL); + } H5E_END_TRY; + /* Should fail */ + if(ret != FAIL) + TEST_ERROR + + /* Attempt to index existing record in level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)1345, index_rec_cb, &find) < 0) FAIL_STACK_ERROR + if(find.key != 1345) + TEST_ERROR + if(find.val != (1345 * 2)) + TEST_ERROR - /* Make certain that the index is correct */ - if(idx != ((INSERT_SPLIT_ROOT_NREC * 87) + ((3 * INSERT_SPLIT_ROOT_NREC) / 4) + 3)) + /* Attempt to index existing record in internal node of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)513, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 513) + TEST_ERROR + if(find.val != (513 * 2)) + TEST_ERROR + + /* Attempt to index existing record in leaf of level-2 B-tree */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + if(H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)555, index_rec_cb, &find) < 0) + FAIL_STACK_ERROR + if(find.key != 555) + TEST_ERROR + if(find.val != (555 * 2)) TEST_ERROR /* Close the v2 B-tree */ @@ -2730,103 +4959,95 @@ error: H5Fclose(file); } H5E_END_TRY; return 1; -} /* test_insert_level2_3internal_split() */ +} /* test_update_make_level2() */ /*------------------------------------------------------------------------- - * Function: test_insert_lots + * Function: test_update_lots * * Purpose: Basic tests for the B-tree v2 code. This test inserts many * records in random order, enough to make at a level 4 B-tree. * * Return: Success: 0 - * * Failure: 1 * * Programmer: Quincey Koziol - * Saturday, February 19, 2005 + * Sunday, December 27, 2015 * *------------------------------------------------------------------------- */ static unsigned -test_insert_lots(hid_t fapl, const H5B2_create_t *cparam, +test_update_lots(hid_t fapl, const H5B2_create_t *cparam, const bt2_test_param_t *tparam) { hid_t file = -1; /* File ID */ - char filename[1024]; /* Filename to use */ H5F_t *f = NULL; /* Internal file object pointer */ hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ H5B2_t *bt2 = NULL; /* v2 B-tree wrapper */ haddr_t bt2_addr; /* Address of B-tree created */ - hsize_t record; /* Record to insert into tree */ - hsize_t idx; /* Index within B-tree, for iterator */ time_t curr_time; /* Current time, for seeding random number generator */ - hsize_t *records; /* Record #'s for random insertion */ - unsigned u; /* Local index variable */ - unsigned swap_idx; /* Location to swap with when shuffling */ - hsize_t temp_rec; /* Temporary record */ + H5B2_test_rec_t *records; /* Record #'s for random insertion */ + H5B2_test_rec_t record; /* Record to insert into tree */ + H5B2_test_rec_t modify; /* Modified value */ + H5B2_test_rec_t find; /* Record to find */ + H5B2_test_rec_t iter; /* Index within B-tree, for iterator */ H5B2_stat_t bt2_stat; /* Statistics about B-tree created */ hsize_t nrec; /* Number of records in B-tree */ + unsigned u; /* Local index variable */ herr_t ret; /* Generic error return value */ /* Initialize random number seed */ - curr_time=HDtime(NULL); + curr_time = HDtime(NULL); #ifdef QAK -curr_time=1109170019; -HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); +curr_time = 1451342093; +HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); #endif /* QAK */ HDsrandom((unsigned)curr_time); /* * Test inserting many records into v2 B-tree */ - TESTING("B-tree insert: create random level 4 B-tree"); + TESTING("B-tree update: create random level 4 B-tree"); /* Allocate space for the records */ - if(NULL == (records = (hsize_t *)HDmalloc(sizeof(hsize_t) * INSERT_MANY))) + if(NULL == (records = (H5B2_test_rec_t *)HDmalloc(sizeof(H5B2_test_rec_t) * INSERT_MANY_REC))) TEST_ERROR /* Initialize record #'s */ - for(u = 0; u < INSERT_MANY; u++) - records[u] = u; + for(u = 0; u < INSERT_MANY_REC; u++) { + records[u].key = u; + records[u].val = u * 2; + } /* end for */ /* Shuffle record #'s */ - for(u = 0; u < INSERT_MANY; u++) { - swap_idx = ((unsigned)HDrandom() % (INSERT_MANY - u)) + u; + for(u = 0; u < INSERT_MANY_REC; u++) { + H5B2_test_rec_t temp_rec; /* Temporary record */ + unsigned swap_idx; /* Location to swap with when shuffling */ + + swap_idx = ((unsigned)HDrandom() % (INSERT_MANY_REC - u)) + u; temp_rec = records[u]; records[u] = records[swap_idx]; records[swap_idx] = temp_rec; } /* end for */ - /* Set the filename to use for this test (dependent on fapl) */ - h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - - /* Create the file to work on */ - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + /* Create the file for the test */ + if(create_file(&file, &f, fapl) < 0) TEST_ERROR - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - STACK_ERROR - - /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) - STACK_ERROR - /* Create the v2 B-tree & get its address */ if(create_btree(f, dxpl, cparam, &bt2, &bt2_addr) < 0) TEST_ERROR /* Insert random records */ - for(u = 0; u < INSERT_MANY; u++) { + for(u = 0; u < INSERT_MANY_REC; u++) { record = records[u]; - if(H5B2_insert(bt2, dxpl, &record) < 0) + if(H5B2_update(bt2, dxpl, &record, no_modify_cb, NULL) < 0) FAIL_STACK_ERROR } /* end for */ /* Check up on B-tree */ bt2_stat.depth = 4; - bt2_stat.nrecords = INSERT_MANY; + bt2_stat.nrecords = INSERT_MANY_REC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR @@ -2838,18 +5059,11 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); /* Close file */ if(H5Fclose(file) < 0) STACK_ERROR + file = -1; - /* Re-open the file */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) - FAIL_STACK_ERROR - - /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) - FAIL_STACK_ERROR - - /* Ignore metadata tags in the file's cache */ - if(H5AC_ignore_tags(f) < 0) - STACK_ERROR + /* Re-open the file for the test */ + if(reopen_file(&file, &f, fapl) < 0) + TEST_ERROR /* Re-open v2 B-tree */ if(NULL == (bt2 = H5B2_open(f, dxpl, bt2_addr, f))) @@ -2857,87 +5071,110 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); /* Check up on B-tree after re-open */ bt2_stat.depth = 4; - bt2_stat.nrecords = INSERT_MANY; + bt2_stat.nrecords = INSERT_MANY_REC; if(check_stats(bt2, &bt2_stat) < 0) TEST_ERROR /* Iterate over B-tree to check records have been inserted correctly */ - idx = 0; - if(H5B2_iterate(bt2, dxpl, iter_cb, &idx) < 0) + iter.key = 0; + iter.val = 0; + if(H5B2_iterate(bt2, dxpl, iter_rec_cb, &iter) < 0) FAIL_STACK_ERROR /* Make certain that the index is correct */ - if(idx != INSERT_MANY) + if(iter.key != INSERT_MANY_REC) TEST_ERROR /* Attempt to find non-existant record in level-4 B-tree */ /* (Should not be found, but not fail) */ - idx = INSERT_MANY * 2; - if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != FALSE) + find.key = INSERT_MANY_REC * 2; + find.val = (hsize_t)-1; + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != FALSE) + TEST_ERROR + if(find.val != (hsize_t)-1) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY; u++) { + for(u = 0; u < FIND_MANY_REC; u++) { /* Pick random record */ - idx = (hsize_t)(HDrandom()%INSERT_MANY); + find.key = (hsize_t)(HDrandom() % INSERT_MANY_REC); + find.val = (hsize_t)-1; - /* Attempt to find existant record in root of level-4 B-tree */ - if(H5B2_find(bt2, dxpl, &idx, find_cb, &idx) != TRUE) + /* Attempt to find existant record in level-4 B-tree */ + if(H5B2_find(bt2, dxpl, &find, find_rec_cb, &find) != TRUE) FAIL_STACK_ERROR + if(find.val != (find.key * 2)) + TEST_ERROR } /* end for */ /* Attempt to index non-existant record in level-4 B-tree, in increasing & decreasing order */ H5E_BEGIN_TRY { - ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + ret = H5B2_index(bt2, dxpl, H5_ITER_INC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); } H5E_END_TRY; /* Should fail */ if(ret != FAIL) TEST_ERROR H5E_BEGIN_TRY { - ret = H5B2_index(bt2, dxpl, H5_ITER_DEC, (hsize_t)(INSERT_MANY*3), find_cb, NULL); + ret = H5B2_index(bt2, dxpl, H5_ITER_DEC, (hsize_t)(INSERT_MANY_REC * 3), find_rec_cb, NULL); } H5E_END_TRY; /* Should fail */ if(ret != FAIL) TEST_ERROR /* Find random records */ - for(u = 0; u < FIND_MANY; u++) { + for(u = 0; u < FIND_MANY_REC; u++) { + hsize_t idx; /* Record index */ + /* Pick random record */ - idx = (hsize_t)(HDrandom() % INSERT_MANY); + idx = (hsize_t)(HDrandom() % INSERT_MANY_REC); - /* Attempt to find existant record in root of level-4 B-tree */ + /* Reset find record */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + + /* Attempt to find existant record in level-4 B-tree */ /* (in increasing order) */ - if(H5B2_index(bt2, dxpl, H5_ITER_INC, idx, find_cb, &idx) < 0) + if(H5B2_index(bt2, dxpl, H5_ITER_INC, idx, index_rec_cb, &find) < 0) FAIL_STACK_ERROR + if(find.key != idx) + TEST_ERROR + if(find.val != (find.key * 2)) + TEST_ERROR - /* Attempt to find existant record in root of level-4 B-tree */ + /* Reset find record */ + find.key = (hsize_t)-1; + find.val = (hsize_t)-1; + + /* Attempt to find existant record in level-4 B-tree */ /* (in decreasing order) */ - if(H5B2_index(bt2, dxpl, H5_ITER_DEC, idx, find_dec_cb, &idx) < 0) + if(H5B2_index(bt2, dxpl, H5_ITER_DEC, idx, index_rec_cb, &find) < 0) FAIL_STACK_ERROR + if(find.key != (INSERT_MANY_REC - (idx + 1))) + TEST_ERROR + if(find.val != (find.key * 2)) + TEST_ERROR } /* end for */ PASSED(); - TESTING("B-tree insert: attempt duplicate record in level 4 B-tree"); + TESTING("B-tree update: update record in level 4 B-tree"); /* Check for closing & re-opening the B-tree */ if(reopen_btree(f, dxpl, &bt2, bt2_addr, tparam) < 0) TEST_ERROR - record = INSERT_MANY / 2; - H5E_BEGIN_TRY { - ret = H5B2_insert(bt2, dxpl, &record); - } H5E_END_TRY; - /* Should fail */ - if(ret != FAIL) - TEST_ERROR + record.key = INSERT_MANY_REC / 2; + modify.key = INSERT_MANY_REC / 2; + modify.val = record.key * 3; + if(H5B2_update(bt2, dxpl, &record, modify_rec_cb, &modify) < 0) + FAIL_STACK_ERROR /* Query the number of records in the B-tree */ if(H5B2_get_nrec(bt2, &nrec) < 0) FAIL_STACK_ERROR /* Make certain that the # of records is correct */ - if(nrec != INSERT_MANY) + if(nrec != INSERT_MANY_REC) TEST_ERROR /* Close the v2 B-tree */ @@ -2956,14 +5193,16 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); return 0; error: + HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); H5E_BEGIN_TRY { if(bt2) H5B2_close(bt2, dxpl); H5Fclose(file); } H5E_END_TRY; HDfree(records); + return 1; -} /* test_insert_lots() */ +} /* test_update_lots() */ /*------------------------------------------------------------------------- @@ -3365,13 +5604,13 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check up on B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = (INSERT_SPLIT_ROOT_NREC * 2) - 2; - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 0; @@ -3384,10 +5623,10 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Make certain that the leaf nodes didn't redistribute */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3409,7 +5648,7 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check up on B-tree */ record = 0; - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 1; @@ -3422,10 +5661,10 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Make certain that the leaf nodes didn't redistribute */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3447,7 +5686,7 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check up on B-tree */ record = INSERT_SPLIT_ROOT_NREC; - if(check_node_depth(bt2, dxpl, record, (unsigned)0) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)0) < 0) TEST_ERROR rrecord = 0; @@ -3460,10 +5699,10 @@ test_remove_level1_noredistrib(hid_t fapl, const H5B2_create_t *cparam, /* Make certain that the leaf nodes didn't redistribute */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3545,10 +5784,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 94; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Query the number of records in the B-tree */ @@ -3593,10 +5832,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 90; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR PASSED(); @@ -3629,10 +5868,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 64; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 90; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR PASSED(); @@ -3665,10 +5904,10 @@ test_remove_level1_redistrib(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 64; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 91; /* Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR /* Close the v2 B-tree */ @@ -3742,7 +5981,7 @@ test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -3815,7 +6054,7 @@ test_remove_level1_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -3921,7 +6160,7 @@ test_remove_level1_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4047,13 +6286,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4093,13 +6332,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4139,13 +6378,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 63; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 125; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4181,13 +6420,13 @@ test_remove_level1_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 63; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 126; /* Center-Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR record = 188; /* Center-Right record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 4; @@ -4274,7 +6513,7 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4335,7 +6574,7 @@ test_remove_level1_promote_2leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4422,7 +6661,7 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4483,7 +6722,7 @@ test_remove_level1_promote_3leaf_redistrib(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 39; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4570,7 +6809,7 @@ test_remove_level1_promote_2leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4715,7 +6954,7 @@ test_remove_level1_promote_3leaf_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 62; /* Left-most record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)1) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)1) < 0) TEST_ERROR ninfo.depth = 1; ninfo.nrec = 2; @@ -4999,7 +7238,7 @@ test_remove_level2_promote(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5285,7 +7524,7 @@ test_remove_level2_promote_2internal_redistrib(hid_t fapl, const H5B2_create_t * /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5435,7 +7674,7 @@ test_remove_level2_promote_3internal_redistrib(hid_t fapl, const H5B2_create_t * /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5585,7 +7824,7 @@ test_remove_level2_promote_2internal_merge(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5736,7 +7975,7 @@ test_remove_level2_promote_3internal_merge(hid_t fapl, const H5B2_create_t *cpar /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -5887,7 +8126,7 @@ test_remove_level2_2internal_merge_left(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -6013,7 +8252,7 @@ test_remove_level2_2internal_merge_right(hid_t fapl, const H5B2_create_t *cparam /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -6139,7 +8378,7 @@ test_remove_level2_3internal_merge(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -6266,7 +8505,7 @@ test_remove_level2_collapse_right(hid_t fapl, const H5B2_create_t *cparam, /* Check record values in root of B-tree */ record = 1889; /* Left record in root node */ - if(check_node_depth(bt2, dxpl, record, (unsigned)2) < 0) + if(check_node_depth(bt2, dxpl, &record, (unsigned)2) < 0) TEST_ERROR ninfo.depth = 2; ninfo.nrec = 2; @@ -7750,7 +9989,7 @@ error: int main(void) { - H5B2_create_t cparam; /* Creation parameters for v2 B-tree */ + H5B2_create_t cparam, cparam2; /* Creation parameters for v2 B-tree */ bt2_test_param_t tparam; /* Test parameters for v2 B-tree */ hid_t fapl = -1; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ @@ -7770,8 +10009,7 @@ main(void) printf("***Express test mode on. Some tests may be skipped\n"); /* Initialize v2 B-tree creation parameters */ - init_cparam(&cparam); - + init_cparam(&cparam, &cparam2); /* Loop over re-opening B-tree during tests */ for(reopen = FALSE; reopen <= TRUE; reopen++) { @@ -7785,7 +10023,7 @@ main(void) } /* end else */ /* Test B-tree record insertion */ - /* Iteration, find & index routines tested in these routines as well */ + /* (Iteration, find & index routines exercised in these routines as well) */ nerrors += test_insert_basic(fapl, &cparam, &tparam); nerrors += test_insert_split_root(fapl, &cparam, &tparam); nerrors += test_insert_level1_2leaf_redistrib(fapl, &cparam, &tparam); @@ -7804,6 +10042,20 @@ main(void) else nerrors += test_insert_lots(fapl, &cparam, &tparam); + /* Test B-tree record update (ie. insert/modify) */ + /* (Iteration, find & index routines exercised in these routines as well) */ + nerrors += test_update_basic(fapl, &cparam2, &tparam); + nerrors += test_update_split_root(fapl, &cparam2, &tparam); + nerrors += test_update_level1_2leaf_redistrib(fapl, &cparam2, &tparam); + nerrors += test_update_level1_side_split(fapl, &cparam2, &tparam); + nerrors += test_update_level1_3leaf_redistrib(fapl, &cparam2, &tparam); + nerrors += test_update_level1_middle_split(fapl, &cparam2, &tparam); + nerrors += test_update_make_level2(fapl, &cparam2, &tparam); + if(ExpressMode > 1) + printf("***Express test mode on. test_update_lots skipped\n"); + else + nerrors += test_update_lots(fapl, &cparam2, &tparam); + /* Test B-tree record removal */ /* Querying the number of records routine also tested in these routines as well */ nerrors += test_remove_basic(fapl, &cparam, &tparam); diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index 480450d..817f583 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -121,6 +121,10 @@ get_H5B2_class(const uint8_t *sig) cls = H5A_BT2_CORDER; break; + case H5B2_TEST2_ID: + cls = H5B2_TEST2; + break; + case H5B2_NUM_BTREE_ID: default: HDfprintf(stderr, "Unknown v2 B-tree subtype %u\n", (unsigned)(subtype)); -- cgit v0.12 From c6949efd4fd5f5757f2d0443d51e4d635485595b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 29 Dec 2015 20:56:45 -0500 Subject: [svn-r28748] Description: Bump number of records for level 4 B-tree test, so that it's more likely to always get to level 4. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index 04c94fd..8a08d3d 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2600 * 1000) +#define INSERT_MANY_REC (2610 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12 From 528ab9b810102a7cc7773c6403c8b2be6578d380 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 30 Dec 2015 13:50:01 -0500 Subject: [svn-r28756] Description: Minor code neatening and cleanups (same as r28755) on revise_chunks branch. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (Too minor for h5committest) --- src/H5Dchunk.c | 40 ++++++++++++++++++++++++---------------- src/H5Dpkg.h | 10 +++++----- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 2e000e3..6b99a43 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1034,9 +1034,8 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) FUNC_ENTER_STATIC_NOERR HDassert(size); - HDassert(pline); - if(pline->nused > 0) + if(pline && pline->nused) ret_value = H5MM_malloc(size); else ret_value = H5FL_BLK_MALLOC(chunk, size); @@ -1064,10 +1063,8 @@ H5D__chunk_mem_xfree(void *chk, const H5O_pline_t *pline) { FUNC_ENTER_STATIC_NOERR - HDassert(pline); - if(chk) { - if(pline->nused > 0) + if(pline && pline->nused) H5MM_xfree(chk); else chk = H5FL_BLK_FREE(chunk, chk); @@ -1751,6 +1748,7 @@ H5D__chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr, hbool_t write_ FUNC_ENTER_PACKAGE + /* Sanity check */ HDassert(io_info); HDassert(dataset); @@ -2551,13 +2549,14 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, H5D_chunk_ud_t *udata) { H5D_rdcc_ent_t *ent = NULL; /* Cache entry */ - hbool_t found = FALSE; /* In cache? */ - unsigned u; /* Counter */ H5O_storage_chunk_t *sc = &(dset->shared->layout.storage.u.chunk); - herr_t ret_value = SUCCEED; /* Return value */ + unsigned idx; /* Index of chunk in cache, if present */ + hbool_t found = FALSE; /* In cache? */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE + /* Sanity checks */ HDassert(dset); HDassert(dset->shared->layout.u.chunk.ndims > 0); H5D_CHUNK_STORAGE_INDEX_CHK(sc); @@ -2567,7 +2566,7 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, /* Initialize the query information about the chunk we are looking for */ udata->common.layout = &(dset->shared->layout.u.chunk); udata->common.storage = &(dset->shared->layout.storage.u.chunk); - udata->common.scaled = scaled; + udata->common.scaled = scaled; /* Reset information about the chunk we are looking for */ udata->chunk_block.offset = HADDR_UNDEF; @@ -2576,19 +2575,29 @@ H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, /* Check for chunk in cache */ if(dset->shared->cache.chunk.nslots > 0) { - udata->idx_hint = H5D__chunk_hash_val(dset->shared, scaled); - ent = dset->shared->cache.chunk.slot[udata->idx_hint]; + /* Determine the chunk's location in the hash table */ + idx = H5D__chunk_hash_val(dset->shared, scaled); + + /* Get the chunk cache entry for that location */ + ent = dset->shared->cache.chunk.slot[idx]; + if(ent) { + unsigned u; /* Counter */ + + /* Speculatively set the 'found' flag */ + found = TRUE; - if(ent) - for(u = 0, found = TRUE; u < dset->shared->ndims; u++) + /* Verify that the cache entry is the correct chunk */ + for(u = 0; u < dset->shared->ndims; u++) if(scaled[u] != ent->scaled[u]) { found = FALSE; break; } /* end if */ + } /* end if */ } /* end if */ - /* Find chunk addr */ + /* Retrieve chunk addr */ if(found) { + udata->idx_hint = idx; udata->chunk_block.offset = ent->chunk_block.offset; udata->chunk_block.length = ent->chunk_block.length;; udata->chunk_idx = ent->chunk_idx; @@ -3287,6 +3296,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, FUNC_ENTER_PACKAGE + /* Sanity check */ HDassert(io_info); HDassert(udata); @@ -3294,8 +3304,6 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, /* * It's not in the cache, probably because it's too big. If it's * dirty then flush it to disk. In any case, free the chunk. - * Note: we have to copy the layout and filter messages so we - * don't discard the `const' qualifier. */ if(dirty) { H5D_rdcc_ent_t fake_ent; /* "fake" chunk cache entry */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 06e763c..4e6376b 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -250,7 +250,6 @@ typedef struct H5D_chunk_rec_t { * to which the index points. */ typedef struct H5D_chunk_common_ud_t { - /* downward */ const H5O_layout_chunk_t *layout; /* Chunk layout description */ const H5O_storage_chunk_t *storage; /* Chunk storage description */ const hsize_t *scaled; /* Scaled coordinates for a chunk */ @@ -258,13 +257,14 @@ typedef struct H5D_chunk_common_ud_t { /* B-tree callback info for various operations */ typedef struct H5D_chunk_ud_t { + /* Downward */ H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ /* Upward */ - unsigned idx_hint; /*index of chunk in cache, if present */ - H5F_block_t chunk_block; /*offset/length of chunk in file */ - unsigned filter_mask; /*excluded filters */ - hsize_t chunk_idx; /*chunk index for EA, FA indexing */ + unsigned idx_hint; /* Index of chunk in cache, if present */ + H5F_block_t chunk_block; /* Offset/length of chunk in file */ + unsigned filter_mask; /* Excluded filters */ + hsize_t chunk_idx; /* Chunk index for EA, FA indexing */ } H5D_chunk_ud_t; /* Typedef for "generic" chunk callbacks */ -- cgit v0.12 From 8d8d56d7d1601a88b90524c7bcb78c2515ce770f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 31 Dec 2015 11:23:05 -0500 Subject: [svn-r28759] Description: Bump number of records for level 4 update test, to cut down on number of random failures. Tested on: None - trivial --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index 8a08d3d..b0c0ac3 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2610 * 1000) +#define INSERT_MANY_REC (2650 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12 From f60170dac7c491cc75120a6ebdfe73c13c0bab1d Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 1 Jan 2016 01:28:04 -0500 Subject: [svn-r28761] Description: Clean up many mismatches between malloc/free and H5MM_malloc/H5MM_xfree in the library and tests (and use of H5free_memory and H5Dvlen_reclaim). Also make H5Ocopy use a private version of H5Lexists, which doesn't internally throw (and suppress) errors when an object (or the path to it) isn't found in the destination. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- fortran/src/H5Pf.c | 2 +- src/H5.c | 5 +- src/H5L.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++++----- src/H5Lprivate.h | 2 + src/H5Ocopy.c | 24 ++----- src/H5TS.c | 17 +++-- src/H5Tvlen.c | 8 +-- src/H5Ztrans.c | 4 +- test/dtypes.c | 99 +++++++++++++++++++++++++--- test/fheap.c | 10 +-- test/file_image.c | 4 +- test/links.c | 57 ++++++++++------ test/objcopy.c | 150 ++++++++++++++++++++++++++++++++++++------ test/tgenprop.c | 4 +- test/tmisc.c | 16 ++++- test/tvlstr.c | 11 ++-- tools/h5ls/h5ls.c | 5 +- 17 files changed, 482 insertions(+), 122 deletions(-) diff --git a/fortran/src/H5Pf.c b/fortran/src/H5Pf.c index 523ed0b..3989512 100644 --- a/fortran/src/H5Pf.c +++ b/fortran/src/H5Pf.c @@ -5273,7 +5273,7 @@ h5pget_file_image_c(hid_t_f *fapl_id, void **buf_ptr, size_t_f *buf_len_ptr) *buf_len_ptr=(size_t_f)c_buf_len_ptr; ret_value = 0; - if(c_buf_ptr) HDfree(c_buf_ptr); + if(c_buf_ptr) H5free_memory(c_buf_ptr); return ret_value; } diff --git a/src/H5.c b/src/H5.c index 33ac340..2086ce8 100644 --- a/src/H5.c +++ b/src/H5.c @@ -942,7 +942,6 @@ H5allocate_memory(size_t size, hbool_t clear) ret_value = H5MM_malloc(size); FUNC_LEAVE_API(ret_value) - } /* end H5allocate_memory() */ @@ -981,7 +980,6 @@ H5resize_memory(void *mem, size_t size) ret_value = H5MM_realloc(mem, size); FUNC_LEAVE_API(ret_value) - } /* end H5resize_memory() */ @@ -1004,10 +1002,9 @@ H5free_memory(void *mem) H5TRACE1("e", "*x", mem); /* At this time, it is impossible for this to fail. */ - HDfree(mem); + H5MM_xfree(mem); FUNC_LEAVE_API(SUCCEED) - } /* end H5free_memory() */ diff --git a/src/H5L.c b/src/H5L.c index a1f3b6e..9daf948 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -93,6 +93,17 @@ typedef struct { hid_t dxpl_id; /* Dataset transfer property list */ } H5L_trav_mv2_t; +/* User data for path traversal routine for checking if a link exists */ +typedef struct { + /* Down */ + char *sep; /* Pointer to next separator in the string */ + hid_t lapl_id; /* Link access property list */ + hid_t dxpl_id; /* Dataset transfer property list */ + + /* Up */ + hbool_t exists; /* Whether the link exists or not */ +} H5L_trav_le_t; + /* User data for path traversal routine for getting link value */ typedef struct { size_t size; /* Size of user buffer */ @@ -170,10 +181,13 @@ static herr_t H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, static herr_t H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static herr_t H5L_exists_cb(H5G_loc_t *grp_loc/*in*/, const char *name, +static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc/*in*/, const char *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, + H5G_own_loc_t *own_loc/*out*/); +static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, +static htri_t H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id); static herr_t H5L_get_info_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, @@ -827,7 +841,7 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Check for the existence of the link */ - if((ret_value = H5L_exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5L__exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") done: @@ -2716,9 +2730,10 @@ done: /*------------------------------------------------------------------------- - * Function: H5L_exists_cb + * Function: H5L__exists_final_cb * - * Purpose: Callback for checking whether a link exists + * Purpose: Callback for checking whether a link exists, as the final + * component of a path * * Return: Non-negative on success/Negative on failure * @@ -2728,30 +2743,162 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, +H5L__exists_final_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, const H5O_link_t *lnk, H5G_loc_t H5_ATTR_UNUSED *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { - hbool_t *udata = (hbool_t *)_udata; /* User data passed in */ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check if the name in this group resolved to a valid link */ - *udata = (hbool_t)(lnk != NULL); + udata->exists = (hbool_t)(lnk != NULL); /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5L_exists_cb() */ +} /* end H5L__exists_final_cb() */ /*------------------------------------------------------------------------- - * Function: H5L_exists + * Function: H5L__exists_inter_cb + * + * Purpose: Callback for checking whether a link exists, as an intermediate + * component of a path + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5L__exists_inter_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *name, + const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, + H5G_own_loc_t *own_loc/*out*/) +{ + H5L_trav_le_t *udata = (H5L_trav_le_t *)_udata; /* User data passed in */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the name in this group resolved to a valid link */ + if(lnk != NULL) { + /* Check for more components to the path */ + if(udata->sep) { + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char *next; /* Pointer to next component name */ + + /* Look for another separator */ + next = udata->sep; + if(NULL == (udata->sep = HDstrchr(udata->sep, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata->sep = '\0'; + udata->sep++; + } while('/' == *udata->sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + if(H5G_traverse(obj_loc, next, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, udata, udata->lapl_id, udata->dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine if link exists") + } /* end if */ + else + udata->exists = TRUE; + } /* end if */ + else + udata->exists = FALSE; + + /* Indicate that this callback didn't take ownership of the group * + * location for the object */ + *own_loc = H5G_OWN_NONE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L__exists_inter_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5L_exists_tolerant * * Purpose: Returns whether a link exists in a group * + * Note: Same as H5L_exists, except that missing links are reported + * as 'FALSE' instead of causing failures + * + * Return: Non-negative (TRUE/FALSE) on success/Negative on failure + * + * Programmer: Quincey Koziol + * Thursday, December 31 2015 + * + *------------------------------------------------------------------------- + */ +htri_t +H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) +{ + H5L_trav_le_t udata; /* User data for traversal */ + H5G_traverse_t cb_func; /* Callback function for tranversal */ + char *name_copy = NULL; /* Duplicate of name */ + char *name_trav; /* Name to traverse */ + htri_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(loc); + HDassert(name); + + /* Copy the name and skip leading '/'s */ + name_trav = name_copy = H5MM_strdup(name); + while('/' == *name_trav) + name_trav++; + + /* A path of "/" will always exist in a file */ + if('\0' == *name_trav) + HGOTO_DONE(TRUE) + + /* Set up user data & correct callback */ + udata.lapl_id = lapl_id; + udata.dxpl_id = dxpl_id; + udata.exists = FALSE; + if(NULL == (udata.sep = HDstrchr(name_trav, '/'))) + cb_func = H5L__exists_final_cb; + else { + /* Chew through adjacent separators, if present */ + do { + *udata.sep = '\0'; + udata.sep++; + } while('/' == *udata.sep); + cb_func = H5L__exists_inter_cb; + } /* end else */ + + /* Traverse the group hierarchy to locate the link to check */ + if(H5G_traverse(loc, name_trav, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, cb_func, &udata, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine if link exists") + + /* Set return value */ + ret_value = (htri_t)udata.exists; + +done: + /* Release duplicated string */ + H5MM_xfree(name_copy); + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5L_exists_tolerant() */ + + +/*------------------------------------------------------------------------- + * Function: H5L__exists + * + * Purpose: Returns whether a link exists in a group + * + * Note: Same as H5L_exists_tolerant, except that missing links are reported + * as failures + * * Return: Non-negative (TRUE/FALSE) on success/Negative on failure * * Programmer: Quincey Koziol @@ -2760,23 +2907,28 @@ H5L_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char H5_ATTR_UNUSED *------------------------------------------------------------------------- */ static htri_t -H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) +H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { - hbool_t exists = FALSE; /* Whether the link exists in the group */ + H5L_trav_le_t udata; /* User data for traversal */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + + /* A path of "/" will always exist in a file */ + if(0 == HDstrcmp(name, "/")) + HGOTO_DONE(TRUE) /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_exists_cb, &exists, lapl_id, dxpl_id) < 0) + udata.exists = FALSE; + if(H5G_traverse(loc, name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L__exists_final_cb, &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "path doesn't exist") /* Set return value */ - ret_value = (htri_t)exists; + ret_value = (htri_t)udata.exists; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5L_exists() */ +} /* H5L__exists() */ /*------------------------------------------------------------------------- diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index f3079bc..1c8690b 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -81,6 +81,8 @@ H5_DLL hid_t H5L_get_default_lcpl(void); H5_DLL herr_t H5L_move(H5G_loc_t *src_loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id); +H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id, + hid_t dxpl_id); H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id, diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 02c72e7..6f42a88 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -213,10 +213,10 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* for opening the destination object */ H5G_name_t src_path; /* Opened source object hier. path */ H5O_loc_t src_oloc; /* Opened source object object location */ + htri_t dst_exists; /* Does destination name exist already? */ hbool_t loc_found = FALSE; /* Location at 'name' found */ hbool_t obj_open = FALSE; /* Entry at 'name' found */ - - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, @@ -233,22 +233,10 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") /* check if destination name already exists */ - { - H5G_name_t tmp_path; - H5O_loc_t tmp_oloc; - H5G_loc_t tmp_loc; - - /* Set up group location */ - tmp_loc.oloc = &tmp_oloc; - tmp_loc.path = &tmp_path; - H5G_loc_reset(&tmp_loc); - - /* Check if object already exists in destination */ - if(H5G_loc_find(&dst_loc, dst_name, &tmp_loc, H5P_DEFAULT, H5AC_ind_dxpl_id) >= 0) { - H5G_name_free(&tmp_path); - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "destination object already exists") - } /* end if */ - } + if((dst_exists = H5L_exists_tolerant(&dst_loc, dst_name, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to check if destination name exists") + if(TRUE == dst_exists) + HGOTO_ERROR(H5E_OHDR, H5E_EXISTS, FAIL, "destination object already exists") /* Set up opened group location to fill in */ src_loc.oloc = &src_oloc; diff --git a/src/H5TS.c b/src/H5TS.c index 987bead..6a64a14 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -255,19 +255,18 @@ H5TS_cancel_count_inc(void) if (!cancel_counter) { /* - * First time thread calls library - create new counter and associate + * First time thread calls library - create new counter and associate * with key */ - cancel_counter = (H5TS_cancel_t *)H5MM_calloc(sizeof(H5TS_cancel_t)); + cancel_counter = (H5TS_cancel_t *)HDcalloc(1, sizeof(H5TS_cancel_t)); - if (!cancel_counter) { - H5E_push_stack(NULL, "H5TS_cancel_count_inc", - __FILE__, __LINE__, H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); - return FAIL; - } + if (!cancel_counter) { + H5E_push_stack(NULL, "H5TS_cancel_count_inc", __FILE__, __LINE__, + H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); + return FAIL; + } - ret_value = pthread_setspecific(H5TS_cancel_key_g, - (void *)cancel_counter); + ret_value = pthread_setspecific(H5TS_cancel_key_g, (void *)cancel_counter); } if (cancel_counter->cancel_count == 0) diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 2abdf6f..0ed8209 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -465,7 +465,7 @@ H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ - if(NULL==(vl.p=H5MM_malloc(len))) + if(NULL == (vl.p = HDmalloc(len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ @@ -691,7 +691,7 @@ H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end if */ else { /* Default to system malloc */ - if(NULL==(t = (char *)H5MM_malloc((seq_len+1)*base_size))) + if(NULL == (t = (char *)HDmalloc((seq_len + 1) * base_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") } /* end else */ @@ -1073,14 +1073,14 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi if(free_func != NULL) (*free_func)(vl->p, free_info); else - H5MM_xfree(vl->p); + HDfree(vl->p); } /* end if */ } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Free the VL string */ if(free_func != NULL) (*free_func)(*(char **)elem, free_info); else - H5MM_xfree(*(char **)elem); + HDfree(*(char **)elem); } else { HDassert(0 && "Invalid VL type"); } /* end else */ diff --git a/src/H5Ztrans.c b/src/H5Ztrans.c index 0a9a4da..2627a29 100644 --- a/src/H5Ztrans.c +++ b/src/H5Ztrans.c @@ -1032,7 +1032,7 @@ H5Z_xform_eval(H5Z_data_xform_t *data_xform_prop, void* array, size_t array_size /* Free the temporary arrays we used */ if(data_xform_prop->dat_val_pointers->num_ptrs > 1) for(i=0; idat_val_pointers->num_ptrs; i++) - HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end else */ done: @@ -1042,7 +1042,7 @@ done: if(data_xform_prop->dat_val_pointers->num_ptrs > 1) for(i = 0; i < data_xform_prop->dat_val_pointers->num_ptrs; i++) if(data_xform_prop->dat_val_pointers->ptr_dat_val[i]) - HDfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); + H5MM_xfree(data_xform_prop->dat_val_pointers->ptr_dat_val[i]); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/test/dtypes.c b/test/dtypes.c index 326294f..984b6c6 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -1789,6 +1789,13 @@ test_compound_9(void) goto error; } /* end if */ + if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ + rdata.str = NULL; + if(H5Dclose(dset_id) < 0) goto error; if(H5Tclose(cmpd_tid) < 0) @@ -1815,6 +1822,12 @@ test_compound_9(void) goto error; } /* end if */ + if((space_id = H5Dget_space(dset_id)) < 0) { + H5_FAILED(); AT(); + printf("Can't get space\n"); + goto error; + } /* end if */ + if((cmpd_tid = H5Dget_type(dset_id)) < 0) { H5_FAILED(); AT(); printf("cannot open dataset\n"); @@ -1842,10 +1855,19 @@ test_compound_9(void) goto error; } /* end if */ + if(H5Dvlen_reclaim(dup_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't read data\n"); + goto error; + } /* end if */ + rdata.str = NULL; + if(rdata.str) HDfree(rdata.str); if(H5Dclose(dset_id) < 0) goto error; + if(H5Sclose(space_id) < 0) + goto error; if(H5Tclose(cmpd_tid) < 0) goto error; if(H5Tclose(dup_tid) < 0) @@ -2020,12 +2042,17 @@ test_compound_10(void) printf("incorrect VL read data\n"); goto error; } - - HDfree(t1); - HDfree(t2); - HDfree(wdata[i].str); - HDfree(rdata[i].str); } /* end for */ + if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &rdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ + if(H5Dvlen_reclaim(arr_tid, space_id, H5P_DEFAULT, &wdata) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim read data\n"); + goto error; + } /* end if */ if(H5Dclose(dset_id) < 0) goto error; @@ -2090,6 +2117,8 @@ test_compound_11(void) hid_t big_tid, little_tid; /* Datatype IDs for type conversion */ hid_t big_tid2, little_tid2; /* Datatype IDs for type conversion */ hid_t opaq_src_tid, opaq_dst_tid; /* Datatype IDs for type conversion */ + hid_t space_id; /* Dataspace for buffer elements */ + hsize_t dim[1]; /* Dimensions for dataspace */ void *buf = NULL; /* Conversion buffer */ void *buf_orig = NULL; /* Copy of original conversion buffer */ void *bkg = NULL; /* Background buffer */ @@ -2138,6 +2167,13 @@ test_compound_11(void) /* Make copy of buffer before conversion */ HDmemcpy(buf_orig,buf,sizeof(big_t)*NTESTELEM); + dim[0] = NTESTELEM; + if((space_id = H5Screate_simple(1, dim, NULL)) < 0) { + H5_FAILED(); AT(); + printf("Can't create space\n"); + goto error; + } /* end if */ + /* Make copies of the 'big' and 'little' datatypes, so the type * conversion routine doesn't use the same ones this time and next time */ @@ -2169,8 +2205,12 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid2, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Build source and destination types for conversion routine */ if((opaq_src_tid=H5Tcreate(H5T_OPAQUE, (size_t)4)) < 0) TEST_ERROR @@ -2209,8 +2249,12 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Unregister the conversion routine */ if(H5Tunregister(H5T_PERS_HARD, "opaq_test", opaq_src_tid, opaq_dst_tid, convert_opaque) < 0) TEST_ERROR @@ -2243,12 +2287,17 @@ test_compound_11(void) (unsigned)u,((big_t *)buf_orig)[u].s1,(unsigned)u,((little_t *)buf)[u].s1); TEST_ERROR } /* end if */ - HDfree(((little_t *)buf)[u].s1); } /* end for */ + if(H5Dvlen_reclaim(little_tid, space_id, H5P_DEFAULT, buf) < 0) { + H5_FAILED(); AT(); + printf("Can't reclaim data\n"); + goto error; + } /* end if */ /* Free everything */ for(u=0; udel_dir == FHEAP_DEL_FORWARD) if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) - str = HDstrdup("(all - forward)"); + str = H5MM_strdup("(all - forward)"); else - str = HDstrdup("(half, refill, all - forward)"); + str = H5MM_strdup("(half, refill, all - forward)"); else if(tparam->del_dir == FHEAP_DEL_REVERSE) if(tparam->drain_half == FHEAP_DEL_DRAIN_ALL) - str = HDstrdup("(all - reverse)"); + str = H5MM_strdup("(all - reverse)"); else - str = HDstrdup("(half, refill, all - reverse)"); + str = H5MM_strdup("(half, refill, all - reverse)"); else - str = HDstrdup("(all - deleting heap)"); + str = H5MM_strdup("(all - deleting heap)"); return(str); } /* get_del_string() */ diff --git a/test/file_image.c b/test/file_image.c index 52d0b28..6d1845f 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -156,8 +156,8 @@ error: if(H5Pclose(fapl_1) < 0) retval = 1; if(H5Pclose(fapl_2) < 0) retval = 1; HDfree(buffer); - HDfree(temp); - HDfree(temp2); + H5free_memory(temp); + H5free_memory(temp2); if(retval == 0) PASSED(); diff --git a/test/links.c b/test/links.c index 2886304..c87d2b6 100644 --- a/test/links.c +++ b/test/links.c @@ -136,7 +136,7 @@ const char *FILENAME[] = { #define H5L_DIM1 100 #define H5L_DIM2 100 -#define FILTER_FILESIZE_MAX_FRACTION 0.9F +#define FILTER_FILESIZE_MAX_FRACTION (double)0.9F /* Creation order macros */ #define CORDER_GROUP_NAME "corder_group" @@ -548,8 +548,27 @@ cklinks(hid_t fapl, hbool_t new_format) HDputs(" expected file location."); TEST_ERROR } /* end if */ + if(H5Lexists(file, "/", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "d1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR if(H5Lexists(file, "grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if(H5Lexists(file, "/grp1", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + if(H5Lexists(file, "/grp1/hard", H5P_DEFAULT) != TRUE) FAIL_STACK_ERROR + H5E_BEGIN_TRY { + status = H5Lexists(file, "no_grp1/hard", H5P_DEFAULT); + } H5E_END_TRY; + if(status >= 0) { + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR + } /* end if */ + H5E_BEGIN_TRY { + status = H5Lexists(file, "/no_grp1/hard", H5P_DEFAULT); + } H5E_END_TRY; + if(status >= 0) { + H5_FAILED(); + HDputs(" H5Lexists() should have failed for a path with missing components."); + TEST_ERROR + } /* end if */ /* Symbolic link */ if(H5Oget_info_by_name(file, "grp1/soft", &oinfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -10985,6 +11004,7 @@ link_info_by_idx(hid_t fapl) char filename[NAME_BUF_SIZE];/* File name */ char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ @@ -11026,9 +11046,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)0, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Create several links, up to limit of compact form */ for(u = 0; u < max_compact; u++) { @@ -11068,9 +11088,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Create more links, to push group into dense form */ for(; u < (max_compact * 2); u++) { @@ -11110,9 +11130,9 @@ link_info_by_idx(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -11167,6 +11187,7 @@ link_info_by_idx_old(hid_t fapl) char tmpname[NAME_BUF_SIZE]; /* Temporary link name */ char tmpval[NAME_BUF_SIZE]; /* Temporary link value */ unsigned u; /* Local index variable */ + ssize_t name_len; /* Length of name */ herr_t ret; /* Generic return value */ /* Loop over creating hard or soft links */ @@ -11278,9 +11299,9 @@ link_info_by_idx_old(hid_t fapl) } H5E_END_TRY; if(ret >= 0) TEST_ERROR H5E_BEGIN_TRY { - ret = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); + name_len = H5Lget_name_by_idx(group_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, tmpname, (size_t)NAME_BUF_SIZE, H5P_DEFAULT); } H5E_END_TRY; - if(ret >= 0) TEST_ERROR + if(name_len >= 0) TEST_ERROR /* Verify state of group */ if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR @@ -12038,7 +12059,7 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_links - 1) - skip); + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Literate(group_id, idx_type, order, &skip, link_iterate_cb, iter_info) < 0) TEST_ERROR @@ -12066,11 +12087,11 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ - iter_info->nskipped = gskip = max_links / 2; + iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - gskip); + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Giterate(group_id, ".", &gskip, group_iterate_cb, iter_info) < 0) TEST_ERROR @@ -12111,7 +12132,7 @@ link_iterate_check(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = 3; iter_info->ncalled = 0; @@ -12468,7 +12489,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, with H5Giterate */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; @@ -12488,7 +12509,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? skip : ((max_links - 1) - skip); + iter_info->curr = (int64_t)(order != H5_ITER_DEC ? skip : ((max_links - 1) - skip)); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Literate(group_id, H5_INDEX_NAME, order, &skip, link_iterate_old_cb, iter_info) < 0) TEST_ERROR @@ -12516,11 +12537,11 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Skip over some links in group, with H5Giterate */ - iter_info->nskipped = gskip = max_links / 2; + iter_info->nskipped = (unsigned)(gskip = (int)(max_links / 2)); iter_info->order = order; iter_info->stop = -1; iter_info->ncalled = 0; - iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - gskip); + iter_info->curr = order != H5_ITER_DEC ? (unsigned)gskip : ((max_links - 1) - (unsigned)gskip); HDmemset(iter_info->visited, 0, sizeof(hbool_t) * iter_info->max_visit); if(H5Giterate(group_id, ".", &gskip, group_iterate_old_cb, iter_info) < 0) TEST_ERROR @@ -12561,7 +12582,7 @@ link_iterate_old_check(hid_t group_id, H5_iter_order_t order, #ifndef H5_NO_DEPRECATED_SYMBOLS /* Iterate over links in group, stopping in the middle, with H5Giterate() */ - iter_info->nskipped = gskip = 0; + iter_info->nskipped = (unsigned)(gskip = 0); iter_info->order = order; iter_info->stop = 3; iter_info->ncalled = 0; diff --git a/test/objcopy.c b/test/objcopy.c index f3806cd..cd978f2 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -197,7 +197,7 @@ addr_insert(H5O_info_t *oi) * *------------------------------------------------------------------------- */ -static hbool_t +static H5_ATTR_PURE hbool_t addr_lookup(H5O_info_t *oi) { size_t n; @@ -512,8 +512,12 @@ test_copy_attach_attribute_vl(hid_t loc_id) ret_value = 0; done: - if(tid >0 && sid > 0) - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + if(tid >0 && sid > 0) { + hid_t dxpl_id = H5Pcreate(H5P_DATASET_XFER); + H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL); + H5Dvlen_reclaim(tid, sid, dxpl_id, buf); + H5Pclose(dxpl_id); + } if(sid > 0) H5Sclose(sid); if(tid > 0) @@ -4028,6 +4032,7 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_ hid_t tid = -1; /* Datatype ID */ hid_t sid = -1; /* Dataspace ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -4111,7 +4116,12 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_ /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4127,6 +4137,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4158,6 +4169,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ @@ -4250,7 +4262,12 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4266,6 +4283,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4297,6 +4316,7 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -4387,7 +4407,12 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4403,6 +4428,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -4550,6 +4576,7 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t tid = -1; /* Datatype ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ hsize_t dim2d[2]; /* Dataset dimensions */ hsize_t chunk_dim2d[2] ={CHUNK_SIZE_1, CHUNK_SIZE_2}; /* Chunk dimensions */ hvl_t buf[DIM_SIZE_1][DIM_SIZE_2]; /* Buffer for writing data */ @@ -4649,7 +4676,12 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -4668,6 +4700,7 @@ error: H5Dclose(did); H5Pclose(pid); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Sclose(sid); H5Fclose(fid_dst); @@ -6357,6 +6390,7 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6456,7 +6490,12 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6473,6 +6512,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6504,6 +6544,7 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t tid = -1, tid_copy=-1; /* Datatype ID */ hid_t sid = -1; /* Dataspace ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6596,7 +6637,12 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6612,6 +6658,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6644,6 +6691,7 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6744,7 +6792,12 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6761,6 +6814,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6793,6 +6847,7 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -6894,7 +6949,12 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_ /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid_copy, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid_copy, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid_copy) < 0) TEST_ERROR @@ -6911,6 +6971,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid_copy, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid_copy); H5Sclose(sid); @@ -6943,6 +7004,7 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7049,7 +7111,12 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7066,6 +7133,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7098,6 +7167,7 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7203,7 +7273,12 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h if(H5Fclose(fid_dst) < 0) TEST_ERROR /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7220,6 +7295,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7252,6 +7329,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7359,7 +7437,12 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7377,6 +7460,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7409,6 +7493,7 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j, k; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hvl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7516,7 +7601,12 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fap /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid2, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid2, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid) < 0) TEST_ERROR @@ -7534,6 +7624,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid2, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid); H5Tclose(tid2); H5Sclose(sid); @@ -7576,6 +7667,7 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t sid = -1; /* Dataspace ID */ hid_t did = -1; /* Dataset ID */ hid_t did2 = -1; /* Dataset ID */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7665,7 +7757,12 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7682,6 +7779,7 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); @@ -7714,6 +7812,7 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ hsize_t chunk_dim1d[1] = {CHUNK_SIZE_1}; /* Chunk dimensions */ @@ -7811,7 +7910,12 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7828,6 +7932,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); @@ -7860,6 +7966,7 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl hid_t sid = -1; /* Dataspace ID */ hid_t pid = -1; /* Dataset creation property list ID */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t dxpl_id = -1; /* Dataset transfer property list ID */ unsigned int i, j; /* Local index variables */ hsize_t dim1d[1]; /* Dataset dimensions */ cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */ @@ -7956,7 +8063,12 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl /* Reclaim vlen buffer */ - if(H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf) < 0) TEST_ERROR + if(H5Tdetect_class(tid, H5T_VLEN) == TRUE) { + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR + if(H5Pset_vlen_mem_manager(dxpl_id, NULL, NULL, NULL, NULL) < 0) TEST_ERROR + if(H5Dvlen_reclaim(tid, sid, dxpl_id, buf) < 0) TEST_ERROR + if(H5Pclose(dxpl_id) < 0) TEST_ERROR + } /* end if */ /* close datatype */ if(H5Tclose(tid2) < 0) TEST_ERROR @@ -7973,6 +8085,8 @@ error: H5Dclose(did2); H5Dclose(did); H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, buf); + H5Pclose(dxpl_id); + H5Pclose(pid); H5Tclose(tid2); H5Tclose(tid); H5Sclose(sid); diff --git a/test/tgenprop.c b/test/tgenprop.c index c4f3a3f..b670c0d 100644 --- a/test/tgenprop.c +++ b/test/tgenprop.c @@ -1780,7 +1780,7 @@ test_genprop_path(void) CHECK_PTR(path, "H5P_get_class_path_test"); if(HDstrcmp(path,CLASS1_PATH)!=0) TestErrPrintf("Class names don't match!, path=%s, CLASS1_PATH=%s\n",path,CLASS1_PATH); - HDfree(path); + H5free_memory(path); /* Create another new generic class, derived from first class */ cid2 = H5Pcreate_class(cid1,CLASS2_NAME, NULL, NULL, NULL, NULL, NULL, NULL); @@ -1805,7 +1805,7 @@ test_genprop_path(void) VERIFY(ret, 1, "H5Pequal"); /* Release the path string */ - HDfree(path); + H5free_memory(path); /* Close class */ ret = H5Pclose_class(cid3); diff --git a/test/tmisc.c b/test/tmisc.c index 1298f6b..011486a 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -462,7 +462,8 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att1, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Aclose(att1); CHECK(ret, FAIL, "HAclose"); @@ -487,7 +488,8 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att2, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, dataspace, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); ret = H5Aclose(att2); CHECK(ret, FAIL, "HAclose"); @@ -514,6 +516,7 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name { hid_t file, root, att; hid_t type; + hid_t space; herr_t ret; misc2_struct data_check; @@ -528,10 +531,17 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name att = H5Aopen(root, att_name, H5P_DEFAULT); CHECK(att, FAIL, "H5Aopen"); + space = H5Aget_space(att); + CHECK(space, FAIL, "H5Aget_space"); + ret = H5Aread(att, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - HDfree(data_check.string); + ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_check); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); + + ret = H5Sclose(space); + CHECK(ret, FAIL, "H5Sclose"); ret = H5Aclose(att); CHECK(ret, FAIL, "H5Aclose"); diff --git a/test/tvlstr.c b/test/tvlstr.c index 02bd59d..dbc3083 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -604,7 +604,7 @@ static void test_write_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att) != 0) TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; ret = H5Aclose(att); @@ -626,7 +626,7 @@ static void test_write_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att_write) != 0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; /* The attribute string written is freed below, in the test_read_vl_string_attribute() test */ @@ -687,7 +687,7 @@ static void test_read_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att) != 0) TestErrPrintf("VL string attributes don't match!, string_att=%s, string_att_check=%s\n",string_att,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; ret = H5Aclose(att); @@ -704,7 +704,7 @@ static void test_read_vl_string_attribute(void) if(HDstrcmp(string_att_check,string_att_write) != 0) TestErrPrintf("VL string attributes don't match!, string_att_write=%s, string_att_check=%s\n",string_att_write,string_att_check); - HDfree(string_att_check); + H5free_memory(string_att_check); string_att_check = NULL; } @@ -762,7 +762,8 @@ static void read_scalar_dset(hid_t file, hid_t type, hid_t space, char *name, ch if(HDstrcmp(data, data_read)) TestErrPrintf("Expected %s for dataset %s but read %s\n", data, name, data_read); - HDfree(data_read); + ret = H5Dvlen_reclaim(type, space, H5P_DEFAULT, &data_read); + CHECK(ret, FAIL, "H5Dvlen_reclaim"); } /**************************************************************** diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index cce5f3d..98468c9 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -973,7 +973,7 @@ print_enum_type(h5tools_str_t *buffer, hid_t type, int ind) /* Release resources */ for(i = 0; i < (unsigned)nmembs; i++) - HDfree(name[i]); + H5free_memory(name[i]); HDfree(name); HDfree(value); } @@ -1856,13 +1856,10 @@ dataset_list2(hid_t dset, const char H5_ATTR_UNUSED *name) if (vmaps) { size_t next; - ssize_t ssize_out; h5tools_str_append(&buffer, " %-10s {%ld} Source {\n", "Maps:", vmaps); for (next = 0; next < (unsigned) vmaps; next++) { - ssize_out = H5Pget_virtual_filename(dcpl, next, NULL, 0); H5Pget_virtual_filename(dcpl, next, f_name, sizeof(f_name)); - ssize_out = H5Pget_virtual_dsetname(dcpl, next, NULL, 0); H5Pget_virtual_dsetname(dcpl, next, dset_name, sizeof(dset_name)); h5tools_str_append(&buffer, " %-10s ", " "); print_string(&buffer, f_name, TRUE); -- cgit v0.12 From 42bf0e2136a60a9dc18a2a2a5fb029fa5a0d6562 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 1 Jan 2016 20:58:18 -0500 Subject: [svn-r28765] Description: Bump the nunmber of v2 B-tree records for the random 4-level B-tree update test by another 25,000 records. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (Too minor to require h5committest) --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index b0c0ac3..3278b67 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2650 * 1000) +#define INSERT_MANY_REC (2675 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12 From d4f3d93b8d9188548407453e10df12dc9ba0480f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 2 Jan 2016 20:03:08 -0500 Subject: [svn-r28769] Description: More memory cleanups and leak elimination. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5Dcompact.c | 5 +---- src/H5Eint.c | 5 +++++ tools/h5repack/h5repacktst.c | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index ebe75bd..df2a740 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -440,12 +440,9 @@ H5D__compact_copy(H5F_t *f_src, H5O_storage_compact_t *storage_src, H5F_t *f_dst HDassert(storage_src); HDassert(f_dst); HDassert(storage_dst); + HDassert(storage_dst->buf); HDassert(dt_src); - /* Allocate space for destination data */ - if(NULL == (storage_dst->buf = H5MM_malloc(storage_src->size))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "unable to allocate memory for compact dataset") - /* Create datatype ID for src datatype, so it gets freed */ if((tid_src = H5I_register(H5I_DATATYPE, dt_src, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register source file datatype") diff --git a/src/H5Eint.c b/src/H5Eint.c index 6e84a09..6ed405f 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -743,8 +743,13 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin done: if(va_started) va_end(ap); +#ifdef H5_HAVE_VASPRINTF + if(tmp) + HDfree(tmp); +#else /* H5_HAVE_VASPRINTF */ if(tmp) H5MM_xfree(tmp); +#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_printf_stack() */ diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c index 3959300..972014d 100644 --- a/tools/h5repack/h5repacktst.c +++ b/tools/h5repack/h5repacktst.c @@ -1554,6 +1554,8 @@ int main (void) puts("All h5repack tests passed."); + h5tools_close(); + return 0; error: -- cgit v0.12 From f8465bd1243d16783b4df44b40193d8f5137a781 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sun, 3 Jan 2016 09:22:49 -0500 Subject: [svn-r28773] Description: Clear memory for shared message info when "deferring" and using memory checker, so valgrind doesn't whine. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5SM.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/H5SM.c b/src/H5SM.c index 4a562dd..413ad1f 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -1375,11 +1375,23 @@ H5SM_write_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, } /* end else */ } /* end else */ - if(found) + if(found) { /* If the message was found, it's shared in the heap (now). Set up a * shared message so we can mark it as shared. */ shared.type = H5O_SHARE_TYPE_SOHM; + +#ifdef H5_USING_MEMCHECKER + /* Reset the shared message payload if deferring. This doesn't matter + * in the long run since the payload will get overwritten when the + * non-deferred call to this routine occurs, but it stops memory + * checkers like valgrind from whining when the partially initialized + * shared message is serialized. -QAK + */ + if(defer) + HDmemset(&shared.u, 0, sizeof(shared.u)); +#endif /* H5_USING_MEMCHECKER */ + } /* end if */ else { htri_t share_in_ohdr; /* Whether the new message can be shared in another object's header */ -- cgit v0.12 From f017eb6fc09d74aa83eb5391028be5fd12380d34 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sun, 3 Jan 2016 17:06:52 -0500 Subject: [svn-r28777] Description: Add --enable-memory-alloc-sanity-check option to configure, to track and sanity check memory allocations within the library. This is orthogonal to the --enable-using-memchecker option and can be used with/without it. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- CMakeLists.txt | 8 + config/cmake/cacheinit.cmake | 2 + config/cmake/libhdf5.settings.cmake.in | 1 + config/cmake/mccacheinit.cmake | 2 + configure.ac | 31 ++++ release_docs/INSTALL_CMake.txt | 2 + src/H5.c | 5 + src/H5Dchunk.c | 32 +++- src/H5Dpkg.h | 25 +-- src/H5MM.c | 323 +++++++++++++++++++++++++++++++-- src/H5MMprivate.h | 13 +- src/libhdf5.settings.in | 1 + 12 files changed, 397 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65124ab..23b55c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -376,6 +376,14 @@ if (HDF5_ENABLE_USING_MEMCHECKER) endif (HDF5_ENABLE_USING_MEMCHECKER) #----------------------------------------------------------------------------- +# Option to indicate internal memory allocation sanity checks are enabled +#----------------------------------------------------------------------------- +option (HDF5_MEMORY_ALLOC_SANITY_CHECK "Indicate that internal memory allocation sanity checks are enabled" OFF) +if (HDF5_MEMORY_ALLOC_SANITY_CHECK) + set (H5_MEMORY_ALLOC_SANITY_CHECK 1) +endif (HDF5_MEMORY_ALLOC_SANITY_CHECK) + +#----------------------------------------------------------------------------- # Option to use deprecated public API symbols #----------------------------------------------------------------------------- option (HDF5_ENABLE_DEPRECATED_SYMBOLS "Enable deprecated public API symbols" ON) diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index 4bef99f..5cae21b 100644 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -36,6 +36,8 @@ set (HDF5_ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage for Libraries and set (HDF5_ENABLE_USING_MEMCHECKER OFF CACHE BOOL "Indicate that a memory checker is used" FORCE) +set (HDF5_MEMORY_ALLOC_SANITY_CHECK OFF CACHE BOOL "Indicate that internal memory allocation sanity checks are enabled" FORCE) + set (HDF5_DISABLE_COMPILER_WARNINGS OFF CACHE BOOL "Disable compiler warnings" FORCE) set (HDF5_USE_FOLDERS ON CACHE BOOL "Enable folder grouping of projects in IDEs." FORCE) diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index ba764a4..cc6ae3e 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -65,6 +65,7 @@ Features: dmalloc: @H5_HAVE_LIBDMALLOC@ Clear file buffers before write: @HDF5_Enable_Clear_File_Buffers@ Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@ +Memory allocation sanity checks: @HDF5_MEMORY_ALLOC_SANITY_CHECK@ Function Stack Tracing: @HDF5_ENABLE_CODESTACK@ Strict File Format Checks: @HDF5_STRICT_FORMAT_CHECKS@ Optimization Instrumentation: @HDF5_Enable_Instrument@ diff --git a/config/cmake/mccacheinit.cmake b/config/cmake/mccacheinit.cmake index 19ecc15..e54db1f 100644 --- a/config/cmake/mccacheinit.cmake +++ b/config/cmake/mccacheinit.cmake @@ -48,6 +48,8 @@ set (HDF5_ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage for Libraries and set (HDF5_ENABLE_USING_MEMCHECKER ON CACHE BOOL "Indicate that a memory checker is used" FORCE) +set (HDF5_MEMORY_ALLOC_SANITY_CHECK OFF CACHE BOOL "Indicate that internal memory allocation sanity checks are enabled" FORCE) + set (HDF5_DISABLE_COMPILER_WARNINGS OFF CACHE BOOL "Disable compiler warnings" FORCE) set (HDF5_USE_FOLDERS ON CACHE BOOL "Enable folder grouping of projects in IDEs." FORCE) diff --git a/configure.ac b/configure.ac index 0e853a8..9c1d5b0 100644 --- a/configure.ac +++ b/configure.ac @@ -2044,6 +2044,8 @@ AC_ARG_ENABLE([using-memchecker], library. Enabling this causes the library to be more picky about it's memory operations and also disables the library's free space manager code. + This option is orthogonal to the + --enable-memory-alloc-sanity-check option. Default=no.])], [USINGMEMCHECKER=$enableval]) @@ -2062,6 +2064,35 @@ case "X-$USINGMEMCHECKER" in ;; esac +## ---------------------------------------------------------------------- +## Check if they would like to enable the internal memory allocation sanity +## checking code. +## +AC_SUBST([MEMORYALLOCSANITYCHECK]) +AC_MSG_CHECKING([whether internal memory allocation sanity checking is used]) +AC_ARG_ENABLE([memory-alloc-sanity-check], + [AS_HELP_STRING([--enable-memory-alloc-sanity-check], + [Enable this option to turn on internal memory + allocation sanity checking. This could cause + more memory use and somewhat slower allocation. + This option is orthogonal to the + --enable-using-memchecker option. + Default=no.])], + [MEMORYALLOCSANITYCHECK=$enableval]) + +case "X-$MEMORYALLOCSANITYCHECK" in + X-yes) + MEMORYALLOCSANITYCHECK=yes + AC_MSG_RESULT([yes]) + AC_DEFINE([MEMORY_ALLOC_SANITY_CHECK], [1], + [Define to enable internal memory allocation sanity checking.]) + ;; + *) + MEMORYALLOCSANITYCHECK=no + AC_MSG_RESULT([no]) + ;; +esac + ## Checkpoint the cache AC_CACHE_SAVE diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index e745084..37326ed 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -411,6 +411,7 @@ These five steps are described in detail below. set (HDF5_BUILD_PARALLEL_ALL OFF CACHE BOOL "Build Parallel Programs" FORCE) set (HDF5_ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage for Libraries and Programs" FORCE) set (HDF5_ENABLE_USING_MEMCHECKER OFF CACHE BOOL "Indicate that a memory checker is used" FORCE) + set (HDF5_MEMORY_ALLOC_SANITY_CHECK OFF CACHE BOOL "Indicate that internal memory allocation sanity checks are enabled" FORCE) set (HDF5_DISABLE_COMPILER_WARNINGS OFF CACHE BOOL "Disable compiler warnings" FORCE) set (HDF5_USE_FOLDERS ON CACHE BOOL "Enable folder grouping of projects in IDEs." FORCE) set (HDF5_USE_16_API_DEFAULT OFF CACHE BOOL "Use the HDF5 1.6.x API by default" FORCE) @@ -587,6 +588,7 @@ HDF5_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux HDF5_ENABLE_PARALLEL "Enable parallel build (requires MPI)" OFF HDF5_ENABLE_TRACE "Enable API tracing capability" OFF HDF5_ENABLE_USING_MEMCHECKER "Indicate that a memory checker is used" OFF +HDF5_MEMORY_ALLOC_SANITY_CHECK "Indicate that internal memory allocation sanity checks are enabled" OFF HDF5_METADATA_TRACE_FILE "Enable metadata trace file collection" OFF HDF5_NO_PACKAGES "Do not include CPack Packaging" OFF HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" OFF diff --git a/src/H5.c b/src/H5.c index 2086ce8..a522398 100644 --- a/src/H5.c +++ b/src/H5.c @@ -396,6 +396,11 @@ H5_term_library(void) (void)H5MM_free(tmp_open_stream); } /* end while */ +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + /* Sanity check memory allocations */ + H5MM_final_sanity_check(); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + /* Reset flag indicating that the library is being shut down */ H5_TERM_GLOBAL = FALSE; diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 6b99a43..0c4cba1 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -107,6 +107,25 @@ /* Local Typedefs */ /******************/ +/* Raw data chunks are cached. Each entry in the cache is: */ +typedef struct H5D_rdcc_ent_t { + hbool_t locked; /*entry is locked in cache */ + hbool_t dirty; /*needs to be written to disk? */ + hbool_t deleted; /*chunk about to be deleted */ + hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ + uint32_t rd_count; /*bytes remaining to be read */ + uint32_t wr_count; /*bytes remaining to be written */ + H5F_block_t chunk_block; /*offset/length of chunk in file */ + hsize_t chunk_idx; /*index of chunk in dataset */ + uint8_t *chunk; /*the unfiltered chunk data */ + unsigned idx; /*index in hash table */ + struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ + struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ + struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ +} H5D_rdcc_ent_t; +typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ + /* Callback info for iteration to prune chunks */ typedef struct H5D_chunk_it_ud1_t { H5D_chunk_common_ud_t common; /* Common info for B-tree user data (must be first) */ @@ -244,6 +263,11 @@ static herr_t H5D__chunk_flush_entry(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, H5D_rdcc_ent_t *ent, hbool_t reset); static herr_t H5D__chunk_cache_evict(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, H5D_rdcc_ent_t *ent, hbool_t flush); +static void *H5D__chunk_lock(const H5D_io_info_t *io_info, + H5D_chunk_ud_t *udata, hbool_t relax); +static herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, + const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, + uint32_t naccessed); static herr_t H5D__chunk_cache_prune(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t *dxpl_cache, size_t size); static herr_t H5D__chunk_prune_fill(H5D_chunk_it_ud1_t *udata); @@ -3008,7 +3032,7 @@ done: * *------------------------------------------------------------------------- */ -void * +static void * H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t relax) { @@ -3024,7 +3048,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, void *chunk = NULL; /*the file chunk */ void *ret_value = NULL; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC HDassert(io_info); HDassert(io_info->dxpl_cache); @@ -3286,7 +3310,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, uint32_t naccessed) { @@ -3294,7 +3318,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, const H5D_rdcc_t *rdcc = &(io_info->dset->shared->cache.chunk); herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC /* Sanity check */ HDassert(io_info); diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 4e6376b..97fc442 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -369,6 +369,7 @@ typedef struct H5D_chunk_cached_t { } H5D_chunk_cached_t; /* The raw data chunk cache */ +struct H5D_rdcc_ent_t; /* Forward declaration of struct used below */ typedef struct H5D_rdcc_t { struct { unsigned ninits; /* Number of chunk creations */ @@ -497,25 +498,6 @@ typedef struct { hsize_t size; /* Accumulated number of bytes for the selection */ } H5D_vlen_bufsize_t; -/* Raw data chunks are cached. Each entry in the cache is: */ -typedef struct H5D_rdcc_ent_t { - hbool_t locked; /*entry is locked in cache */ - hbool_t dirty; /*needs to be written to disk? */ - hbool_t deleted; /*chunk about to be deleted */ - hsize_t scaled[H5O_LAYOUT_NDIMS]; /*scaled chunk 'name' (coordinates) */ - uint32_t rd_count; /*bytes remaining to be read */ - uint32_t wr_count; /*bytes remaining to be written */ - H5F_block_t chunk_block; /*offset/length of chunk in file */ - hsize_t chunk_idx; /*index of chunk in dataset */ - uint8_t *chunk; /*the unfiltered chunk data */ - unsigned idx; /*index in hash table */ - struct H5D_rdcc_ent_t *next;/*next item in doubly-linked list */ - struct H5D_rdcc_ent_t *prev;/*previous item in doubly-linked list */ - struct H5D_rdcc_ent_t *tmp_next;/*next item in temporary doubly-linked list */ - struct H5D_rdcc_ent_t *tmp_prev;/*previous item in temporary doubly-linked list */ -} H5D_rdcc_ent_t; -typedef H5D_rdcc_ent_t *H5D_rdcc_ent_ptr_t; /* For free lists */ - /*****************************/ /* Package Private Variables */ @@ -623,11 +605,6 @@ H5_DLL herr_t H5D__chunk_set_info(const H5D_t *dset); H5_DLL hbool_t H5D__chunk_is_space_alloc(const H5O_storage_t *storage); H5_DLL herr_t H5D__chunk_lookup(const H5D_t *dset, hid_t dxpl_id, const hsize_t *scaled, H5D_chunk_ud_t *udata); -H5_DLL void *H5D__chunk_lock(const H5D_io_info_t *io_info, - H5D_chunk_ud_t *udata, hbool_t relax); -H5_DLL herr_t H5D__chunk_unlock(const H5D_io_info_t *io_info, - const H5D_chunk_ud_t *udata, hbool_t dirty, void *chunk, - uint32_t naccessed); H5_DLL herr_t H5D__chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes); H5_DLL herr_t H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, hsize_t old_dim[]); diff --git a/src/H5MM.c b/src/H5MM.c index a37bbff..05bfb9e 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -25,9 +25,195 @@ */ -#include "H5private.h" -#include "H5Eprivate.h" -#include "H5MMprivate.h" +/****************/ +/* Module Setup */ +/****************/ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +#define H5MM_SIG_SIZE 4 +#define H5MM_HEAD_GUARD_SIZE 8 +#define H5MM_TAIL_GUARD_SIZE 8 +#define H5MM_BLOCK_FROM_BUF(mem) ((H5MM_block_t *)((unsigned char *)mem - (offsetof(H5MM_block_t, b) + H5MM_HEAD_GUARD_SIZE))) +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +/******************/ +/* Local Typedefs */ +/******************/ + +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +/* Memory allocation "block", wrapped around each allocation */ +struct H5MM_block_t; /* Forward declaration for typedef */ +typedef struct H5MM_block_t { + unsigned char sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ + struct H5MM_block_t *next; /* Pointer to next block in the list of allocated blocks */ + struct H5MM_block_t *prev; /* Pointer to previous block in the list of allocated blocks */ + size_t size; + hbool_t in_use; + unsigned char b[]; +} H5MM_block_t; +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +/********************/ +/* Local Prototypes */ +/********************/ +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +static hbool_t H5MM__is_our_block(void *mem); +static void H5MM__sanity_check_block(const H5MM_block_t *block); +static void H5MM__sanity_check(void *mem); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +/* Constant strings for block signature, head & tail guards */ +static const char H5MM_block_signature_s[H5MM_SIG_SIZE] = {'H', '5', 'M', 'M'}; +static const char H5MM_block_head_guard_s[H5MM_HEAD_GUARD_SIZE] = {'D', 'E', 'A', 'D', 'B', 'E', 'E', 'F'}; +static const char H5MM_block_tail_guard_s[H5MM_TAIL_GUARD_SIZE] = {'B', 'E', 'E', 'F', 'D', 'E', 'A', 'D'}; + +/* Flag to indicate the the interface has been initialized */ +static hbool_t H5MM_init_s = FALSE; + +/* Head of the list of allocated blocks */ +static H5MM_block_t H5MM_block_head_s; + +/* Statistics about block allocations */ +static unsigned long long H5MM_total_alloc_bytes_s = 0; +static unsigned long long H5MM_curr_alloc_bytes_s = 0; +static unsigned long long H5MM_peak_alloc_bytes_s = 0; +static size_t H5MM_max_block_size_s = 0; +static size_t H5MM_total_alloc_blocks_count_s = 0; +static size_t H5MM_curr_alloc_blocks_count_s = 0; +static size_t H5MM_peak_alloc_blocks_count_s = 0; +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + +/*------------------------------------------------------------------------- + * Function: H5MM__is_our_block + * + * Purpose: Try to determine if a memory buffer has been allocated through + * the H5MM* interface, instead of the system's malloc() routines. + * + * Return: Success: TRUE/FALSE + * Failure: (Can't fail) + * + * Programmer: Quincey Koziol + * Dec 30 2015 + * + *------------------------------------------------------------------------- + */ +static hbool_t +H5MM__is_our_block(void *mem) +{ + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + + return(0 == HDmemcmp(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE)); +} + + +/*------------------------------------------------------------------------- + * Function: H5MM__sanity_check_block + * + * Purpose: Check a block wrapper around a buffer to validate it. + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Dec 30 2015 + * + *------------------------------------------------------------------------- + */ +static void +H5MM__sanity_check_block(const H5MM_block_t *block) +{ + HDassert(block->size > 0); + HDassert(block->in_use); + /* Check for head & tail guards, if not head of linked list */ + if(block->size != SIZE_T_MAX) { + HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); + HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); + } +} + + +/*------------------------------------------------------------------------- + * Function: H5MM__sanity_check + * + * Purpose: Check a buffer to validate it (just calls + * H5MM__sanity_check_block after finding block for buffer) + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Dec 30 2015 + * + *------------------------------------------------------------------------- + */ +static void +H5MM__sanity_check(void *mem) +{ + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + + H5MM__sanity_check_block(block); +} + + +/*------------------------------------------------------------------------- + * Function: H5MM_final_sanity_check + * + * Purpose: Final sanity checks on memory allocation. + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Jan 1 2016 + * + *------------------------------------------------------------------------- + */ +void +H5MM_final_sanity_check(void) +{ + HDassert(0 == H5MM_curr_alloc_bytes_s); + HDassert(0 == H5MM_curr_alloc_blocks_count_s); + HDassert(H5MM_block_head_s.next == &H5MM_block_head_s); + HDassert(H5MM_block_head_s.prev == &H5MM_block_head_s); +#ifdef H5MM_PRINT_MEMORY_STATS + HDfprintf(stderr, "%s: H5MM_total_alloc_bytes_s = %llu\n", __func__, H5MM_total_alloc_bytes_s); + HDfprintf(stderr, "%s: H5MM_peak_alloc_bytes_s = %llu\n", __func__, H5MM_peak_alloc_bytes_s); + HDfprintf(stderr, "%s: H5MM_max_block_size_s = %zu\n", __func__, H5MM_max_block_size_s); + HDfprintf(stderr, "%s: H5MM_total_alloc_blocks_count_s = %zu\n", __func__, H5MM_total_alloc_blocks_count_s); + HDfprintf(stderr, "%s: H5MM_peak_alloc_blocks_count_s = %zu\n", __func__, H5MM_peak_alloc_blocks_count_s); +#endif /* H5MM_PRINT_MEMORY_STATS */ +} +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ /*------------------------------------------------------------------------- @@ -42,7 +228,6 @@ * bytes usually indicate problems. * * Return: Success: Pointer new memory - * * Failure: NULL * * Programmer: Quincey Koziol @@ -60,12 +245,61 @@ H5MM_malloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(size) +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + /* Initialize block list head singleton */ + if(!H5MM_init_s) { + HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); + H5MM_block_head_s.next = &H5MM_block_head_s; + H5MM_block_head_s.prev = &H5MM_block_head_s; + H5MM_block_head_s.size = SIZE_T_MAX; + H5MM_block_head_s.in_use = TRUE; + + H5MM_init_s = TRUE; + } /* end if */ +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + + if(size) { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + H5MM_block_t *block; + size_t alloc_size = sizeof(H5MM_block_t) + size + H5MM_HEAD_GUARD_SIZE + H5MM_TAIL_GUARD_SIZE; + + if(NULL != (block = (H5MM_block_t *)HDmalloc(alloc_size))) { + /* Set up block */ + HDmemcpy(block->sig, H5MM_block_signature_s, H5MM_SIG_SIZE); + block->next = H5MM_block_head_s.next; + H5MM_block_head_s.next = block; + block->next->prev = block; + block->prev = &H5MM_block_head_s; + block->size = size; + block->in_use = TRUE; + HDmemcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE); + HDmemcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE); + + /* Update statistics */ + H5MM_total_alloc_bytes_s += size; + H5MM_curr_alloc_bytes_s += size; + if(H5MM_curr_alloc_bytes_s > H5MM_peak_alloc_bytes_s) + H5MM_peak_alloc_bytes_s = H5MM_curr_alloc_bytes_s; + if(size > H5MM_max_block_size_s) + H5MM_max_block_size_s = size; + H5MM_total_alloc_blocks_count_s++; + H5MM_curr_alloc_blocks_count_s++; + if(H5MM_curr_alloc_blocks_count_s > H5MM_peak_alloc_blocks_count_s) + H5MM_peak_alloc_blocks_count_s = H5MM_curr_alloc_blocks_count_s; + + /* Set buffer to return */ + ret_value = block->b + H5MM_HEAD_GUARD_SIZE; + } /* end if */ + else + ret_value = NULL; +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDmalloc(size); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end if */ else ret_value = NULL; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_malloc() */ @@ -83,7 +317,6 @@ H5MM_malloc(size_t size) * * * Return: Success: Pointer new memory - * * Failure: NULL * * Programmer: Quincey Koziol @@ -101,12 +334,18 @@ H5MM_calloc(size_t size) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(size) + if(size) { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if(NULL != (ret_value = H5MM_malloc(size))) + HDmemset(ret_value, 0, size); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDcalloc((size_t)1, size); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end if */ else ret_value = NULL; - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_calloc() */ @@ -123,9 +362,7 @@ H5MM_calloc(size_t size) * Note that the (NULL, 0) combination is undefined behavior * in the C standard. * - * Return: Success: Ptr to new memory if size > 0 - * NULL if size is zero - * + * Return: Success: Ptr to new memory if size > 0, NULL if size is zero * Failure: NULL (input buffer is unchanged on failure) * * Programmer: Robb Matzke @@ -143,17 +380,39 @@ H5MM_realloc(void *mem, size_t size) HDassert(mem || size); - if(NULL == mem && 0 == size) { + if(NULL == mem && 0 == size) /* Not defined in the standard, return NULL */ ret_value = NULL; - } else { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if(size > 0) { + if(mem) { + if(H5MM__is_our_block(mem)) { + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + size_t old_size = block->size; + + H5MM__sanity_check(mem); + + ret_value = H5MM_malloc(size); + HDmemcpy(ret_value, mem, MIN(size, old_size)); + H5MM_xfree(mem); + } /* end if */ + else + ret_value = HDrealloc(mem, size); + } + else + ret_value = H5MM_malloc(size); + } + else + ret_value = H5MM_xfree(mem); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ ret_value = HDrealloc(mem, size); /* Some platforms do not return NULL if size is zero. */ if(0 == size) ret_value = NULL; - } +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5MM_realloc() */ @@ -250,8 +509,38 @@ H5MM_xfree(void *mem) /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - if(mem) + if(mem) { +#if defined H5_MEMORY_ALLOC_SANITY_CHECK + if(H5MM__is_our_block(mem)) { + H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); + + /* Run sanity checks on this block and its neighbors */ + H5MM__sanity_check(mem); + H5MM__sanity_check_block(block->next); + H5MM__sanity_check_block(block->prev); + + /* Update statistics */ + H5MM_curr_alloc_bytes_s -= block->size; + H5MM_curr_alloc_blocks_count_s--; + + /* Reset block info */ + HDmemset(block->sig, 0, H5MM_SIG_SIZE); + block->next->prev = block->prev; + block->prev->next = block->next; + block->next = NULL; + block->prev = NULL; + block->in_use = FALSE; + + /* Free the block (finally!) */ + HDfree(block); + } + else + HDfree(mem); +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ HDfree(mem); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + } /* end if */ - FUNC_LEAVE_NOAPI(NULL); + FUNC_LEAVE_NOAPI(NULL) } /* end H5MM_xfree() */ + diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index 0d608b2..c494a60 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -21,8 +21,6 @@ * * Purpose: Private header for memory management. * - * Modifications: - * *------------------------------------------------------------------------- */ #ifndef _H5MMprivate_H @@ -33,7 +31,12 @@ /* Private headers needed by this file */ #include "H5private.h" +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +/*#define H5MM_PRINT_MEMORY_STATS */ +#define H5MM_free(Z) H5MM_xfree(Z) +#else /* H5_MEMORY_ALLOC_SANITY_CHECK */ #define H5MM_free(Z) HDfree(Z) +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ /* * Library prototypes... @@ -44,5 +47,9 @@ H5_DLL void *H5MM_realloc(void *mem, size_t size); H5_DLL char *H5MM_xstrdup(const char *s); H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); +#if defined H5_MEMORY_ALLOC_SANITY_CHECK +H5_DLL void H5MM_final_sanity_check(void); +#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ + +#endif /* _H5MMprivate_H */ -#endif diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 2355543..90224c1 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -66,6 +66,7 @@ Features: dmalloc: @HAVE_DMALLOC@ Clear file buffers before write: @CLEARFILEBUF@ Using memory checker: @USINGMEMCHECKER@ +Memory allocation sanity checks: @MEMORYALLOCSANITYCHECK@ Function Stack Tracing: @CODESTACK@ Strict File Format Checks: @STRICT_FORMAT_CHECKS@ Optimization Instrumentation: @INSTRUMENT@ -- cgit v0.12 From 064b2f6dd85330a7e06f07c5fd2b8b26c29c8f28 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 4 Jan 2016 12:21:05 -0500 Subject: [svn-r28788] Added extern C block to H5Epubgen.h (via bin/make_err). Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- bin/make_err | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/make_err b/bin/make_err index 4b1f474..1b39d53fb 100755 --- a/bin/make_err +++ b/bin/make_err @@ -175,6 +175,12 @@ sub create_public ($) { print_warning(*HEADER); print_startprotect(*HEADER, $file); + # Begin extern C block + print HEADER "\n"; + print HEADER "#ifdef __cplusplus\n"; + print HEADER "extern \"C\" {\n"; + print HEADER "#endif\n"; + # Iterate over all the major errors print HEADER "\n/*********************/\n"; print HEADER "/* Major error codes */\n"; @@ -202,6 +208,12 @@ sub create_public ($) { } } + # End extern C block + print HEADER "\n"; + print HEADER "#ifdef __cplusplus\n"; + print HEADER "}\n"; + print HEADER "#endif\n"; + print_endprotect(*HEADER, $file); # Close header file -- cgit v0.12 From cdc21e0cb2d8a987790660b660a56744d54c5bed Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 15:56:08 -0500 Subject: [svn-r28790] Description: Correct non-portable 'SIZE_T_MAX' to 'SIZET_MAX'. Tested on: Linux/32 2.6.x (jam) w/default compilers (h5committest forthcoming) --- src/H5MM.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5MM.c b/src/H5MM.c index 05bfb9e..b6e77eb 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -157,7 +157,7 @@ H5MM__sanity_check_block(const H5MM_block_t *block) HDassert(block->size > 0); HDassert(block->in_use); /* Check for head & tail guards, if not head of linked list */ - if(block->size != SIZE_T_MAX) { + if(block->size != SIZET_MAX) { HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); } @@ -251,7 +251,7 @@ H5MM_malloc(size_t size) HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); H5MM_block_head_s.next = &H5MM_block_head_s; H5MM_block_head_s.prev = &H5MM_block_head_s; - H5MM_block_head_s.size = SIZE_T_MAX; + H5MM_block_head_s.size = SIZET_MAX; H5MM_block_head_s.in_use = TRUE; H5MM_init_s = TRUE; -- cgit v0.12 From 1cbc72e1ef6d5a0341713b4c7d8b113310a52551 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Mon, 4 Jan 2016 16:12:14 -0500 Subject: [svn-r28792] Added cleanup for new test files to tfile.c. Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- test/tfile.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/tfile.c b/test/tfile.c index c36045b..927ecab 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -3715,5 +3715,7 @@ cleanup_file(void) HDremove(FILE3); HDremove(FILE4); HDremove(FILE5); + HDremove(FILE6); + HDremove(FILE7); } -- cgit v0.12 From 3e0e79aa6eaa26106d22c0b860d523fe945cb0ac Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 21:46:26 -0500 Subject: [svn-r28795] Description: Clean up more memory allocation mis-matches. Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5E.c | 5 +++++ src/H5PL.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/H5E.c b/src/H5E.c index 4374f1d..efa83e4 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -1417,8 +1417,13 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, done: if(va_started) va_end(ap); +#ifdef H5_HAVE_VASPRINTF + if(tmp) + HDfree(tmp); +#else /* H5_HAVE_VASPRINTF */ if(tmp) H5MM_xfree(tmp); +#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_API(ret_value) } /* end H5Epush2() */ diff --git a/src/H5PL.c b/src/H5PL.c index 4c35c09..a196884 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -413,9 +413,9 @@ H5PL__init_path_table(void) */ origin_dl_path = HDgetenv("HDF5_PLUGIN_PATH"); if(NULL == origin_dl_path) - dl_path = HDstrdup(H5PL_DEFAULT_PATH); + dl_path = H5MM_strdup(H5PL_DEFAULT_PATH); else - dl_path = HDstrdup(origin_dl_path); + dl_path = H5MM_strdup(origin_dl_path); if(NULL == dl_path) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path") @@ -425,7 +425,7 @@ H5PL__init_path_table(void) /* Check for too many directories in path */ if(H5PL_num_paths_g == H5PL_MAX_PATH_NUM) HGOTO_ERROR(H5E_PLUGIN, H5E_NOSPACE, FAIL, "too many directories in path for table") - if(NULL == (H5PL_path_table_g[H5PL_num_paths_g] = HDstrdup(dir))) + if(NULL == (H5PL_path_table_g[H5PL_num_paths_g] = H5MM_strdup(dir))) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path") H5PL_num_paths_g++; dir = HDstrtok(NULL, H5PL_PATH_SEPARATOR); -- cgit v0.12 From 4c5bb2b8db3c16c9ec7a3f7f7eebf7fbeac8c48b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:28:43 -0500 Subject: [svn-r28797] Description: Clean up another round of memory allocation mis-matches. Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2.c | 8 ++++---- src/H5B2hdr.c | 12 ++++-------- src/H5B2int.c | 32 ++++++++++++-------------------- src/H5Dchunk.c | 4 ++-- src/H5Dmpio.c | 30 +++++++++++++++++------------- src/H5Dvirtual.c | 10 +++++----- src/H5FDlog.c | 14 ++++++-------- src/H5Ocopy.c | 4 ++-- src/H5Pdcpl.c | 4 ++-- 9 files changed, 54 insertions(+), 64 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index c105a93..62aded3 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -614,7 +614,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -622,7 +622,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1224,7 +1224,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1232,7 +1232,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 25ac141..036e81a 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -619,14 +619,10 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) } /* end if */ /* Release the min & max record info, if set */ - if(hdr->min_native_rec) { - HDfree(hdr->min_native_rec); - hdr->min_native_rec = NULL; - } /* end if */ - if(hdr->max_native_rec) { - HDfree(hdr->max_native_rec); - hdr->max_native_rec = NULL; - } /* end if */ + if(hdr->min_native_rec) + hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + if(hdr->max_native_rec) + hdr->max_native_rec = H5MM_free(hdr->max_native_rec); /* Free B-tree header info */ hdr = H5FL_FREE(H5B2_hdr_t, hdr); diff --git a/src/H5B2int.c b/src/H5B2int.c index 363d903..105dad4 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1640,7 +1640,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1648,7 +1648,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1929,7 +1929,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1937,7 +1937,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)HDmalloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -2552,18 +2552,14 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr /* (Don't use 'else' for the idx check, to allow for root leaf node) */ if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) { - HDfree(hdr->min_native_rec); - hdr->min_native_rec = NULL; - } /* end if */ + if(hdr->min_native_rec) + hdr->min_native_rec = H5MM_free(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) { - HDfree(hdr->max_native_rec); - hdr->max_native_rec = NULL; - } /* end if */ + if(hdr->max_native_rec) + hdr->max_native_rec = H5MM_free(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ @@ -2867,18 +2863,14 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, /* (Don't use 'else' for the idx check, to allow for root leaf node) */ if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->min_native_rec) { - HDfree(hdr->min_native_rec); - hdr->min_native_rec = NULL; - } /* end if */ + if(hdr->min_native_rec) + hdr->min_native_rec = H5MM_free(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { - if(hdr->max_native_rec) { - HDfree(hdr->max_native_rec); - hdr->max_native_rec = NULL; - } /* end if */ + if(hdr->max_native_rec) + hdr->max_native_rec = H5MM_free(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 0c4cba1..b0abdf1 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -3746,7 +3746,7 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, write collectively at the end */ /* allocate/resize address array if no more space left */ if(0 == chunk_info.num_io % 1024) - if(NULL == (chunk_info.addr = (haddr_t *)HDrealloc(chunk_info.addr, (chunk_info.num_io + 1024) * sizeof(haddr_t)))) + if(NULL == (chunk_info.addr = (haddr_t *)H5MM_realloc(chunk_info.addr, (chunk_info.num_io + 1024) * sizeof(haddr_t)))) HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "memory allocation failed for chunk addresses") /* Store the chunk's address for later */ @@ -3813,7 +3813,7 @@ done: #ifdef H5_HAVE_PARALLEL if(using_mpi && chunk_info.addr) - HDfree(chunk_info.addr); + H5MM_free(chunk_info.addr); #endif FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL) diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index a5f34d1..0ba340a 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -1680,7 +1680,6 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, MPI_Comm comm; int ic, root; int mpi_code; - hbool_t mem_cleanup = FALSE; #ifdef H5_HAVE_INSTRUMENTED_LIBRARY int new_value; htri_t check_prop; @@ -1715,12 +1714,14 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, threshold_nproc_per_chunk = mpi_size * percent_nproc_per_chunk/100; /* Allocate memory */ - io_mode_info = (uint8_t *)H5MM_calloc(total_chunks); - mergebuf = H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks); + if(NULL == (io_mode_info = (uint8_t *)H5MM_calloc(total_chunks))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate I/O mode info buffer") + if(NULL == (mergebuf = H5MM_malloc((sizeof(haddr_t) + 1) * total_chunks))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate mergebuf buffer") tempbuf = mergebuf + total_chunks; if(mpi_rank == root) - recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * mpi_size); - mem_cleanup = TRUE; + if(NULL == (recv_io_mode_info = (uint8_t *)H5MM_malloc(total_chunks * mpi_size))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate recv I/O mode info buffer") /* Obtain the regularity and selection information for all chunks in this process. */ chunk_node = H5SL_first(fm->sel_chunks); @@ -1742,11 +1743,12 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, /* pre-computing: calculate number of processes and regularity of the selection occupied in each chunk */ - nproc_per_chunk = (int*)H5MM_calloc(total_chunks * sizeof(int)); + if(NULL == (nproc_per_chunk = (int*)H5MM_calloc(total_chunks * sizeof(int)))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "couldn't allocate nproc_per_chunk buffer") /* calculating the chunk address */ if(H5D__chunk_addrmap(io_info, chunk_addr) < 0) { - HDfree(nproc_per_chunk); + H5MM_free(nproc_per_chunk); HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk address") } /* end if */ @@ -1774,7 +1776,7 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, HDmemcpy(mergebuf, assign_io_mode, total_chunks); HDmemcpy(tempbuf, chunk_addr, sizeof(haddr_t) * total_chunks); - HDfree(nproc_per_chunk); + H5MM_free(nproc_per_chunk); } /* end if */ /* Broadcasting the MPI_IO option info. and chunk address info. */ @@ -1824,11 +1826,13 @@ H5D__obtain_mpio_mode(H5D_io_info_t* io_info, H5D_chunk_map_t *fm, #endif done: - if(mem_cleanup) { - HDfree(io_mode_info); - HDfree(mergebuf); - if(mpi_rank == root) - HDfree(recv_io_mode_info); + if(io_mode_info) + H5MM_free(io_mode_info); + if(mergebuf) + H5MM_free(mergebuf); + if(recv_io_mode_info) { + HDassert(mpi_rank == root); + H5MM_free(recv_io_mode_info); } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 7c5186d..bf754cb 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -446,10 +446,10 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) /* Copy original source names */ if(NULL == (layout->storage.u.virt.list[i].source_file_name - = HDstrdup(orig_list[i].source_file_name))) + = H5MM_strdup(orig_list[i].source_file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") if(NULL == (layout->storage.u.virt.list[i].source_dset_name - = HDstrdup(orig_list[i].source_dset_name))) + = H5MM_strdup(orig_list[i].source_dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") /* Copy source selection */ @@ -488,7 +488,7 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) } /* end if */ else if(NULL == (layout->storage.u.virt.list[i].source_dset.file_name - = HDstrdup(orig_list[i].source_dset.file_name))) + = H5MM_strdup(orig_list[i].source_dset.file_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source file name") } /* end if */ if(orig_list[i].source_dset.dset_name) { @@ -504,7 +504,7 @@ H5D__virtual_copy_layout(H5O_layout_t *layout) } /* end if */ else if(NULL == (layout->storage.u.virt.list[i].source_dset.dset_name - = HDstrdup(orig_list[i].source_dset.dset_name))) + = H5MM_strdup(orig_list[i].source_dset.dset_name))) HGOTO_ERROR(H5E_DATASET, H5E_RESOURCE, FAIL, "unable to duplicate source dataset name") } /* end if */ @@ -1124,7 +1124,7 @@ H5D__virtual_copy_parsed_name(H5O_storage_virtual_name_seg_t **dst, /* Duplicate name segment */ if(p_src->name_segment) { - if(NULL == ((*p_dst)->name_segment = HDstrdup(p_src->name_segment))) + if(NULL == ((*p_dst)->name_segment = H5MM_strdup(p_src->name_segment))) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to duplicate name segment") } /* end if */ diff --git a/src/H5FDlog.c b/src/H5FDlog.c index a8228e0..435ee70 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -406,7 +406,7 @@ H5FD_log_fapl_copy(const void *_old_fa) /* Deep copy the log file name */ if(old_fa->logfile != NULL) - if(NULL == (new_fa->logfile = H5MM_xstrdup(old_fa->logfile))) + if(NULL == (new_fa->logfile = H5MM_strdup(old_fa->logfile))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate log file name") /* Set return value */ @@ -416,7 +416,7 @@ done: if(NULL == ret_value) if(new_fa) { if(new_fa->logfile) - H5MM_free(new_fa->logfile); + new_fa->logfile = H5MM_free(new_fa->logfile); H5MM_free(new_fa); } /* end if */ @@ -445,7 +445,7 @@ H5FD_log_fapl_free(void *_fa) /* Free the fapl information */ if(fa->logfile) - H5MM_xfree(fa->logfile); + fa->logfile = H5MM_free(fa->logfile); H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) @@ -594,7 +594,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) /* Get the flags for logging */ file->fa.flags = fa->flags; if(fa->logfile) - file->fa.logfile = HDstrdup(fa->logfile); + file->fa.logfile = H5MM_strdup(fa->logfile); else file->fa.logfile = NULL; file->fa.buf_size = fa->buf_size; @@ -798,10 +798,8 @@ H5FD_log_close(H5FD_t *_file) HDfclose(file->logfp); } /* end if */ - if(file->fa.logfile) { - HDfree(file->fa.logfile); - file->fa.logfile = NULL; - } + if(file->fa.logfile) + file->fa.logfile = H5MM_free(file->fa.logfile); /* Release the file info */ file = H5FL_FREE(H5FD_log_t, file); diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 6f42a88..70dc560 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -463,7 +463,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, /* Allocate memory for "deleted" array. This array marks the message in * the source that shouldn't be copied to the destination. */ - if(NULL == (deleted = (hbool_t *)HDmalloc(sizeof(hbool_t) * oh_src->nmesgs))) + if(NULL == (deleted = (hbool_t *)H5MM_malloc(sizeof(hbool_t) * oh_src->nmesgs))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") HDmemset(deleted, FALSE, sizeof(hbool_t) * oh_src->nmesgs); @@ -870,7 +870,7 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out*/, done: /* Free deleted array */ if(deleted) - HDfree(deleted); + H5MM_free(deleted); /* Release pointer to source object header and its derived objects */ if(oh_src && H5O_unprotect(oloc_src, dxpl_id, oh_src, H5AC__NO_FLAGS_SET) < 0) diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 03d987f..971394c 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -2227,9 +2227,9 @@ H5Pset_virtual(hid_t dcpl_id, hid_t vspace_id, const char *src_file_name, HDmemset(ent, 0, sizeof(H5O_storage_virtual_ent_t)); /* Clear before starting to set up */ if(NULL == (ent->source_dset.virtual_select = H5S_copy(vspace, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy virtual selection") - if(NULL == (ent->source_file_name = HDstrdup(src_file_name))) + if(NULL == (ent->source_file_name = H5MM_xstrdup(src_file_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") - if(NULL == (ent->source_dset_name = HDstrdup(src_dset_name))) + if(NULL == (ent->source_dset_name = H5MM_xstrdup(src_dset_name))) HGOTO_ERROR(H5E_PLIST, H5E_RESOURCE, FAIL, "can't duplicate source file name") if(NULL == (ent->source_select = H5S_copy(src_space, FALSE, TRUE))) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "unable to copy source selection") -- cgit v0.12 From 4b90bb3317c39b347fd67dc753d70fe6808e4f2b Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:37:06 -0500 Subject: [svn-r28798] Description: Add missing H5MMprivate.h header file Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2.c | 1 + src/H5B2hdr.c | 3 ++- src/H5B2int.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index 62aded3..3a712da 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -42,6 +42,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5B2pkg.h" /* v2 B-trees */ #include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ /****************/ diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index 036e81a..b6e0b26 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -38,7 +38,8 @@ #include "H5B2pkg.h" /* v2 B-trees */ #include "H5Eprivate.h" /* Error handling */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ diff --git a/src/H5B2int.c b/src/H5B2int.c index 105dad4..fe82604 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -38,7 +38,8 @@ #include "H5B2pkg.h" /* v2 B-trees */ #include "H5Eprivate.h" /* Error handling */ #include "H5MFprivate.h" /* File memory management */ -#include "H5VMprivate.h" /* Vectors and arrays */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VMprivate.h" /* Vectors and arrays */ /****************/ /* Local Macros */ -- cgit v0.12 From 63102599575c860b0f5b839e0e3ab8e5944fd1fc Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:46:10 -0500 Subject: [svn-r28800] Description: Correct H5MM_free => H5MM_xfree Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2hdr.c | 4 ++-- src/H5B2int.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/H5B2hdr.c b/src/H5B2hdr.c index b6e0b26..ab424b7 100644 --- a/src/H5B2hdr.c +++ b/src/H5B2hdr.c @@ -621,9 +621,9 @@ H5B2__hdr_free(H5B2_hdr_t *hdr) /* Release the min & max record info, if set */ if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_free(hdr->max_native_rec); + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); /* Free B-tree header info */ hdr = H5FL_FREE(H5B2_hdr_t, hdr); diff --git a/src/H5B2int.c b/src/H5B2int.c index fe82604..f3bae69 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -2554,13 +2554,13 @@ H5B2__remove_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_free(hdr->max_native_rec); + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ @@ -2865,13 +2865,13 @@ H5B2__remove_leaf_by_idx(H5B2_hdr_t *hdr, hid_t dxpl_id, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec) - hdr->min_native_rec = H5MM_free(hdr->min_native_rec); + hdr->min_native_rec = H5MM_xfree(hdr->min_native_rec); } /* end if */ } /* end if */ if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec) - hdr->max_native_rec = H5MM_free(hdr->max_native_rec); + hdr->max_native_rec = H5MM_xfree(hdr->max_native_rec); } /* end if */ } /* end if */ } /* end if */ -- cgit v0.12 From fb1525c2b2bb606a39fa6b2d2a50cfa4d3fee640 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Mon, 4 Jan 2016 22:47:55 -0500 Subject: [svn-r28802] Description: Correct another H5MM_free => H5MM_xfree Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5FDlog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 435ee70..4bb72ce 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -416,7 +416,7 @@ done: if(NULL == ret_value) if(new_fa) { if(new_fa->logfile) - new_fa->logfile = H5MM_free(new_fa->logfile); + new_fa->logfile = H5MM_xfree(new_fa->logfile); H5MM_free(new_fa); } /* end if */ @@ -445,7 +445,7 @@ H5FD_log_fapl_free(void *_fa) /* Free the fapl information */ if(fa->logfile) - fa->logfile = H5MM_free(fa->logfile); + fa->logfile = H5MM_xfree(fa->logfile); H5MM_xfree(fa); FUNC_LEAVE_NOAPI(SUCCEED) @@ -799,7 +799,7 @@ H5FD_log_close(H5FD_t *_file) } /* end if */ if(file->fa.logfile) - file->fa.logfile = H5MM_free(file->fa.logfile); + file->fa.logfile = H5MM_xfree(file->fa.logfile); /* Release the file info */ file = H5FL_FREE(H5FD_log_t, file); -- cgit v0.12 From 48f7ad2df147d92851c6246155712f430a9f39f0 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 10:46:02 -0500 Subject: [svn-r28811] Description: Switch v2 B-tree min & max records to be void*'s to be cleaner and generate less warnings. Tested on: Linux/32 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5B2.c | 8 ++++---- src/H5B2int.c | 8 ++++---- src/H5B2pkg.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/H5B2.c b/src/H5B2.c index 3a712da..a1e9d37 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -615,7 +615,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -623,7 +623,7 @@ H5B2_find(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_found_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1225,7 +1225,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1233,7 +1233,7 @@ H5B2_modify(H5B2_t *bt2, hid_t dxpl_id, void *udata, H5B2_modify_t op, if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ diff --git a/src/H5B2int.c b/src/H5B2int.c index f3bae69..a69774a 100644 --- a/src/H5B2int.c +++ b/src/H5B2int.c @@ -1641,7 +1641,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1649,7 +1649,7 @@ H5B2__insert_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1930,7 +1930,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == 0) { if(H5B2_POS_LEFT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->min_native_rec == NULL) - if(NULL == (hdr->min_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->min_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree min record info") HDmemcpy(hdr->min_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ @@ -1938,7 +1938,7 @@ H5B2__update_leaf(H5B2_hdr_t *hdr, hid_t dxpl_id, H5B2_node_ptr_t *curr_node_ptr if(idx == (unsigned)(leaf->nrec - 1)) { if(H5B2_POS_RIGHT == curr_pos || H5B2_POS_ROOT == curr_pos) { if(hdr->max_native_rec == NULL) - if(NULL == (hdr->max_native_rec = (uint8_t *)H5MM_malloc(hdr->cls->nrec_size))) + if(NULL == (hdr->max_native_rec = H5MM_malloc(hdr->cls->nrec_size))) HGOTO_ERROR(H5E_BTREE, H5E_CANTALLOC, FAIL, "memory allocation failed for v2 B-tree max record info") HDmemcpy(hdr->max_native_rec, H5B2_LEAF_NREC(leaf, hdr, idx), hdr->cls->nrec_size); } /* end if */ diff --git a/src/H5B2pkg.h b/src/H5B2pkg.h index d6b6c04..2b2c145 100644 --- a/src/H5B2pkg.h +++ b/src/H5B2pkg.h @@ -182,8 +182,8 @@ typedef struct H5B2_hdr_t { uint8_t *page; /* Common disk page for I/O */ size_t *nat_off; /* Array of offsets of native records */ H5B2_node_info_t *node_info; /* Table of node info structs for current depth of B-tree */ - uint8_t *min_native_rec; /* Pointer to minimum native record */ - uint8_t *max_native_rec; /* Pointer to maximum native record */ + void *min_native_rec; /* Pointer to minimum native record */ + void *max_native_rec; /* Pointer to maximum native record */ /* Client information (not stored) */ const H5B2_class_t *cls; /* Class of B-tree client */ -- cgit v0.12 From 4bf63f78e71aed68ba946dbfda545d657a9a94b5 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 12:04:15 -0500 Subject: [svn-r28815] Description: Add internal routine to sanity check all blocks allocated through H5MM interface. Tested on: Linux/32 2.6.x (jam) w/serial Linux/64 2.6.x (mayll) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- src/H5MM.c | 25 +++++++++++++++++++++++++ src/H5MMprivate.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/H5MM.c b/src/H5MM.c index b6e77eb..fd9a4a9 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -187,6 +187,31 @@ H5MM__sanity_check(void *mem) /*------------------------------------------------------------------------- + * Function: H5MM_sanity_check_all + * + * Purpose: Sanity check all current memory allocations. + * + * Return: N/A (void) + * + * Programmer: Quincey Koziol + * Jan 5 2016 + * + *------------------------------------------------------------------------- + */ +void +H5MM_sanity_check_all(void) +{ + H5MM_block_t *curr; + + curr = H5MM_block_head_s.next; + while(curr != &H5MM_block_head_s) { + H5MM__sanity_check_block(curr); + curr = curr->next; + } /* end while */ +} /* end H5MM_sanity_check_all() */ + + +/*------------------------------------------------------------------------- * Function: H5MM_final_sanity_check * * Purpose: Final sanity checks on memory allocation. diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index c494a60..14bd28d 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -48,6 +48,7 @@ H5_DLL char *H5MM_xstrdup(const char *s); H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); #if defined H5_MEMORY_ALLOC_SANITY_CHECK +H5_DLL void H5MM_sanity_check_all(void); H5_DLL void H5MM_final_sanity_check(void); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ -- cgit v0.12 From 06da6031a596c2d19dcc4a253253b6ea33378728 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 12:50:08 -0500 Subject: [svn-r28819] Description: Align internal memory sanity checking buffer, to avoid problems when optimization is enabled. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel Linux/32 2.6.x (jam) w/serial --- src/H5MM.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/H5MM.c b/src/H5MM.c index fd9a4a9..b830d21 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -60,9 +60,14 @@ typedef struct H5MM_block_t { unsigned char sig[H5MM_SIG_SIZE]; /* Signature for the block, to indicate it was allocated with H5MM* interface */ struct H5MM_block_t *next; /* Pointer to next block in the list of allocated blocks */ struct H5MM_block_t *prev; /* Pointer to previous block in the list of allocated blocks */ - size_t size; - hbool_t in_use; - unsigned char b[]; + union { + struct { + size_t size; /* Size of allocated block */ + hbool_t in_use; /* Whether the block is in use or is free */ + } info; + double _align; /* Align following buffer (b) to double boundary (unused) */ + } u; + unsigned char b[]; /* Buffer for caller (includes header and footer) */ } H5MM_block_t; #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ @@ -154,12 +159,12 @@ H5MM__is_our_block(void *mem) static void H5MM__sanity_check_block(const H5MM_block_t *block) { - HDassert(block->size > 0); - HDassert(block->in_use); + HDassert(block->u.info.size > 0); + HDassert(block->u.info.in_use); /* Check for head & tail guards, if not head of linked list */ - if(block->size != SIZET_MAX) { + if(block->u.info.size != SIZET_MAX) { HDassert(0 == HDmemcmp(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE)); - HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); + HDassert(0 == HDmemcmp(block->b + H5MM_HEAD_GUARD_SIZE + block->u.info.size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE)); } } @@ -271,13 +276,16 @@ H5MM_malloc(size_t size) FUNC_ENTER_NOAPI_NOINIT_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK + /* Make certain that the buffer in the struct is properly aligned */ + HDcompile_assert(offsetof(H5MM_block_t, b) % sizeof(double) == 0); + /* Initialize block list head singleton */ if(!H5MM_init_s) { HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); H5MM_block_head_s.next = &H5MM_block_head_s; H5MM_block_head_s.prev = &H5MM_block_head_s; - H5MM_block_head_s.size = SIZET_MAX; - H5MM_block_head_s.in_use = TRUE; + H5MM_block_head_s.u.info.size = SIZET_MAX; + H5MM_block_head_s.u.info.in_use = TRUE; H5MM_init_s = TRUE; } /* end if */ @@ -295,8 +303,8 @@ H5MM_malloc(size_t size) H5MM_block_head_s.next = block; block->next->prev = block; block->prev = &H5MM_block_head_s; - block->size = size; - block->in_use = TRUE; + block->u.info.size = size; + block->u.info.in_use = TRUE; HDmemcpy(block->b, H5MM_block_head_guard_s, H5MM_HEAD_GUARD_SIZE); HDmemcpy(block->b + H5MM_HEAD_GUARD_SIZE + size, H5MM_block_tail_guard_s, H5MM_TAIL_GUARD_SIZE); @@ -414,7 +422,7 @@ H5MM_realloc(void *mem, size_t size) if(mem) { if(H5MM__is_our_block(mem)) { H5MM_block_t *block = H5MM_BLOCK_FROM_BUF(mem); - size_t old_size = block->size; + size_t old_size = block->u.info.size; H5MM__sanity_check(mem); @@ -545,7 +553,7 @@ H5MM_xfree(void *mem) H5MM__sanity_check_block(block->prev); /* Update statistics */ - H5MM_curr_alloc_bytes_s -= block->size; + H5MM_curr_alloc_bytes_s -= block->u.info.size; H5MM_curr_alloc_blocks_count_s--; /* Reset block info */ @@ -554,7 +562,7 @@ H5MM_xfree(void *mem) block->prev->next = block->next; block->next = NULL; block->prev = NULL; - block->in_use = FALSE; + block->u.info.in_use = FALSE; /* Free the block (finally!) */ HDfree(block); -- cgit v0.12 From b834ac36535d72dd5013514bad5448bf0baa465e Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 6 Jan 2016 13:33:23 -0500 Subject: [svn-r28821] Merge of r28816 from revise_chunks (tarray.c cleanup). Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 serial only --- test/tarray.c | 168 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/test/tarray.c b/test/tarray.c index 9c79f41..28798c2 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -178,7 +178,7 @@ test_array_funcs(void) { hid_t type; /* Datatype ID */ hsize_t tdims1[] = {ARRAY1_DIM1}; - int size; + size_t size; H5T_pad_t inpad; H5T_norm_t norm; H5T_cset_t cset; @@ -190,13 +190,13 @@ test_array_funcs(void) CHECK(type, FAIL, "H5Tarray_create2"); size=H5Tget_precision(type); - CHECK(size, FAIL, "H5Tget_precision"); + CHECK(size, 0, "H5Tget_precision"); size=H5Tget_size(type); - CHECK(size, FAIL, "H5Tget_size"); + CHECK(size, 0, "H5Tget_size"); size=H5Tget_ebias(type); - CHECK(size, FAIL, "H5Tget_ebias"); + CHECK(size, 0, "H5Tget_ebias"); ret=H5Tset_pad(type, H5T_PAD_ZERO, H5T_PAD_ONE); CHECK(ret, FAIL, "H5Tset_pad"); @@ -541,7 +541,7 @@ test_array_compound_atomic(void) for(i = 0; i < SPACE1_DIM1; i++) for(j = 0; j < ARRAY1_DIM1; j++) { wdata[i][j].i = i * 10 + j; - wdata[i][j].f = (float)(i * 2.5F + j); + wdata[i][j].f = (float)i * 2.5F + (float)j; } /* end for */ /* Create file */ @@ -745,7 +745,7 @@ test_array_compound_array(void) for(j=0; jnsubfields = 3; /* Initialize the offsets */ /* ----------------------- */ - dtsinfo.offset[0] = HOFFSET(CmpField, a); - dtsinfo.offset[1] = HOFFSET(CmpField, b); - dtsinfo.offset[2] = HOFFSET(CmpField, c); + dtsinfo->offset[0] = HOFFSET(CmpField, a); + dtsinfo->offset[1] = HOFFSET(CmpField, b); + dtsinfo->offset[2] = HOFFSET(CmpField, c); /* Initialize the data type IDs */ /* ---------------------------- */ - dtsinfo.datatype[0] = H5T_NATIVE_INT; - dtsinfo.datatype[1] = H5T_NATIVE_FLOAT; - dtsinfo.datatype[2] = H5T_NATIVE_DOUBLE; + dtsinfo->datatype[0] = H5T_NATIVE_INT; + dtsinfo->datatype[1] = H5T_NATIVE_FLOAT; + dtsinfo->datatype[2] = H5T_NATIVE_DOUBLE; /* Initialize the names of data members */ /* ------------------------------------ */ - for (i = 0; i < dtsinfo.nsubfields; i++) - dtsinfo.name[i] = (char *)HDcalloc((size_t)20, sizeof(char)); + for (i = 0; i < dtsinfo->nsubfields; i++) + dtsinfo->name[i] = (char *)HDcalloc((size_t)20, sizeof(char)); - strcpy(dtsinfo.name[0], "One"); - strcpy(dtsinfo.name[1], "Two"); - strcpy(dtsinfo.name[2], "Three"); + strcpy(dtsinfo->name[0], "One"); + strcpy(dtsinfo->name[1], "Two"); + strcpy(dtsinfo->name[2], "Three"); /* Create file */ @@ -1585,17 +1584,16 @@ test_array_bkg(void) /* Add members to the compound data type */ /* -------------------------------------- */ - for ( i = 0; i < dtsinfo.nsubfields; i++) - { - array_dt = H5Tarray_create2(dtsinfo.datatype[i], ndims[i], dima); + for ( i = 0; i < dtsinfo->nsubfields; i++) { + array_dt = H5Tarray_create2(dtsinfo->datatype[i], ndims[i], dima); CHECK(array_dt, FAIL, "H5Tarray_create2"); - status = H5Tinsert (type, dtsinfo.name[i], dtsinfo.offset[i], array_dt); + status = H5Tinsert (type, dtsinfo->name[i], dtsinfo->offset[i], array_dt); CHECK(status, FAIL, "H5Tinsert"); status = H5Tclose(array_dt); CHECK(status, FAIL, "H5Tclose"); - } + } /* end for */ /* Create the dataset */ /* ------------------ */ @@ -1617,23 +1615,23 @@ test_array_bkg(void) if(cf[i].a[j]!=cfr[i].a[j]) { TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); continue; - } + } /* end if */ if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); continue; - } + } /* end if */ if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); continue; - } - } - } + } /* end if */ + } /* end for */ + } /* end for */ /* Release memory resources */ /* ------------------------ */ - for (i = 0; i < dtsinfo.nsubfields; i++) - HDfree(dtsinfo.name[i]); + for (i = 0; i < dtsinfo->nsubfields; i++) + HDfree(dtsinfo->name[i]); /* Release IDs */ @@ -1651,9 +1649,9 @@ test_array_bkg(void) CHECK(status, FAIL, "H5Fclose"); -/******************************/ -/* Reopen the file and update */ -/******************************/ + /******************************/ + /* Reopen the file and update */ + /******************************/ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -1674,7 +1672,7 @@ test_array_bkg(void) /* -------------------------------- */ for (i=0; i< LENGTH; i++) for (j = 0; j < ALEN; j++) - cf[i].b[j]=fld[i].b[j] = 1.313F; + cf[i].b[j] = fld[i].b[j] = 1.313F; status = H5Dwrite (dataset, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, fld); CHECK(status, FAIL, "H5Dwrite"); @@ -1688,7 +1686,7 @@ test_array_bkg(void) if(!H5_FLT_ABS_EQUAL(fld[i].b[j],fldr[i].b[j])) { TestErrPrintf("Field data doesn't match, fld[%d].b[%d]=%f, fldr[%d].b[%d]=%f\n",(int)i,(int)j,(double)fld[i].b[j],(int)i,(int)j,(double)fldr[i].b[j]); continue; - } + } /* end if */ status = H5Tclose (type); CHECK(status, FAIL, "H5Tclose"); @@ -1710,17 +1708,17 @@ test_array_bkg(void) if(cf[i].a[j]!=cfr[i].a[j]) { TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); continue; - } + } /* end if */ if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); continue; - } + } /* end if */ if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); continue; - } - } - } + } /* end if */ + } /* end for */ + } /* end for */ status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); @@ -1731,9 +1729,9 @@ test_array_bkg(void) status = H5Fclose(fid); CHECK(status, FAIL, "H5Fclose"); -/****************************************************/ -/* Reopen the file and print out all the data again */ -/****************************************************/ + /****************************************************/ + /* Reopen the file and print out all the data again */ + /****************************************************/ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -1759,17 +1757,17 @@ test_array_bkg(void) if(cf[i].a[j]!=cfr[i].a[j]) { TestErrPrintf("Field a data doesn't match, cf[%d].a[%d]=%d, cfr[%d].a[%d]=%d\n",(int)i,(int)j,(int)cf[i].a[j],(int)i,(int)j,(int)cfr[i].a[j]); continue; - } + } /* end if */ if(!H5_FLT_ABS_EQUAL(cf[i].b[j],cfr[i].b[j])) { TestErrPrintf("Field b data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].b[j],(int)i,(int)j,(double)cfr[i].b[j]); continue; - } + } /* end if */ if(!H5_DBL_ABS_EQUAL(cf[i].c[j],cfr[i].c[j])) { TestErrPrintf("Field c data doesn't match, cf[%d].b[%d]=%f, cfr[%d].b[%d]=%f\n",(int)i,(int)j,(double)cf[i].c[j],(int)i,(int)j,(double)cfr[i].c[j]); continue; - } - } - } + } /* end if */ + } /* end for */ + } /* end for */ status = H5Dclose(dataset); CHECK(status, FAIL, "H5Dclose"); @@ -1779,6 +1777,8 @@ test_array_bkg(void) status = H5Fclose(fid); CHECK(status, FAIL, "H5Fclose"); + + HDfree(dtsinfo); } /* end test_array_bkg() */ /**************************************************************** -- cgit v0.12 From 971af2d7333584e021564f4f50f3afcfba57716f Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 14:10:21 -0500 Subject: [svn-r28824] Description: Reduce asserts on buffer alignment. Tested on: Linux/32 & Linux/64 2.6.x (jam & myall) w/serial --- src/H5MM.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/H5MM.c b/src/H5MM.c index b830d21..09e6461 100644 --- a/src/H5MM.c +++ b/src/H5MM.c @@ -276,9 +276,6 @@ H5MM_malloc(size_t size) FUNC_ENTER_NOAPI_NOINIT_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK - /* Make certain that the buffer in the struct is properly aligned */ - HDcompile_assert(offsetof(H5MM_block_t, b) % sizeof(double) == 0); - /* Initialize block list head singleton */ if(!H5MM_init_s) { HDmemcpy(H5MM_block_head_s.sig, H5MM_block_signature_s, H5MM_SIG_SIZE); -- cgit v0.12 From e9a63d30df37fba8b879f18f39cf96b3d46bd615 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 15:45:25 -0500 Subject: [svn-r28828] Description: Switch filter plugin to use H5allocate_memory and H5free_memory instead of malloc and free. Tested on: Linux/32 2.6.x (jam) w/serial Linux/64 2.6.x (jam) w/serial MacOSX/64 10.11.2 (amazon) w/serial & parallel --- test/dynlib3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dynlib3.c b/test/dynlib3.c index b3a02ed..e509a52 100644 --- a/test/dynlib3.c +++ b/test/dynlib3.c @@ -81,7 +81,7 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, void *outbuf = NULL; /* Pointer to new buffer */ unsigned char *dst; /* Temporary pointer to destination buffer */ - dst = (unsigned char *)(outbuf = malloc(nbytes + SUFFIX_LEN)); + dst = (unsigned char *)(outbuf = H5allocate_memory(nbytes + SUFFIX_LEN, 0)); /* Copy raw data */ memcpy((void*)dst, (void*)(*buf), nbytes); @@ -91,7 +91,7 @@ H5Z_filter_dynlib3(unsigned int flags, size_t cd_nelmts, memcpy(dst, (void*)GROUP_SUFFIX, SUFFIX_LEN); /* Free input buffer */ - free(*buf); + H5free_memory(*buf); /* Set return values */ *buf_size = nbytes + SUFFIX_LEN; -- cgit v0.12 From dc63336a4a863f1222f698d882e0862b72aa93fc Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 6 Jan 2016 17:05:32 -0500 Subject: [svn-r28832] Description: Reset driver info message when superblock load fails. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel Linux/32 2.6.x (jam) w/serial Linux/64 2.6.x (mayll) w/serial --- src/H5Fsuper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index a0f9536..332dfa6 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -510,8 +510,10 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver info message not present") /* Validate and decode driver information */ - if(H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) + if(H5FD_sb_load(f->shared->lf, drvinfo.name, drvinfo.buf) < 0) { + H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "unable to decode driver information") + } /* end if */ /* Reset driver info message */ H5O_msg_reset(H5O_DRVINFO_ID, &drvinfo); -- cgit v0.12 From ed380746fe131bf1aeb3d8135c5ff31705312cb0 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 7 Jan 2016 12:45:11 -0500 Subject: [svn-r28837] Merged r28836 from revise_chunks (tarray.c fix). Tested on ostrich w/ gcc --- test/tarray.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/tarray.c b/test/tarray.c index 28798c2..cb5fef9 100644 --- a/test/tarray.c +++ b/test/tarray.c @@ -1031,8 +1031,8 @@ test_array_vlen_atomic(void) H5T_class_t mclass; /* Datatype class for VL */ hid_t xfer_pid; /* Dataset transfer property list ID */ hsize_t size; /* Number of bytes which will be used */ - int mem_used=0; /* Memory used during allocation */ - int i,j,k; /* counting variables */ + size_t mem_used=0; /* Memory used during allocation */ + int i,j,k; /* counting variables */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -1242,8 +1242,8 @@ test_array_vlen_array(void) H5T_class_t mclass; /* Datatype class for VL */ hid_t xfer_pid; /* Dataset transfer property list ID */ hsize_t size; /* Number of bytes which will be used */ - int mem_used=0; /* Memory used during allocation */ - int i,j,k,l; /* Index variables */ + size_t mem_used=0; /* Memory used during allocation */ + int i,j,k,l; /* Index variables */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ -- cgit v0.12 From 74fbe507ae0e69d689409560c37974d92d28ad10 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 7 Jan 2016 15:27:37 -0500 Subject: [svn-r28841] indentations were messed up by some previous commit. Restored them to more readable spacing. No code change. Test: visual inspection. --- bin/cmakehdf5 | 222 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 111 insertions(+), 111 deletions(-) diff --git a/bin/cmakehdf5 b/bin/cmakehdf5 index 48869cf..6e22e17 100755 --- a/bin/cmakehdf5 +++ b/bin/cmakehdf5 @@ -124,12 +124,12 @@ STEP() echo "$banner" with output saved in $logfile (TIMESTAMP; nerror=0 ; - echo "eval $command" - eval $command || nerror=1 ; - TIMESTAMP; exit $nerror) < /dev/null > "$logfile" 2>&1 + echo "eval $command" + eval $command || nerror=1 ; + TIMESTAMP; exit $nerror) < /dev/null > "$logfile" 2>&1 if [ $? -ne 0 ]; then - echo "error in '$banner'. $progname aborted." - exit 1 + echo "error in '$banner'. $progname aborted." + exit 1 fi } @@ -143,26 +143,26 @@ INSTALL_HDF5() { myos="`uname -s`" case "$myos" in - Linux) - install_file=./HDF5-${version}-Linux.sh - $install_file --skip-license $* - ;; - Darwin) # Mac OSX DMG file - install_file=HDF5-${version}-Darwin.dmg - test -d hdf5 || mkdir hdf5 - basename=`basename $install_file .dmg` - # mount the DMG file as /Volumes/$basename - # echo 'Y' as yes for license. - echo Y | hdiutil mount $install_file - # copy the contents to the install location - cp -R "/Volumes/$basename/HDF_Group" hdf5 - # unmount the DMG file - hdiutil unmount /Volumes/$basename - ;; - *) # unknown/unsupported OS. - echo "INSTALL_HDF5: Error--unknown/unsupported OS($myos)" - return 1 - ;; + Linux) + install_file=./HDF5-${version}-Linux.sh + $install_file --skip-license $* + ;; + Darwin) # Mac OSX DMG file + install_file=HDF5-${version}-Darwin.dmg + test -d hdf5 || mkdir hdf5 + basename=`basename $install_file .dmg` + # mount the DMG file as /Volumes/$basename + # echo 'Y' as yes for license. + echo Y | hdiutil mount $install_file + # copy the contents to the install location + cp -R "/Volumes/$basename/HDF_Group" hdf5 + # unmount the DMG file + hdiutil unmount /Volumes/$basename + ;; + *) # unknown/unsupported OS. + echo "INSTALL_HDF5: Error--unknown/unsupported OS($myos)" + return 1 + ;; esac } @@ -172,14 +172,14 @@ INSTALL_HDF5() DUMP_LOGFILE() { for x in $*; do - if [ -f $x ]; then - echo "==================================" - echo "Dumping $x" - echo "==================================" - cat $x - echo "==== END $x =====" - echo - fi + if [ -f $x ]; then + echo "==================================" + echo "Dumping $x" + echo "==================================" + cat $x + echo "==== END $x =====" + echo + fi done } @@ -207,84 +207,84 @@ fi # tools Build tools while [ $# -gt 0 ]; do case "$1" in - --enable-fortran) - build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=ON - ;; - --disable-fortran) - build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=OFF - ;; - --enable-cxx) - build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=ON - ;; - --disable-cxx) - build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=OFF - ;; - --enable-hl) - build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=ON - ;; - --disable-hl) - build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=OFF - ;; - --enable-shared) - shared_lib=-DBUILD_SHARED_LIBS:BOOL=ON - ;; - --disable-shared) - shared_lib=-DBUILD_SHARED_LIBS:BOOL=OFF - ;; - --enable-tools) - build_tools=-DHDF5_BUILD_TOOLS:BOOL=ON - ;; - --disable-tools) - build_tools=-DHDF5_BUILD_TOOLS:BOOL=OFF - ;; - --enable-testing) - build_testing=-DBUILD_TESTING:BOOL=ON - ;; - --disable-testing) - build_testing=-DBUILD_TESTING:BOOL=OFF - ;; - --with-zlib) - with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON - ;; - --with-zlib=*) - xarg=`echo $1 | cut -d= -f2-` - with_zlib="-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON -DZLIB_ROOT=$xarg" - ;; - --without-zlib) - with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF - ;; - --with-szlib) - with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON - szlib_path="" # szlib is in default paths - ;; - --with-szlib=*) - xarg=`echo $1 | cut -d= -f2-` - with_szlib="-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON" - szlib_path="SZIP_INSTALL=$xarg" - ;; - --without-szlib) - with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF - szlib_path="" # reset the path - ;; - --njobs=*) - njobs=`echo $1 | cut -d= -f2-` - ;; - --enable-verbose) - vflag=1 - ;; - --disable-verbose) - vflag=0 - ;; - --help) - # print the detail help page and exit - HELP - exit 0 - ;; - *) - echo "Unknown options: $1" - HELP - exit 1 - ;; + --enable-fortran) + build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=ON + ;; + --disable-fortran) + build_fortran=-DHDF5_BUILD_FORTRAN:BOOL=OFF + ;; + --enable-cxx) + build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=ON + ;; + --disable-cxx) + build_cpp_lib=-DHDF5_BUILD_CPP_LIB:BOOL=OFF + ;; + --enable-hl) + build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=ON + ;; + --disable-hl) + build_hl_lib=-DHDF5_BUILD_HL_LIB:BOOL=OFF + ;; + --enable-shared) + shared_lib=-DBUILD_SHARED_LIBS:BOOL=ON + ;; + --disable-shared) + shared_lib=-DBUILD_SHARED_LIBS:BOOL=OFF + ;; + --enable-tools) + build_tools=-DHDF5_BUILD_TOOLS:BOOL=ON + ;; + --disable-tools) + build_tools=-DHDF5_BUILD_TOOLS:BOOL=OFF + ;; + --enable-testing) + build_testing=-DBUILD_TESTING:BOOL=ON + ;; + --disable-testing) + build_testing=-DBUILD_TESTING:BOOL=OFF + ;; + --with-zlib) + with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON + ;; + --with-zlib=*) + xarg=`echo $1 | cut -d= -f2-` + with_zlib="-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON -DZLIB_ROOT=$xarg" + ;; + --without-zlib) + with_zlib=-DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF + ;; + --with-szlib) + with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON + szlib_path="" # szlib is in default paths + ;; + --with-szlib=*) + xarg=`echo $1 | cut -d= -f2-` + with_szlib="-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON" + szlib_path="SZIP_INSTALL=$xarg" + ;; + --without-szlib) + with_szlib=-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF + szlib_path="" # reset the path + ;; + --njobs=*) + njobs=`echo $1 | cut -d= -f2-` + ;; + --enable-verbose) + vflag=1 + ;; + --disable-verbose) + vflag=0 + ;; + --help) + # print the detail help page and exit + HELP + exit 0 + ;; + *) + echo "Unknown options: $1" + HELP + exit 1 + ;; esac shift done -- cgit v0.12 From 887cf130ff773568f90ec8bae66dafa761a77712 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Jan 2016 09:08:00 -0500 Subject: [svn-r28843] Description: Bump number of records for random update test again. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- test/btree2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/btree2.c b/test/btree2.c index 3278b67..2c9bbae 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -38,7 +38,7 @@ const char *FILENAME[] = { #define INSERT_SPLIT_ROOT_NREC 63 #define INSERT_SPLIT_ROOT_NREC_REC 64 #define INSERT_MANY (1000 * 1000) -#define INSERT_MANY_REC (2675 * 1000) +#define INSERT_MANY_REC (2700 * 1000) #define FIND_MANY (INSERT_MANY / 100) #define FIND_MANY_REC (INSERT_MANY_REC / 100) #define FIND_NEIGHBOR 2000 -- cgit v0.12 From 67570ce476f334fdafc01a89796808264ab8e6c4 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Mon, 11 Jan 2016 11:16:38 -0500 Subject: [svn-r28853] HDFFV-9649: cmakehdf5 needs a proper implementation to verify the installation images created for Mac OSX. The current implementation for Mac OSX platform is a kludge that sometimes left behind mounted volumes. Temporary screen out the checking of installtion_check step (so that daily test may pass). Tested: by hand running cmakehdf5 in platypus and osx1010test. --- bin/cmakehdf5 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bin/cmakehdf5 b/bin/cmakehdf5 index 6e22e17..7d9caa8 100755 --- a/bin/cmakehdf5 +++ b/bin/cmakehdf5 @@ -148,6 +148,10 @@ INSTALL_HDF5() $install_file --skip-license $* ;; Darwin) # Mac OSX DMG file + # These steps were a kludge. Need proper support from Cmake engineering. + echo Darwin install step needs proper implementation. Quit. + return 1 + # install_file=HDF5-${version}-Darwin.dmg test -d hdf5 || mkdir hdf5 basename=`basename $install_file .dmg` @@ -313,8 +317,8 @@ fi # setup output of all the log files if verbose is on upon exit trap \ -"if [ $vflag -ne 0 ]; then DUMP_LOGFILE \$configlog \$makelog \$testlog \$packlog \$installlog; fi" \ -0 + "if [ $vflag -ne 0 ]; then DUMP_LOGFILE \$configlog \$makelog \$testlog \$packlog \$installlog; fi" \ + 0 echo Running Cmake for HDF5-${version} ... # 4. Configure the C library, tools and tests with this command: @@ -343,8 +347,13 @@ STEP "Test the library and tools..." "ctest . -C Release $njobs" $testlog # 7. Create an install image with this command: STEP "Create an install image..." "cpack -C Release CPackConfig.cmake" $packlog +# The implementation of installation is imcomplete (only works for linux). +# Screen it out for now till it is completed. +if false; then # 8. Install with this command: STEP "Install..." "INSTALL_HDF5" $installlog +fi + # save the last exit code exit_code=$? -- cgit v0.12 From 2396a172adc0fca7ad56fe6bd89276903dc8af44 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 12 Jan 2016 07:28:39 -0500 Subject: [svn-r28861] Minor warning format string fix (HDFFV-9640). Tested on: 64-bit Ubuntu 15.10 (Linux 4.2.0 x86_64) gcc 5.2.1 autotools parallel only (MPICH 3.1.4) --- src/H5Eprivate.h | 2 +- test/error_test.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h index ba17ada..db413e3 100644 --- a/src/H5Eprivate.h +++ b/src/H5Eprivate.h @@ -125,7 +125,7 @@ extern int H5E_mpi_error_str_len; #define HMPI_ERROR(mpierr){ \ MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \ - HERROR(H5E_INTERNAL, H5E_MPIERRSTR, H5E_mpi_error_str); \ + HERROR(H5E_INTERNAL, H5E_MPIERRSTR, "%s", H5E_mpi_error_str); \ } #define HMPI_DONE_ERROR(retcode, str, mpierr){ \ HMPI_ERROR(mpierr); \ diff --git a/test/error_test.c b/test/error_test.c index 4e4c0ef..ee181b1 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -498,7 +498,7 @@ test_create(void) if(err_num != 0) TEST_ERROR /* Push an error with a long description */ - if(H5Epush(estack_id, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, err_msg) < 0) TEST_ERROR; + if(H5Epush(estack_id, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) TEST_ERROR; /* Check the number of errors on stack */ err_num = H5Eget_num(estack_id); @@ -543,7 +543,7 @@ test_copy(void) herr_t ret; /* Generic return value */ /* Push an error with a long description */ - if(H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, err_msg) < 0) TEST_ERROR; + if(H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, "%s", err_msg) < 0) TEST_ERROR; /* Check the number of errors on stack */ err_num = H5Eget_num(H5E_DEFAULT); -- cgit v0.12 From 24443da31663e4f0835e8b966470aff6dfb4f0c9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 12 Jan 2016 15:31:59 -0500 Subject: [svn-r28865] HDFFV-9639: Fix double-free error by setting freed var to NULL. Verified issue with "h5dump tgroup.h5 non_existing.h5" Applied patch and retested. --- tools/h5dump/CMakeTests.cmake | 39 ++++++++++++--------- tools/h5dump/errfiles/non_existing.err | 1 + tools/h5dump/h5dump.c | 64 +++++++++++++++++++--------------- tools/testfiles/non_existing.ddl | 31 ++++++++++++++++ 4 files changed, 91 insertions(+), 44 deletions(-) create mode 100644 tools/h5dump/errfiles/non_existing.err create mode 100644 tools/testfiles/non_existing.ddl diff --git a/tools/h5dump/CMakeTests.cmake b/tools/h5dump/CMakeTests.cmake index 00ec760..c256e11 100644 --- a/tools/h5dump/CMakeTests.cmake +++ b/tools/h5dump/CMakeTests.cmake @@ -4,7 +4,7 @@ ### T E S T I N G ### ############################################################################## ############################################################################## - + # -------------------------------------------------------------------- # Copy all the HDF5 files from the test directory into the source directory # -------------------------------------------------------------------- @@ -12,6 +12,7 @@ ${HDF5_TOOLS_SRC_DIR}/testfiles/charsets.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/file_space.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/filter_fail.ddl + ${HDF5_TOOLS_SRC_DIR}/testfiles/non_existing.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/packedbits.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-1.ddl ${HDF5_TOOLS_SRC_DIR}/testfiles/tall-2.ddl @@ -284,6 +285,7 @@ ) set (HDF5_ERROR_REFERENCE_TEST_FILES ${PROJECT_SOURCE_DIR}/errfiles/filter_fail.err + ${PROJECT_SOURCE_DIR}/errfiles/non_existing.err ${PROJECT_SOURCE_DIR}/errfiles/tall-1.err ${PROJECT_SOURCE_DIR}/errfiles/tall-2A.err ${PROJECT_SOURCE_DIR}/errfiles/tall-2A0.err @@ -325,7 +327,7 @@ ARGS -E copy_if_different ${tst_h5_file} ${dest} ) endforeach (tst_h5_file ${HDF5_REFERENCE_TEST_FILES}) - + foreach (tst_exp_file ${HDF5_REFERENCE_EXP_FILES}) if (WIN32) file (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/${tst_exp_file} TEST_STREAM) @@ -373,7 +375,7 @@ COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_SOURCE_DIR}/testfiles/tbin1.ddl ${PROJECT_BINARY_DIR}/testfiles/std/tbin1LE.ddl ) - + if (WIN32) file (READ ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.exp TEST_STREAM) file (WRITE ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp "${TEST_STREAM}") @@ -385,7 +387,7 @@ ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/tbinregR.exp ${PROJECT_BINARY_DIR}/testfiles/std/tbinregR.exp ) endif (WIN32) - + ############################################################################## ############################################################################## ### T H E T E S T S M A C R O S ### @@ -730,7 +732,7 @@ add_test ( NAME H5DUMP-clearall-objects COMMAND ${CMAKE_COMMAND} - -E remove + -E remove h5dump-help.out charsets.out charsets.out.err @@ -738,6 +740,8 @@ file_space.out.err filter_fail.out filter_fail.out.err + non_existing.out + non_existing.out.err packedbits.out packedbits.out.err tall-1.out @@ -1075,9 +1079,9 @@ ADD_H5_TEST_EXPORT (trawdatafile packedbits.h5 0 --enable-error-stack -y -o) ADD_H5_TEST_EXPORT (tnoddlfile packedbits.h5 0 --enable-error-stack -O -y -o) ADD_H5_TEST_EXPORT (trawssetfile tdset.h5 0 --enable-error-stack -d "/dset1[1,1;;;]" -y -o) - + ADD_H5_TEST_EXPORT_DDL (twithddlfile packedbits.h5 0 twithddl --enable-error-stack --ddl=twithddl.txt -y -o) - + # test for maximum display datasets ADD_H5_TEST (twidedisplay 0 --enable-error-stack -w0 packedbits.h5) @@ -1147,7 +1151,7 @@ # test for named data types ADD_H5_TEST (tcomp-2 0 --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5) ADD_H5_TEST_N (tcomp-2 0 --enable-error-stack -N /type1 --any_path /type2 --any_path=/group1/type3 tcompound.h5) - # test for unamed type + # test for unamed type ADD_H5ERR_MASK_TEST (tcomp-3 0 "--enable-error-stack;-t;/#6632;-g;/group2;tcompound.h5") # test complicated compound datatype ADD_H5_TEST (tcomp-4 0 --enable-error-stack tcompound_complex.h5) @@ -1169,7 +1173,7 @@ # test for loop detection ADD_H5_TEST (tloop-1 0 --enable-error-stack tloop.h5) - # test for string + # test for string ADD_H5_TEST (tstr-1 0 --enable-error-stack tstr.h5) ADD_H5_TEST (tstr-2 0 --enable-error-stack tstr2.h5) @@ -1202,7 +1206,7 @@ #ADD_H5_MASK_TEST (tstarfile 0 --enable-error-stack -H -d Dataset1 tarr*.h5) #ADD_H5_MASK_TEST (tqmarkfile 0 --enable-error-stack -H -d Dataset1 tarray?.h5) ADD_H5_TEST (tmultifile 0 --enable-error-stack -H -d Dataset1 tarray2.h5 tarray3.h5 tarray4.h5 tarray5.h5 tarray6.h5 tarray7.h5) - + # test for files with empty data ADD_H5_TEST (tempty 0 --enable-error-stack tempty.h5) @@ -1263,7 +1267,7 @@ ADD_H5_TEST (tcontiguos 0 --enable-error-stack -H -p -d contiguous tfilters.h5) # chunked ADD_H5_TEST (tchunked 0 --enable-error-stack -H -p -d chunked tfilters.h5) - # external + # external ADD_H5_TEST (texternal 0 --enable-error-stack -H -p -d external tfilters.h5) # fill values @@ -1331,7 +1335,7 @@ # don't have). Do this by searching H5pubconf.h to see which # filters are defined. -# detect whether the encoder is present. +# detect whether the encoder is present. if (H5_HAVE_FILTER_DEFLATE) set (USE_FILTER_DEFLATE "true") endif (H5_HAVE_FILTER_DEFLATE) @@ -1352,12 +1356,12 @@ # test for displaying objects with very long names ADD_H5_TEST (tlonglinks 0 --enable-error-stack tlonglinks.h5) - # dimensions over 4GB, print boundary + # dimensions over 4GB, print boundary ADD_H5_TEST (tbigdims 0 --enable-error-stack -d dset4gb -s 4294967284 -c 22 tbigdims.h5) # hyperslab read ADD_H5_TEST (thyperslab 0 --enable-error-stack thyperslab.h5) - + # test for displaying dataset and attribute of null space ADD_H5_TEST (tnullspace 0 --enable-error-stack tnullspace.h5) @@ -1391,7 +1395,7 @@ ADD_H5_TEST (tbin4 0 --enable-error-stack -d double -b FILE -o tbin4.bin tbinary.h5) endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - # test for dataset region references + # test for dataset region references ADD_H5_TEST (tdatareg 0 --enable-error-stack tdatareg.h5) ADD_H5ERR_MASK_TEST (tdataregR 0 --enable-error-stack -R tdatareg.h5) ADD_H5ERR_MASK_TEST (tattrregR 0 -R --enable-error-stack tattrreg.h5) @@ -1414,7 +1418,7 @@ # tests for link references and order ADD_H5ERR_MASK_TEST (torderlinks1 0 --enable-error-stack --sort_by=name --sort_order=ascending tfcontents1.h5) ADD_H5ERR_MASK_TEST (torderlinks2 0 --enable-error-stack --sort_by=name --sort_order=descending tfcontents1.h5) - + # tests for floating point user defined printf format ADD_H5_TEST (tfpformat 0 --enable-error-stack -m %.7f tfpformat.h5) @@ -1430,3 +1434,6 @@ # test for -o -y for dataset with attributes ADD_H5_TEST_EXPORT (tall-6 tall.h5 0 --enable-error-stack -d /g1/g1.1/dset1.1.1 -y -o) + + # test for non-existing file + ADD_H5_TEST (non_existing 1 --enable-error-stack tgroup.h5 non_existing.h5) diff --git a/tools/h5dump/errfiles/non_existing.err b/tools/h5dump/errfiles/non_existing.err new file mode 100644 index 0000000..f7e3afa --- /dev/null +++ b/tools/h5dump/errfiles/non_existing.err @@ -0,0 +1 @@ +h5dump error: unable to open file "non_existing.h5" diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 68889c9..ffba581 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -620,7 +620,7 @@ parse_hsize_list(const char *h_list, subset_d *d) size_count++; last_digit = 1; - } + } else { last_digit = 0; } @@ -643,7 +643,7 @@ parse_hsize_list(const char *h_list, subset_d *d) } d->data = p_list; d->len = size_count; - + return; } @@ -705,7 +705,7 @@ parse_subset_params(char *dset) * * Purpose: Parse a list of comma or space separated integers and fill * the packed_bits list and counter. The string being passed into this function - * should be at the start of the list you want to parse. + * should be at the start of the list you want to parse. * * Return: Success: SUCCEED * @@ -831,7 +831,7 @@ static void free_handler(struct handler_t *hand, int len) { int i; - + if(hand) { for (i = 0; i < len; i++) { if(hand[i].obj) { @@ -1161,7 +1161,7 @@ parse_start: } if (HDstrcmp(opt_arg,":") == 0) { xmlnsprefix = ""; - } + } else { xmlnsprefix = opt_arg; } @@ -1187,7 +1187,7 @@ parse_start: * the two. */ s = last_dset->subset_info; - } + } else { last_dset->subset_info = s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t)); } @@ -1358,7 +1358,7 @@ main(int argc, const char *argv[]) /* Disable tools error reporting */ H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); - + if((hand = parse_command_line(argc, argv))==NULL) { goto done; } @@ -1444,12 +1444,12 @@ main(int argc, const char *argv[]) if (xml_dtd_uri == NULL) { if (useschema) { xml_dtd_uri = DEFAULT_XSD; - } + } else { xml_dtd_uri = DEFAULT_DTD; xmlnsprefix = ""; } - } + } else { if (useschema && HDstrcmp(xmlnsprefix,"")) { error_msg("Cannot set Schema URL for a qualified namespace--use -X or -U option with -D \n"); @@ -1486,7 +1486,7 @@ main(int argc, const char *argv[]) /* start to dump - display file header information */ if (!doxml) { begin_obj(h5tools_dump_header_format->filebegin, fname, h5tools_dump_header_format->fileblockbegin); - } + } else { PRINTVALSTREAM(rawoutstream, "\n"); @@ -1495,7 +1495,7 @@ main(int argc, const char *argv[]) if (HDstrcmp(xmlnsprefix,"") == 0) { PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri); - } + } else { /* TO DO: make -url option work in this case (may need new option) */ char *ns; @@ -1511,7 +1511,7 @@ main(int argc, const char *argv[]) "http://www.hdfgroup.org/HDF5/XML/schema/HDF5-File.xsd\">\n",xmlnsprefix,ns); HDfree(ns); } - } + } else { PRINTSTREAM(rawoutstream, "\n", xml_dtd_uri); PRINTVALSTREAM(rawoutstream, "\n"); @@ -1570,7 +1570,7 @@ main(int argc, const char *argv[]) if (!doxml) { end_obj(h5tools_dump_header_format->fileend, h5tools_dump_header_format->fileblockend); PRINTVALSTREAM(rawoutstream, "\n"); - } + } else { PRINTSTREAM(rawoutstream, "\n", xmlnsprefix); } @@ -1581,13 +1581,17 @@ main(int argc, const char *argv[]) if (H5Fclose(fid) < 0) h5tools_setstatus(EXIT_FAILURE); - if(prefix) + if(prefix) { HDfree(prefix); - if(fname) + prefix = NULL; + } + if(fname) { HDfree(fname); + fname = NULL; + } } /* end while */ - if(hand) + if(hand) free_handler(hand, argc); /* To Do: clean up XML table */ @@ -1601,13 +1605,17 @@ done: if(fid >=0) if (H5Fclose(fid) < 0) h5tools_setstatus(EXIT_FAILURE); - - if(prefix) + + if(prefix) { HDfree(prefix); - if(fname) + prefix = NULL; + } + if(fname) { HDfree(fname); + fname = NULL; + } - if(hand) + if(hand) free_handler(hand, argc); /* To Do: clean up XML table */ @@ -1660,20 +1668,20 @@ h5_fileaccess(void) if (!HDstrcmp(name, "sec2")) { /* Unix read() and write() system calls */ if (H5Pset_fapl_sec2(fapl)<0) return -1; - } + } else if (!HDstrcmp(name, "stdio")) { /* Standard C fread() and fwrite() system calls */ if (H5Pset_fapl_stdio(fapl)<0) return -1; - } + } else if (!HDstrcmp(name, "core")) { /* In-core temporary file with 1MB increment */ if (H5Pset_fapl_core(fapl, 1024*1024, FALSE)<0) return -1; - } + } else if (!HDstrcmp(name, "split")) { /* Split meta data and raw data each using default driver */ if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) return -1; - } + } else if (!HDstrcmp(name, "multi")) { /* Multi-file driver, general case of the split driver */ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; @@ -1699,7 +1707,7 @@ h5_fileaccess(void) if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) return -1; - } + } else if (!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ @@ -1708,7 +1716,7 @@ h5_fileaccess(void) fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; - } + } else if (!HDstrcmp(name, "log")) { long log_flags = H5FD_LOG_LOC_IO; @@ -1718,12 +1726,12 @@ h5_fileaccess(void) if (H5Pset_fapl_log(fapl, NULL, (unsigned)log_flags, 0) < 0) return -1; - } + } else if (!HDstrcmp(name, "direct")) { /* Substitute Direct I/O driver with sec2 driver temporarily because * some output has sec2 driver as the standard. */ if (H5Pset_fapl_sec2(fapl)<0) return -1; - } + } else { /* Unknown driver */ return -1; diff --git a/tools/testfiles/non_existing.ddl b/tools/testfiles/non_existing.ddl new file mode 100644 index 0000000..4377f8d --- /dev/null +++ b/tools/testfiles/non_existing.ddl @@ -0,0 +1,31 @@ +HDF5 "tgroup.h5" { +GROUP "/" { + GROUP "g1" { + GROUP "g1.1" { + } + GROUP "g1.2" { + } + } + GROUP "g2" { + GROUP "g2.1" { + GROUP "g2.1.1" { + } + GROUP "g2.1.2" { + } + GROUP "g2.1.3" { + } + } + } + GROUP "g3" { + GROUP "g3.1" { + } + GROUP "g3.2" { + } + GROUP "g3.3" { + } + GROUP "g3.4" { + } + } +} +} +h5dump error: unable to open file "non_existing.h5" -- cgit v0.12 From af88e57c263e2361a9bf084338ea463abf6dcbc4 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 12 Jan 2016 15:38:20 -0500 Subject: [svn-r28866] HDFFV-9639: new files --- MANIFEST | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MANIFEST b/MANIFEST index 3923060..d741018 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1363,6 +1363,7 @@ ./tools/testfiles/filter_fail.h5 ./tools/testfiles/filter_fail.ddl ./tools/testfiles/h5dump-help.txt +./tools/testfiles/non_existing.ddl ./tools/testfiles/packedbits.ddl ./tools/testfiles/taindices.h5 ./tools/testfiles/tall-1.ddl @@ -1619,6 +1620,7 @@ # h5dump test error files ./tools/h5dump/errfiles/filter_fail.err +./tools/h5dump/errfiles/non_existing.err ./tools/h5dump/errfiles/tall-1.err ./tools/h5dump/errfiles/tall-2A.err ./tools/h5dump/errfiles/tall-2A0.err -- cgit v0.12 From 0115366eee8364b2f433725026553ebc58678937 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 12 Jan 2016 15:48:23 -0500 Subject: [svn-r28868] HDFFV-9639: autotools script update --- tools/h5dump/testh5dump.sh.in | 65 +++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 95f8091..8be1745 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -27,10 +27,10 @@ EXIT_FAILURE=1 DUMPER=h5dump # The tool name DUMPER_BIN=`pwd`/$DUMPER # The path of the tool binary -H5DIFF=../h5diff/h5diff # The h5diff tool name +H5DIFF=../h5diff/h5diff # The h5diff tool name H5DIFF_BIN=`pwd`/$H5DIFF # The path of the h5diff tool binary -H5IMPORT=../h5import/h5import # The h5import tool name +H5IMPORT=../h5import/h5import # The h5import tool name H5IMPORT_BIN=`pwd`/$H5IMPORT # The path of the h5import tool binary RM='rm -rf' @@ -176,6 +176,7 @@ LIST_OTHER_TEST_FILES=" $SRC_H5DUMP_TESTFILES/charsets.ddl $SRC_H5DUMP_TESTFILES/file_space.ddl $SRC_H5DUMP_TESTFILES/filter_fail.ddl +$SRC_H5DUMP_TESTFILES/non_existing.ddl $SRC_H5DUMP_TESTFILES/packedbits.ddl $SRC_H5DUMP_TESTFILES/tall-1.ddl $SRC_H5DUMP_TESTFILES/tall-2.ddl @@ -266,7 +267,7 @@ $SRC_H5DUMP_TESTFILES/tindicessub4.ddl $SRC_H5DUMP_TESTFILES/tindicesyes.ddl $SRC_H5DUMP_TESTFILES/tintsattrs.ddl $SRC_H5DUMP_TESTFILES/tlarge_objname.ddl -#$SRC_H5DUMP_TESTFILES/tldouble.ddl +#$SRC_H5DUMP_TESTFILES/tldouble.ddl $SRC_H5DUMP_TESTFILES/tlonglinks.ddl $SRC_H5DUMP_TESTFILES/tloop-1.ddl $SRC_H5DUMP_TESTFILES/tmulti.ddl @@ -347,6 +348,7 @@ $SRC_H5DUMP_TESTFILES/tbinregR.exp LIST_ERROR_TEST_FILES=" ${SRC_H5DUMP_ERRORFILES}/filter_fail.err +${SRC_H5DUMP_ERRORFILES}/non_existing.err ${SRC_H5DUMP_ERRORFILES}/tall-1.err ${SRC_H5DUMP_ERRORFILES}/tall-2A.err ${SRC_H5DUMP_ERRORFILES}/tall-2A0.err @@ -393,10 +395,10 @@ COPY_TESTFILES_TO_TESTDIR() INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $CP -f $tstfile $TESTDIR + $CP -f $tstfile $TESTDIR if [ $? -ne 0 ]; then echo "Error: FAILED to copy $tstfile ." - + # Comment out this to CREATE expected file exit $EXIT_FAILURE fi @@ -441,14 +443,14 @@ TESTING() { TOOLTEST() { # check if caseless compare and diff requested if [ "$1" = ignorecase ]; then - caseless="-i" - # replace cmp with diff which runs much longer. - xCMP="$DIFF -i" - shift + caseless="-i" + # replace cmp with diff which runs much longer. + xCMP="$DIFF -i" + shift else - caseless="" - # stick with faster cmp if ignorecase is not requested. - xCMP="$CMP" + caseless="" + # stick with faster cmp if ignorecase is not requested. + xCMP="$CMP" fi expect="$TESTDIR/$1" @@ -537,7 +539,7 @@ TOOLTEST2() { nerrors="`expr $nerrors + 1`" test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi - + # Clean up output file if test -z "$HDF5_NOCLEANUP"; then rm -f $actual $actualdata $actual_err @@ -545,7 +547,7 @@ TOOLTEST2() { } -# same as TOOLTEST2 but compares generated file to expected ddl file +# same as TOOLTEST2 but compares generated file to expected ddl file # and compares the generated data file to the expected data file # used for the binary tests that expect a full path in -o without -b # ADD_H5_TEST_EXPORT @@ -603,7 +605,7 @@ TOOLTEST2A() { nerrors="`expr $nerrors + 1`" test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' fi - + # Clean up output file if test -z "$HDF5_NOCLEANUP"; then rm -f $actual $actualdata $actual_err $actualmeta @@ -642,7 +644,7 @@ TOOLTEST2B() { nerrors="`expr $nerrors + 1`" test yes = "$verbose" && $DIFF $expectdata $actualdata |sed 's/^/ /' fi - + # Clean up output file if test -z "$HDF5_NOCLEANUP"; then rm -f $actual $actualdata $actual_err @@ -859,7 +861,7 @@ TOOLTEST_HELP() { echo " Expected output (*.txt) differs from actual output (*.out)" nerrors="`expr $nerrors + 1`" fi - + # Clean up output file if test -z "$HDF5_NOCLEANUP"; then rm -f $actual $actual_err @@ -872,7 +874,7 @@ SKIP() { TESTING $DUMPER $@ echo " -SKIP-" } - + # Print a line-line message left justified in a field of 70 characters # PRINT_H5DIFF() { @@ -883,7 +885,7 @@ PRINT_H5DIFF() { # Call the h5diff tool # -DIFFTEST() +DIFFTEST() { PRINT_H5DIFF $@ ( @@ -897,7 +899,7 @@ DIFFTEST() else echo " PASSED" fi - + } # Print a line-line message left justified in a field of 70 characters @@ -910,7 +912,7 @@ PRINT_H5IMPORT() { # Call the h5import tool # -IMPORTTEST() +IMPORTTEST() { # remove the output hdf5 file if it exists hdf5_file="$TESTDIR/$5" @@ -921,7 +923,7 @@ IMPORTTEST() PRINT_H5IMPORT $@ ( cd $TESTDIR - $RUNSERIAL $H5IMPORT_BIN "$@" + $RUNSERIAL $H5IMPORT_BIN "$@" ) RET=$? if [ $RET != 0 ] ; then @@ -930,7 +932,7 @@ IMPORTTEST() else echo " PASSED" fi - + } @@ -1021,7 +1023,7 @@ TOOLTEST tcomp-1.ddl --enable-error-stack tcompound.h5 # test for named data types TOOLTEST tcomp-2.ddl --enable-error-stack -t /type1 --datatype /type2 --datatype=/group1/type3 tcompound.h5 TOOLTEST tcomp-2.ddl --enable-error-stack -N /type1 --any_path /type2 --any_path=/group1/type3 tcompound.h5 -# test for unamed type +# test for unamed type TOOLTEST4 tcomp-3.ddl --enable-error-stack -t /#6632 -g /group2 tcompound.h5 # test complicated compound datatype TOOLTEST tcomp-4.ddl --enable-error-stack tcompound_complex.h5 @@ -1041,7 +1043,7 @@ TOOLTEST tall-7N.ddl --enable-error-stack -N attr1 tall.h5 # test for loop detection TOOLTEST tloop-1.ddl --enable-error-stack tloop.h5 -# test for string +# test for string TOOLTEST tstr-1.ddl --enable-error-stack tstr.h5 TOOLTEST tstr-2.ddl --enable-error-stack tstr2.h5 @@ -1136,7 +1138,7 @@ TOOLTEST tcompact.ddl --enable-error-stack -H -p -d compact tfilters.h5 TOOLTEST tcontiguos.ddl --enable-error-stack -H -p -d contiguous tfilters.h5 # chunked TOOLTEST tchunked.ddl --enable-error-stack -H -p -d chunked tfilters.h5 -# external +# external TOOLTEST texternal.ddl --enable-error-stack -H -p -d external tfilters.h5 # fill values @@ -1205,7 +1207,7 @@ fi # test for displaying objects with very long names TOOLTEST tlonglinks.ddl --enable-error-stack tlonglinks.h5 -# dimensions over 4GB, print boundary +# dimensions over 4GB, print boundary TOOLTEST tbigdims.ddl --enable-error-stack -d dset4gb -s 4294967284 -c 22 tbigdims.h5 # hyperslab read @@ -1213,7 +1215,7 @@ TOOLTEST thyperslab.ddl --enable-error-stack thyperslab.h5 # - + # test for displaying dataset and attribute of null space TOOLTEST tnullspace.ddl --enable-error-stack tnullspace.h5 @@ -1252,7 +1254,7 @@ IMPORTTEST out3.bin -c tbin3.ddl -o out3D.h5 DIFFTEST tbinary.h5 out3D.h5 /integer /integer TOOLTEST tbin4.ddl --enable-error-stack -d double -b FILE -o out4.bin tbinary.h5 - + # Clean up binary output files if test -z "$HDF5_NOCLEANUP"; then rm -f out[1-4].bin @@ -1260,7 +1262,7 @@ if test -z "$HDF5_NOCLEANUP"; then rm -f out3.h5 fi -# test for dataset region references +# test for dataset region references TOOLTEST tdatareg.ddl --enable-error-stack tdatareg.h5 TOOLTEST4 tdataregR.ddl --enable-error-stack -R tdatareg.h5 TOOLTEST tattrreg.ddl --enable-error-stack tattrreg.h5 @@ -1306,6 +1308,9 @@ TOOLTEST5 filter_fail.ddl --enable-error-stack filter_fail.h5 # test for -o -y for dataset with attributes TOOLTEST2 tall-6.exp --enable-error-stack -y -o tall-6.txt -d /g1/g1.1/dset1.1.1 tall.h5 +# test for non-existing file +TOOLTEST5 non_existing.ddl --enable-error-stack tgroup.h5 non_existing.h5 + # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR -- cgit v0.12 From 1617502f5e643e38479f8ad106b0a92d36cc8695 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 13 Jan 2016 11:10:19 -0500 Subject: [svn-r28878] Removed some duplicated comment lines from configure.ac. Tested on: N/A --- configure.ac | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9c1d5b0..b1c26a2 100644 --- a/configure.ac +++ b/configure.ac @@ -2284,9 +2284,6 @@ fi ## ---------------------------------------------------------------------- ## Check if Direct I/O driver is enabled by --enable-direct-vfd ## -## ---------------------------------------------------------------------- -## Check if Direct I/O driver is enabled by --enable-direct-vfd -## AC_CACHE_VAL([hdf5_cv_direct_io], AC_CHECK_DECL([O_DIRECT], [hdf5_cv_direct_io=yes], [hdf5_cv_direct_io=no], [[#include ]])) AC_CACHE_VAL([hdf5_cv_posix_memalign], -- cgit v0.12 From b29d6174e17ddad6482f80c3da477ce9074487b1 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 13 Jan 2016 11:25:11 -0500 Subject: [svn-r28881] Merged r28880 from revise_chunks. Adds a script to flip maint mode. Tested on: linux VM --- MANIFEST | 1 + bin/switch_maint_mode | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100755 bin/switch_maint_mode diff --git a/MANIFEST b/MANIFEST index d741018..4899ab2 100644 --- a/MANIFEST +++ b/MANIFEST @@ -66,6 +66,7 @@ ./bin/runtest _DO_NOT_DISTRIBUTE_ ./bin/snapshot ./bin/snapshot_version _DO_NOT_DISTRIBUTE_ +./bin/switch_maint_mode _DO_NOT_DISTRIBUTE_ ./bin/timekeeper _DO_NOT_DISTRIBUTE_ ./bin/trace ./bin/yodconfigure diff --git a/bin/switch_maint_mode b/bin/switch_maint_mode new file mode 100755 index 0000000..2b62545 --- /dev/null +++ b/bin/switch_maint_mode @@ -0,0 +1,83 @@ +#!/bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic HDF5 document set and +# is linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have +# access to either file, you may request a copy from help@hdfgroup.org. +# +# Switch AM_MAINTAINER_MODE value in configure.ac +# Usage: See USAGE() +# Programmer: Dana Robinson +# Creation date: January 2016 + +USAGE() +{ +cat < + +EOF +} + +MODE="notset" +CONFIG_AC_PATH= + +# Display help/usage if any options were passed in +while [ $# -gt 0 ]; do + case "$1" in + -enable) + MODE="enable" + ;; + -disable) + MODE="disable" + ;; + -help) + USAGE + exit 0 + ;; + *) + CONFIG_AC_PATH="$1" + ;; + esac + shift +done + +# Did we get a file path? +if test -z $CONFIG_AC_PATH ; then + USAGE + exit 1 +fi + +# Did we get a mode? +if test -z $MODE ; then + USAGE + exit 1 +fi + +# Run perl over configure.ac +if test "X-$MODE" = "X-enable" ; then + perl -pi -e 's/^(AM_MAINTAINER_MODE\(\[)([a-z]+)(\]\))/$1enable$3/g' $CONFIG_AC_PATH +fi +if test "X-$MODE" = "X-disable" ; then + perl -pi -e 's/^(AM_MAINTAINER_MODE\(\[)([a-z]+)(\]\))/$1disable$3/g' $CONFIG_AC_PATH +fi + -- cgit v0.12 From 94d03fd874817c9245785b1cfac88457a30a7615 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 13 Jan 2016 12:24:20 -0500 Subject: [svn-r28885] Change TOOLTEST5 to TOOLTEST3, which does not post-process the files. --- tools/h5dump/testh5dump.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 8be1745..267ac44 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -1309,7 +1309,7 @@ TOOLTEST5 filter_fail.ddl --enable-error-stack filter_fail.h5 TOOLTEST2 tall-6.exp --enable-error-stack -y -o tall-6.txt -d /g1/g1.1/dset1.1.1 tall.h5 # test for non-existing file -TOOLTEST5 non_existing.ddl --enable-error-stack tgroup.h5 non_existing.h5 +TOOLTEST3 non_existing.ddl --enable-error-stack tgroup.h5 non_existing.h5 # Clean up temporary files/directories CLEAN_TESTFILES_AND_TESTDIR -- cgit v0.12 From bd44db8a3c39427c7e969f788d344f36bd4b7193 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 13 Jan 2016 23:29:58 -0500 Subject: [svn-r28894] Description: Normalize against changes on phdf5_metadata_opt branch to trunk Tested on: MacoSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5A.c | 57 ++++++++++++++------- src/H5AC.c | 28 +++++------ src/H5ACmpio.c | 42 ++++++++-------- src/H5C.c | 145 ++++++++++++++---------------------------------------- src/H5D.c | 9 ++-- src/H5F.c | 10 ++-- src/H5FDmpio.c | 3 +- src/H5Fpublic.h | 22 ++++++--- src/H5G.c | 22 ++++++--- src/H5L.c | 56 ++++++++++++++------- src/H5Lexternal.c | 3 +- src/H5O.c | 26 ++++++---- src/H5Pint.c | 2 +- src/H5Tcommit.c | 8 +-- 14 files changed, 214 insertions(+), 219 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index 7d87505..97d082c 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -252,6 +252,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, H5G_loc_t loc; /* Object location */ H5T_t *type; /* Datatype to use for attribute */ H5S_t *space; /* Dataspace to use for attribute */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -271,8 +272,8 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id))) + /* Go do the real work for attaching the attribute to the object */ + if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") /* Register the new attribute and get an ID for it */ @@ -331,6 +332,7 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ H5T_t *type; /* Datatype to use for attribute */ H5S_t *space; /* Dataspace to use for attribute */ + hid_t dxpl_id; /* dxpl used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -359,12 +361,14 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + dxpl_id = H5AC_ind_dxpl_id; + if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id))) + dxpl_id = H5AC_dxpl_id; + if(NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") /* Register the new attribute and get an ID for it */ @@ -405,6 +409,7 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t H5_ATTR_UNUSED aapl_id) { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute opened */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -419,7 +424,7 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t H5_ATTR_UNUSED aapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") /* Read in attribute from object header */ - if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id))) + if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name) /* Finish initializing attribute */ @@ -467,6 +472,7 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute opened */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -488,7 +494,7 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, H5AC_ind_dxpl_id))) + if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Register the attribute and get an ID for it */ @@ -535,6 +541,7 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, { H5A_t *attr = NULL; /* Attribute opened */ H5G_loc_t loc; /* Object location */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -559,7 +566,7 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Open the attribute in the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id))) + if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") /* Register the attribute and get an ID for it */ @@ -867,6 +874,7 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute object for name */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -891,7 +899,7 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id))) + if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the length of the name */ @@ -1005,6 +1013,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute object for name */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1028,7 +1037,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, H5AC_ind_dxpl_id))) + if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the attribute information */ @@ -1064,6 +1073,7 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute object for name */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1090,7 +1100,7 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id))) + if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") /* Get the attribute information */ @@ -1167,6 +1177,7 @@ herr_t H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, const char *new_attr_name, hid_t lapl_id) { + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by the library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1196,7 +1207,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call private attribute rename routine */ - if(H5A_rename_by_name(loc, obj_name, old_attr_name, new_attr_name, lapl_id, H5AC_dxpl_id) < 0) + if(H5A_rename_by_name(loc, obj_name, old_attr_name, new_attr_name, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ @@ -1341,6 +1352,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5A_attr_iter_op_t attr_op; /* Attribute operator */ hsize_t start_idx; /* Index of attribute to start iterating at */ hsize_t last_attr; /* Index of last attribute examined */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1370,12 +1382,12 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Open the object */ - if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) + if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Build attribute operator info */ @@ -1384,7 +1396,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Call attribute iteration routine */ last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O_attr_iterate(obj_loc_id, H5AC_ind_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) + if((ret_value = H5O_attr_iterate(obj_loc_id, dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); /* Set the last attribute information */ @@ -1469,6 +1481,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + hid_t dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1495,12 +1508,14 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + dxpl_id = H5AC_ind_dxpl_id; + if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Delete the attribute from the location */ - if(H5O_attr_remove(obj_loc.oloc, attr_name, H5AC_dxpl_id) < 0) + dxpl_id = H5AC_dxpl_id; + if(H5O_attr_remove(obj_loc.oloc, attr_name, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1545,6 +1560,7 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + hid_t dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1573,12 +1589,14 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + dxpl_id = H5AC_ind_dxpl_id; + if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; /* Delete the attribute from the location */ - if(H5O_attr_remove_by_idx(obj_loc.oloc, idx_type, order, n, H5AC_dxpl_id) < 0) + dxpl_id = H5AC_dxpl_id; + if(H5O_attr_remove_by_idx(obj_loc.oloc, idx_type, order, n, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1684,6 +1702,7 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { H5G_loc_t loc; /* Object location */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1704,7 +1723,7 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - if((ret_value = H5A_exists_by_name(loc, obj_name, attr_name, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5A_exists_by_name(loc, obj_name, attr_name, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: diff --git a/src/H5AC.c b/src/H5AC.c index f5b331f..34e291d 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -189,7 +189,7 @@ H5AC__init_package(void) HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list") /* Get the property list object */ - if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_dxpl_id))) + if(NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_dxpl_id))) HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object") /* Insert 'collective metadata write' property */ @@ -260,7 +260,7 @@ H5AC_term_package(void) H5E_clear_stack(NULL); /*ignore error*/ } /* end if */ #endif /* H5_HAVE_PARALLEL */ - + /* Reset static IDs */ H5AC_dxpl_id = (-1); H5AC_ind_dxpl_id = (-1); @@ -478,7 +478,7 @@ H5AC_dest(H5F_t *f, hid_t dxpl_id) #endif /* H5AC__TRACE_FILE_ENABLED */ #ifdef H5_HAVE_PARALLEL - aux_ptr = H5C_get_aux_ptr(f->shared->cache); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); if(aux_ptr) /* Sanity check */ HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -766,7 +766,7 @@ H5AC_insert_entry(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t add { H5AC_aux_t *aux_ptr; - if(NULL != (aux_ptr = H5C_get_aux_ptr(f->shared->cache))) { + if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { /* Log the new entry */ if(H5AC__log_inserted_entry((H5AC_info_t *)thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC__log_inserted_entry() failed") @@ -832,7 +832,7 @@ H5AC_mark_entry_dirty(void *thing) H5C_t *cache_ptr = entry_ptr->cache_ptr; H5AC_aux_t *aux_ptr; - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) && (entry_ptr->is_pinned) && (NULL != aux_ptr)) if(H5AC__log_dirtied_entry(entry_ptr) < 0) @@ -901,7 +901,7 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne #ifdef H5_HAVE_PARALLEL /* Log moving the entry */ - if(NULL != (aux_ptr = H5C_get_aux_ptr(f->shared->cache))) + if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) if(H5AC__log_moved_entry(f, old_addr, new_addr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log moved entry") #endif /* H5_HAVE_PARALLEL */ @@ -1166,7 +1166,7 @@ H5AC_resize_entry(void *thing, size_t new_size) H5C_t *cache_ptr = entry_ptr->cache_ptr; H5AC_aux_t *aux_ptr; - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); if((!entry_ptr->is_dirty) && (NULL != aux_ptr)) if(H5AC__log_dirtied_entry(entry_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry") @@ -1377,7 +1377,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr, } /* end if */ #ifdef H5_HAVE_PARALLEL - if(NULL != (aux_ptr = H5C_get_aux_ptr(f->shared->cache))) { + if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) { if(dirtied && ((H5AC_info_t *)thing)->is_dirty == FALSE) if(H5AC__log_dirtied_entry((H5AC_info_t *)thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log dirtied entry") @@ -1502,7 +1502,7 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, { H5AC_aux_t *aux_ptr; - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr on entry.") } @@ -1549,7 +1549,7 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr, { H5AC_aux_t *aux_ptr; - if(NULL != (aux_ptr = H5C_get_aux_ptr(cache_ptr))) { + if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { config_ptr->dirty_bytes_threshold = aux_ptr->dirty_bytes_threshold; config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy; } /* end if */ @@ -1691,7 +1691,7 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config { H5AC_aux_t *aux_ptr; - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr on entry.") } @@ -1735,7 +1735,7 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config /* Set parallel configuration values */ /* (Which are only held in the H5AC layer -QAK) */ - if(NULL != (aux_ptr = H5C_get_aux_ptr(cache_ptr))) { + if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) { aux_ptr->dirty_bytes_threshold = config_ptr->dirty_bytes_threshold; aux_ptr->metadata_write_strategy = config_ptr->metadata_write_strategy; } /* end if */ @@ -1950,7 +1950,7 @@ H5AC_open_trace_file(H5AC_t *cache_ptr, const char *trace_file_name) { H5AC_aux_t * aux_ptr; - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); if(aux_ptr == NULL) sprintf(file_name, "%s", trace_file_name); else { @@ -2131,7 +2131,7 @@ H5_ATTR_UNUSED HDassert(f != NULL); HDassert(f->shared != NULL); HDassert(f->shared->cache != NULL); - aux_ptr = H5C_get_aux_ptr(f->shared->cache); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache); if(aux_ptr != NULL) { HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); diff --git a/src/H5ACmpio.c b/src/H5ACmpio.c index fdad19a..ca2582e 100644 --- a/src/H5ACmpio.c +++ b/src/H5ACmpio.c @@ -159,7 +159,7 @@ H5AC__set_sync_point_done_callback(H5C_t * cache_ptr, /* Sanity checks */ HDassert(cache_ptr); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -192,7 +192,7 @@ H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)) /* Sanity checks */ HDassert(cache_ptr); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -231,7 +231,7 @@ H5AC_add_candidate(H5AC_t * cache_ptr, haddr_t addr) /* Sanity checks */ HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); @@ -295,7 +295,7 @@ H5AC__broadcast_candidate_list(H5AC_t *cache_ptr, int *num_entries_ptr, /* Sanity checks */ HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank == 0); @@ -427,7 +427,7 @@ H5AC__broadcast_clean_list(H5AC_t * cache_ptr) /* Sanity checks */ HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank == 0); @@ -624,7 +624,7 @@ H5AC__copy_candidate_list_to_buffer(const H5AC_t *cache_ptr, int *num_entries_pt /* Sanity checks */ HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); @@ -700,7 +700,7 @@ H5AC__log_deleted_entry(const H5AC_info_t *entry_ptr) addr = entry_ptr->addr; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank == 0); @@ -756,7 +756,7 @@ H5AC__log_dirtied_entry(const H5AC_info_t *entry_ptr) HDassert(entry_ptr->is_dirty == FALSE); cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -839,7 +839,7 @@ H5AC__log_flushed_entry(H5C_t *cache_ptr, haddr_t addr, hbool_t was_dirty, /* Sanity check */ HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank == 0); @@ -907,7 +907,7 @@ H5AC__log_inserted_entry(const H5AC_info_t *entry_ptr) HDassert(entry_ptr); cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -1010,7 +1010,7 @@ H5AC__log_moved_entry(const H5F_t *f, haddr_t old_addr, haddr_t new_addr) HDassert(f->shared); cache_ptr = (H5AC_t *)f->shared->cache; HDassert(cache_ptr); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); @@ -1188,7 +1188,7 @@ H5AC__propagate_and_apply_candidate_list(H5F_t *f, hid_t dxpl_id) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); @@ -1352,7 +1352,7 @@ H5AC__propagate_flushed_and_still_clean_entries_list(H5F_t *f, hid_t dxpl_id) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); @@ -1477,7 +1477,7 @@ H5AC__receive_and_apply_clean_list(H5F_t *f, hid_t dxpl_id) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank != 0); @@ -1537,7 +1537,7 @@ H5AC__receive_candidate_list(const H5AC_t *cache_ptr, int *num_entries_ptr, /* Sanity checks */ HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->mpi_rank != 0); @@ -1621,7 +1621,7 @@ H5AC__rsp__dist_md_write__flush(H5F_t *f, hid_t dxpl_id) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); @@ -1761,7 +1761,7 @@ H5AC__rsp__dist_md_write__flush_to_min_clean(H5F_t *f, hid_t dxpl_id) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); @@ -1836,7 +1836,7 @@ H5AC__rsp__p0_only__flush(H5F_t *f, hid_t dxpl_id) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); @@ -1938,7 +1938,7 @@ H5AC__rsp__p0_only__flush_to_min_clean(H5F_t *f, hid_t dxpl_id) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY); @@ -2047,7 +2047,7 @@ H5AC__run_sync_point(H5F_t *f, hid_t dxpl_id, int sync_point_op) HDassert(f != NULL); cache_ptr = f->shared->cache; HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert((sync_point_op == H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) || @@ -2171,7 +2171,7 @@ H5AC__tidy_cache_0_lists(H5AC_t *cache_ptr, int num_candidates, /* Sanity checks */ HDassert(cache_ptr != NULL); - aux_ptr = H5C_get_aux_ptr(cache_ptr); + aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); HDassert(aux_ptr != NULL); HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC); HDassert(aux_ptr->metadata_write_strategy == H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED); diff --git a/src/H5C.c b/src/H5C.c index c78c32c..90609b5 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -456,8 +456,6 @@ H5C_create(size_t max_cache_size, HDassert( max_type_id < H5C__MAX_NUM_TYPE_IDS ); HDassert( type_name_table_ptr ); - HDassert( ( write_permitted == TRUE ) || ( write_permitted == FALSE ) ); - for ( i = 0; i <= max_type_id; i++ ) { HDassert( (type_name_table_ptr)[i] ); @@ -1752,7 +1750,7 @@ H5C_insert_entry(H5F_t * f, void * thing, unsigned int flags) { - H5C_t * cache_ptr; + H5C_t *cache_ptr; H5P_genplist_t *dxpl; H5AC_ring_t ring = H5C_RING_UNDEFINED; hbool_t insert_pinned; @@ -1763,8 +1761,8 @@ H5C_insert_entry(H5F_t * f, hbool_t set_flush_marker; hbool_t write_permitted = TRUE; size_t empty_space; - H5C_cache_entry_t * entry_ptr; - H5C_cache_entry_t * test_entry_ptr; + H5C_cache_entry_t *entry_ptr; + H5C_cache_entry_t *test_entry_ptr; unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1991,11 +1989,8 @@ H5C_insert_entry(H5F_t * f, #if H5C_DO_EXTREME_SANITY_CHECKS if ( ( H5C_validate_protected_entry_list(cache_ptr) < 0 ) || ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || - ( H5C_validate_lru_list(cache_ptr) < 0 ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "an extreme sanity check failed just before done.\n"); - } + ( H5C_validate_lru_list(cache_ptr) < 0 ) ) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed just before done.\n") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ /* If the entry's type has a 'notify' callback send a 'after insertion' @@ -2008,19 +2003,14 @@ H5C_insert_entry(H5F_t * f, H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) done: - #if H5C_DO_EXTREME_SANITY_CHECKS if ( ( H5C_validate_protected_entry_list(cache_ptr) < 0 ) || ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || - ( H5C_validate_lru_list(cache_ptr) < 0 ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "an extreme sanity check failed on exit.\n"); - } + ( H5C_validate_lru_list(cache_ptr) < 0 ) ) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "an extreme sanity check failed on exit.\n") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_insert_entry() */ @@ -2589,7 +2579,6 @@ H5C_protect(H5F_t * f, unsigned flags) { H5C_t * cache_ptr; - H5P_genplist_t *dxpl; H5AC_ring_t ring = H5C_RING_UNDEFINED; hbool_t hit; hbool_t have_write_permitted = FALSE; @@ -2602,6 +2591,7 @@ H5C_protect(H5F_t * f, size_t empty_space; void * thing; H5C_cache_entry_t * entry_ptr; + H5P_genplist_t * dxpl; /* dataset transfer property list */ void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -2692,7 +2682,6 @@ H5C_protect(H5F_t * f, } entry_ptr = (H5C_cache_entry_t *)thing; - entry_ptr->ring = ring; /* Apply tag to newly protected entry */ @@ -2936,11 +2925,8 @@ done: #if H5C_DO_EXTREME_SANITY_CHECKS if ( ( H5C_validate_protected_entry_list(cache_ptr) < 0 ) || ( H5C_validate_pinned_entry_list(cache_ptr) < 0 ) || - ( H5C_validate_lru_list(cache_ptr) < 0 ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, \ - "an extreme sanity check failed on exit.\n"); - } + ( H5C_validate_lru_list(cache_ptr) < 0 ) ) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "an extreme sanity check failed on exit.\n") #endif /* H5C_DO_EXTREME_SANITY_CHECKS */ FUNC_LEAVE_NOAPI(ret_value) @@ -3279,23 +3265,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5C_set_evictions_enabled(H5C_t *cache_ptr, - hbool_t evictions_enabled) +H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) { - + if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.") - } - - if ( ( evictions_enabled != TRUE ) && ( evictions_enabled != FALSE ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Bad evictions_enabled on entry.") - } /* There is no fundamental reason why we should not permit * evictions to be disabled while automatic resize is enabled. @@ -3303,20 +3280,15 @@ H5C_set_evictions_enabled(H5C_t *cache_ptr, * want to, and allowing it would greatly complicate testing * the feature. Hence the following: */ - if ( ( evictions_enabled != TRUE ) && - ( ( cache_ptr->resize_ctl.incr_mode != H5C_incr__off ) || - ( cache_ptr->resize_ctl.decr_mode != H5C_decr__off ) ) ) { - - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \ - "Can't disable evictions when auto resize enabled.") - } + if((evictions_enabled != TRUE) && + ((cache_ptr->resize_ctl.incr_mode != H5C_incr__off) || + (cache_ptr->resize_ctl.decr_mode != H5C_decr__off))) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't disable evictions when auto resize enabled.") cache_ptr->evictions_enabled = evictions_enabled; done: - FUNC_LEAVE_NOAPI(ret_value) - } /* H5C_set_evictions_enabled() */ @@ -4679,27 +4651,14 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, if ( (tests & H5C_RESIZE_CFG__VALIDATE_GENERAL) != 0 ) { - if ( ( config_ptr->set_initial_size != TRUE ) && - ( config_ptr->set_initial_size != FALSE ) ) { + if(config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "max_size too big") - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "set_initial_size must be either TRUE or FALSE"); - } - - if ( config_ptr->max_size > H5C__MAX_MAX_CACHE_SIZE ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "max_size too big"); - } + if(config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size too small") - if ( config_ptr->min_size < H5C__MIN_MAX_CACHE_SIZE ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size too small"); - } - - if ( config_ptr->min_size > config_ptr->max_size ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size > max_size"); - } + if(config_ptr->min_size > config_ptr->max_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "min_size > max_size") if ( ( config_ptr->set_initial_size ) && ( ( config_ptr->initial_size < config_ptr->min_size ) || @@ -4738,25 +4697,12 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, if ( config_ptr->incr_mode == H5C_incr__threshold ) { - if ( ( config_ptr->lower_hr_threshold < (double)0.0f ) || - ( config_ptr->lower_hr_threshold > (double)1.0f ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "lower_hr_threshold must be in the range [0.0, 1.0]"); - } - - if ( config_ptr->increment < (double)1.0f ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "increment must be greater than or equal to 1.0"); - } - - if ( ( config_ptr->apply_max_increment != TRUE ) && - ( config_ptr->apply_max_increment != FALSE ) ) { + if((config_ptr->lower_hr_threshold < (double)0.0f) || + (config_ptr->lower_hr_threshold > (double)1.0f)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "lower_hr_threshold must be in the range [0.0, 1.0]") - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "apply_max_increment must be either TRUE or FALSE"); - } + if(config_ptr->increment < (double)1.0f) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "increment must be greater than or equal to 1.0") /* no need to check max_increment, as it is a size_t, * and thus must be non-negative. @@ -4834,26 +4780,13 @@ H5C_validate_resize_config(H5C_auto_size_ctl_t * config_ptr, "epochs_before_eviction must be positive"); } - if ( config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS ) { + if(config_ptr->epochs_before_eviction > H5C__MAX_EPOCH_MARKERS) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "epochs_before_eviction too big") - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "epochs_before_eviction too big"); - } - - if ( ( config_ptr->apply_empty_reserve != TRUE ) && - ( config_ptr->apply_empty_reserve != FALSE ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "apply_empty_reserve must be either TRUE or FALSE"); - } - - if ( ( config_ptr->apply_empty_reserve ) && - ( ( config_ptr->empty_reserve > (double)1.0f ) || - ( config_ptr->empty_reserve < (double)0.0f ) ) ) { - - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, \ - "empty_reserve must be in the interval [0.0, 1.0]"); - } + if((config_ptr->apply_empty_reserve) && + ((config_ptr->empty_reserve > (double)1.0f) || + (config_ptr->empty_reserve < (double)0.0f))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "empty_reserve must be in the interval [0.0, 1.0]") /* no need to check max_decrement as it is a size_t * and thus must be non-negative. @@ -6041,7 +5974,6 @@ H5C__autoadjust__ageout__evict_aged_out_entries(H5F_t * f, prev_ptr = entry_ptr->prev; if ( ! (entry_ptr->is_dirty) ) { - if(H5C__flush_single_entry(f, dxpl_id, entry_ptr, H5C__FLUSH_INVALIDATE_FLAG | H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG, NULL) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush clean entry") } @@ -8440,7 +8372,7 @@ H5C_load_entry(H5F_t * f, #endif /* H5C_DO_MEMORY_SANITY_CHECKS */ /* Get the on-disk entry image */ - if ( 0 == (type->flags & H5C__CLASS_SKIP_READS) ) + if(0 == (type->flags & H5C__CLASS_SKIP_READS)) if(H5F_block_read(f, type->mem_type, addr, len, dxpl_id, image) < 0) HGOTO_ERROR(H5E_CACHE, H5E_READERROR, NULL, "Can't read image*") @@ -8548,17 +8480,12 @@ H5C_load_entry(H5F_t * f, /* Go get the on-disk image again */ if(H5F_block_read(f, type->mem_type, addr, new_len, dxpl_id, image) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't read image") - /* Deserialize on-disk image into native memory - * form again - */ + /* Deserialize on-disk image into native memory form again */ if(NULL == (thing = type->deserialize(image, new_len, udata, &dirty))) - - HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, \ - "Can't deserialize image") + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "Can't deserialize image") #ifndef NDEBUG { diff --git a/src/H5D.c b/src/H5D.c index 3efae8e..0fe6c4d 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -109,6 +109,7 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5G_loc_t loc; /* Object location to insert dataset into */ H5D_t *dset = NULL; /* New dataset's info */ const H5S_t *space; /* Dataspace for dataset */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -145,7 +146,7 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") /* Create the new dataset & get its ID */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id, H5AC_dxpl_id))) + if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") @@ -201,6 +202,7 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, H5G_loc_t loc; /* Object location to insert dataset into */ H5D_t *dset = NULL; /* New dataset's info */ const H5S_t *space; /* Dataspace for dataset */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -227,7 +229,7 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") /* build and open the new dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, H5AC_dxpl_id))) + if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") /* Register the new dataset to get an ID for it */ @@ -244,7 +246,7 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get object location of dataset") /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) + if(H5O_dec_rc_by_loc(oloc, dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") } /* end if */ @@ -310,7 +312,6 @@ done: if(ret_value < 0) if(dset && H5D_close(dset) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") - FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ diff --git a/src/H5F.c b/src/H5F.c index 041bd35..da08de4 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -447,7 +447,8 @@ hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_t *new_file = NULL; /*file struct for new file */ - hid_t ret_value; /*return value */ + hid_t dxpl_id = H5AC_dxpl_id; /*dxpl used by library */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(FAIL) H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id); @@ -490,7 +491,7 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* * Create a new file or truncate an existing file. */ - if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) + if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") /* Get an atom for the file */ @@ -553,7 +554,8 @@ hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { H5F_t *new_file = NULL; /*file struct for new file */ - hid_t ret_value; /*return value */ + hid_t dxpl_id = H5AC_dxpl_id; /*dxpl used by library */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "*sIui", filename, flags, fapl_id); @@ -572,7 +574,7 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* Open the file */ - if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") /* Get an atom for the file */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index b3ef1f2..d0e2171 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -1436,7 +1436,7 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t H5_ATTR_UNUSED type, hid_t dxpl_id, had #endif /* Only look for MPI views for raw data transfers */ - if(type==H5FD_MEM_DRAW) { + if(type == H5FD_MEM_DRAW) { H5FD_mpio_xfer_t xfer_mode; /* I/O tranfer mode */ /* Obtain the data transfer properties */ @@ -1793,6 +1793,7 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, if(H5FD_mpio_Debug[(int)'t']) fprintf(stdout, "H5FD_mpio_write: using MPIO collective mode\n"); #endif + /* Get the collective_opt property to check whether the application wants to do IO individually. */ HDassert(plist); /* get the transfer mode from the dxpl */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index aa6cc2a..122f711 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -32,6 +32,14 @@ #define H5CHECK #endif /* _H5private_H */ +/* When this header is included from a private HDF5 header, don't make calls to H5open() */ +#undef H5OPEN +#ifndef _H5private_H +#define H5OPEN H5open(), +#else /* _H5private_H */ +#define H5OPEN +#endif /* _H5private_H */ + /* * These are the bits that can be passed to the `flags' argument of * H5Fcreate() and H5Fopen(). Use the bit-wise OR operator (|) to combine @@ -44,16 +52,16 @@ * Note that H5F_ACC_DEBUG is deprecated (nonfuncational) but retained as a * symbol for backward compatibility. */ -#define H5F_ACC_RDONLY (H5CHECK 0x0000u) /*absence of rdwr => rd-only */ -#define H5F_ACC_RDWR (H5CHECK 0x0001u) /*open for read and write */ -#define H5F_ACC_TRUNC (H5CHECK 0x0002u) /*overwrite existing files */ -#define H5F_ACC_EXCL (H5CHECK 0x0004u) /*fail if file already exists*/ +#define H5F_ACC_RDONLY (H5CHECK H5OPEN 0x0000u) /*absence of rdwr => rd-only */ +#define H5F_ACC_RDWR (H5CHECK H5OPEN 0x0001u) /*open for read and write */ +#define H5F_ACC_TRUNC (H5CHECK H5OPEN 0x0002u) /*overwrite existing files */ +#define H5F_ACC_EXCL (H5CHECK H5OPEN 0x0004u) /*fail if file already exists*/ /* NOTE: 0x0008u was H5F_ACC_DEBUG, now deprecated */ -#define H5F_ACC_CREAT (H5CHECK 0x0010u) /*create non-existing files */ +#define H5F_ACC_CREAT (H5CHECK H5OPEN 0x0010u) /*create non-existing files */ /* Value passed to H5Pset_elink_acc_flags to cause flags to be taken from the * parent file. */ -#define H5F_ACC_DEFAULT (H5CHECK 0xffffu) /*ignore setting on lapl */ +#define H5F_ACC_DEFAULT (H5CHECK H5OPEN 0xffffu) /*ignore setting on lapl */ /* Flags for H5Fget_obj_count() & H5Fget_obj_ids() calls */ #define H5F_OBJ_FILE (0x0001u) /* File objects */ @@ -223,7 +231,7 @@ H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); #ifndef H5_NO_DEPRECATED_SYMBOLS /* Macros */ -#define H5F_ACC_DEBUG (H5CHECK 0x0000u) /*print debug info (deprecated)*/ +#define H5F_ACC_DEBUG (H5CHECK H5OPEN 0x0000u) /*print debug info (deprecated)*/ /* Typedefs */ diff --git a/src/H5G.c b/src/H5G.c index 03fe50a..00a53b8 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -290,6 +290,7 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, { H5G_loc_t loc; /* Location to create group */ H5G_t *grp = NULL; /* New group created */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -323,7 +324,7 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, H5AC_dxpl_id))) + if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") @@ -378,6 +379,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) H5G_loc_t loc; H5G_t *grp = NULL; H5G_obj_create_t gcrt_info; /* Information for group creation */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -407,7 +409,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info, H5AC_dxpl_id))) + if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") @@ -422,7 +424,7 @@ done: HDONE_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object location of group") /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) + if(H5O_dec_rc_by_loc(oloc, dxpl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") } /* end if */ @@ -457,6 +459,7 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { H5G_t *grp = NULL; /* Group opened */ H5G_loc_t loc; /* Location of parent for group */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -476,7 +479,7 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") /* Open the group */ - if((grp = H5G__open_name(&loc, name, gapl_id, H5AC_ind_dxpl_id)) == NULL) + if((grp = H5G__open_name(&loc, name, gapl_id, dxpl_id)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an ID for the group */ @@ -595,6 +598,7 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, H5G_name_t grp_path; /* Opened object group hier. path */ H5O_loc_t grp_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -619,12 +623,12 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, H5G_loc_reset(&grp_loc); /* Find the group object */ - if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: @@ -658,6 +662,7 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_name_t grp_path; /* Opened object group hier. path */ H5O_loc_t grp_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -687,12 +692,13 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_loc_reset(&grp_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, + lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: diff --git a/src/H5L.c b/src/H5L.c index 9daf948..264c00e 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -336,6 +336,7 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, { H5G_loc_t src_loc, *src_loc_p; H5G_loc_t dst_loc, *dst_loc_p; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -366,7 +367,7 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Move the link */ if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, lcpl_id, - lapl_id, H5AC_dxpl_id) < 0) + lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: @@ -394,6 +395,7 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, { H5G_loc_t src_loc, *src_loc_p; H5G_loc_t dst_loc, *dst_loc_p; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -424,7 +426,7 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Copy the link */ if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, TRUE, lcpl_id, - lapl_id, H5AC_dxpl_id) < 0) + lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: @@ -455,6 +457,7 @@ H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { H5G_loc_t link_loc; /* Group location for new link */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -471,7 +474,7 @@ H5Lcreate_soft(const char *link_target, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Create the link */ - if(H5L_create_soft(link_target, &link_loc, link_name, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + if(H5L_create_soft(link_target, &link_loc, link_name, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -501,6 +504,7 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, { H5G_loc_t cur_loc, *cur_loc_p; H5G_loc_t new_loc, *new_loc_p; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -533,7 +537,7 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, /* Create the link */ if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, - lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -570,6 +574,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id) { H5G_loc_t link_loc; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -585,7 +590,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") /* Create external link */ - if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -614,6 +619,7 @@ herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) { H5G_loc_t loc; /* Group's location */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -626,7 +632,7 @@ H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Unlink */ - if(H5L_delete(&loc, name, lapl_id, H5AC_dxpl_id) < 0) + if(H5L_delete(&loc, name, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -659,6 +665,7 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, { H5G_loc_t loc; /* Group's location */ H5L_trav_rmbi_t udata; /* User data for callback */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -686,7 +693,8 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, udata.dxpl_id = H5AC_dxpl_id; /* Traverse the group hierarchy to remove the link */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, H5L_delete_by_idx_cb, &udata, lapl_id, H5AC_dxpl_id) < 0) + if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, + H5L_delete_by_idx_cb, &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") done: @@ -718,6 +726,7 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, hid_t lapl_id) { H5G_loc_t loc; /* Group location for location to query */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -735,7 +744,7 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Get the link value */ - if(H5L_get_val(&loc, name, buf, size, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5L_get_val(&loc, name, buf, size, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value for '%s'", name) done: @@ -768,6 +777,7 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, { H5G_loc_t loc; /* Group location for location to query */ H5L_trav_gvbi_t udata; /* User data for callback */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -793,12 +803,13 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, udata.idx_type = idx_type; udata.order = order; udata.n = n; - udata.dxpl_id = H5AC_ind_dxpl_id; + udata.dxpl_id = dxpl_id; udata.buf = buf; udata.size = size; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L_get_val_by_idx_cb, &udata, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L_get_val_by_idx_cb, + &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") @@ -824,6 +835,7 @@ htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { H5G_loc_t loc; + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ htri_t ret_value; FUNC_ENTER_API(FAIL) @@ -841,7 +853,7 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Check for the existence of the link */ - if((ret_value = H5L__exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5L__exists(&loc, name, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") done: @@ -868,6 +880,7 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, hid_t lapl_id) { H5G_loc_t loc; + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) @@ -885,7 +898,7 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Get the link information */ - if(H5L_get_info(&loc, name, linfo, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5L_get_info(&loc, name, linfo, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") done: @@ -914,6 +927,7 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, { H5G_loc_t loc; /* Group location for group to query */ H5L_trav_gibi_t udata; /* User data for callback */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -939,11 +953,12 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, udata.idx_type = idx_type; udata.order = order; udata.n = n; - udata.dxpl_id = H5AC_ind_dxpl_id; + udata.dxpl_id = dxpl_id; udata.linfo = linfo; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_info_by_idx_cb, &udata, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, + H5L_get_info_by_idx_cb, &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") @@ -1103,6 +1118,7 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, { H5G_loc_t loc; /* Location of group */ H5L_trav_gnbi_t udata; /* User data for callback */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1128,13 +1144,14 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, udata.idx_type = idx_type; udata.order = order; udata.n = n; - udata.dxpl_id = H5AC_ind_dxpl_id; + udata.dxpl_id = dxpl_id; udata.name = name; udata.size = size; udata.name_len = -1; /* Traverse the group hierarchy to locate the link to get name of */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_name_by_idx_cb, &udata, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, + H5L_get_name_by_idx_cb, &udata, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") /* Set the return value */ @@ -1242,6 +1259,7 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_lnk; /* Index of last object looked at */ hsize_t idx; /* Internal location to hold index */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1272,7 +1290,8 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, lnk_op.op_func.op_new = op; /* Iterate over the links */ - if((ret_value = H5G_iterate(loc_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_iterate(loc_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, + op_data, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") /* Set the index we stopped at */ @@ -1374,6 +1393,7 @@ herr_t H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id) { + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1396,7 +1416,7 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Call internal group visitation routine */ - if((ret_value = H5G_visit(loc_id, group_name, idx_type, order, op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_visit(loc_id, group_name, idx_type, order, op, op_data, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") done: diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 139c5e6..324f2bf 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -563,6 +563,7 @@ H5Lcreate_external(const char *file_name, const char *obj_name, size_t file_name_len; /* Length of file name string */ size_t norm_obj_name_len; /* Length of normalized object name string */ uint8_t *p; /* Pointer into external link buffer */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -598,7 +599,7 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ /* Create an external link */ - if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: diff --git a/src/H5O.c b/src/H5O.c index 34fe498..46ce5fa 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -282,6 +282,7 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ hid_t ret_value = FAIL; @@ -309,12 +310,12 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: @@ -426,6 +427,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, { H5G_loc_t new_loc; H5G_loc_t obj_loc; + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -449,7 +451,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") /* Link to the object */ - if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -556,6 +558,7 @@ htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { H5G_loc_t loc; /* Location info */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) @@ -573,7 +576,7 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Check if the object exists */ - if((ret_value = H5G_loc_exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_loc_exists(&loc, name, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) done: @@ -635,6 +638,7 @@ herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -654,7 +658,7 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: @@ -685,6 +689,7 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -714,7 +719,7 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") loc_found = TRUE; @@ -792,6 +797,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -809,7 +815,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, name, comment, lapl_id, H5AC_ind_dxpl_id) < 0) + if(H5G_loc_set_comment(&loc, name, comment, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: @@ -876,6 +882,7 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf hid_t lapl_id) { H5G_loc_t loc; /* Location of group */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -893,7 +900,7 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") done: @@ -995,6 +1002,7 @@ herr_t H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id) { + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1017,7 +1025,7 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") /* Call internal object visitation routine */ - if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: diff --git a/src/H5Pint.c b/src/H5Pint.c index 69b2791..443802c 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -1187,7 +1187,7 @@ H5P__find_prop_plist(const H5P_genplist_t *plist, const char *name) /* Check if the property has been deleted from list */ if(H5SL_search(plist->del,name) != NULL) { - HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "can't find property in skip list") + HGOTO_ERROR(H5E_PLIST, H5E_NOTFOUND, NULL, "property deleted from skip list") } /* end if */ else { /* Get the property data from the skip list */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 5ff1c73..0ab3b4e 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -99,6 +99,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, { H5G_loc_t loc; /* Location to create datatype */ H5T_t *type; /* Datatype for ID */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -134,7 +135,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") /* Commit the type */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0) + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") done: @@ -248,6 +249,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) { H5G_loc_t loc; /* Group location for location */ H5T_t *type = NULL; /* Datatype created */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl used by library */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -274,7 +276,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") /* Commit the type */ - if(H5T__commit(loc.oloc->file, type, tcpl_id, H5AC_dxpl_id) < 0) + if(H5T__commit(loc.oloc->file, type, tcpl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Release the datatype's object header */ @@ -286,7 +288,7 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype") /* Decrement refcount on committed datatype's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) + if(H5O_dec_rc_by_loc(oloc, dxpl_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") } /* end if */ -- cgit v0.12 From c09393ed0a2624cc04556249ef5549c2485efe8f Mon Sep 17 00:00:00 2001 From: Larry Knox Date: Thu, 14 Jan 2016 16:56:16 -0500 Subject: [svn-r28902] Remove 3 files in autom4te.cache from MANIFEST. They are generated by autogen.sh and were inadvertently added along with configure and Makefile.in files but are not checked in and should not be installed. Furthermore they are not generated on all systems by autogen.sh and cause chkmanifest to fail when run be release scripts. --- MANIFEST | 3 --- 1 file changed, 3 deletions(-) diff --git a/MANIFEST b/MANIFEST index 4899ab2..eb15f23 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2533,9 +2533,6 @@ # Files generated by autogen ./aclocal.m4 -./autom4te.cache/output.0 -./autom4te.cache/requests -./autom4te.cache/traces.0 ./bin/compile ./bin/config.guess ./bin/config.sub -- cgit v0.12 From 0d68aa89cede07df85eca611510a6271fbbb1d8a Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Fri, 15 Jan 2016 10:53:33 -0500 Subject: [svn-r28905] Purpose: Fix user reported problem Description: User Adam Rosenberger reported a failure when using the member function AbstractDs::getArrayType(). This problem was caused by missing initialization of the ArrayType's members in some cases. Solution: - Added ArrayType::setArrayInfo() to retrieve rank and dimensions of an array and store them in memory for easy access. - Re-factored a few functions to use the new function. - We'll give him 1.8.16 patch Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5AbstractDs.cpp | 3 + c++/src/H5ArrayType.cpp | 123 ++++++++++++------- c++/src/H5ArrayType.h | 3 + c++/src/H5CompType.cpp | 11 +- c++/test/Makefile.am | 7 +- c++/test/h5cpputil.h | 2 + c++/test/tarray.cpp | 312 +++++++++++++++++++++++++++++++++++++++++++++++ c++/test/testhdf5.cpp | 2 +- c++/test/ttypes.cpp | 1 - 9 files changed, 407 insertions(+), 57 deletions(-) create mode 100644 c++/test/tarray.cpp diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 06b3e22..4e9a4d5 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -141,8 +141,11 @@ ArrayType AbstractDs::getArrayType() const // depending on which object invokes getArrayType. Then, create and // return the ArrayType object try { + // Create ArrayType and set values this way to work around the + // problem described in the JIRA issue HDFFV-7947 ArrayType arraytype; f_DataType_setId(&arraytype, p_get_type()); + arraytype.setArrayInfo(); return(arraytype); } catch (DataSetIException E) { diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 85340f8..0f09631 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -35,12 +35,7 @@ namespace H5 { ///\brief Default constructor: Creates a stub ArrayType // Programmer Binh-Minh Ribler - May 2004 //-------------------------------------------------------------------------- -ArrayType::ArrayType() : DataType() -{ - // Initialize members - rank = -1; - dimensions = NULL; -} +ArrayType::ArrayType() : DataType(), rank(-1), dimensions(NULL) {} //-------------------------------------------------------------------------- // Function: ArrayType overloaded constructor @@ -51,20 +46,7 @@ ArrayType::ArrayType() : DataType() //-------------------------------------------------------------------------- ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id ) { - // Get the rank of the existing array and store it in this array - rank = H5Tget_array_ndims(existing_id); - if (rank < 0) - { - throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_ndims failed"); - } - - // Allocate space for the dimensions - dimensions = new hsize_t[rank]; - - // Get the dimensions of the existing array and store it in this array - int ret_value = H5Tget_array_dims2(id, dimensions); - if (ret_value < 0) - throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_dims2 failed"); + setArrayInfo(); } //-------------------------------------------------------------------------- @@ -111,25 +93,67 @@ ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) } //-------------------------------------------------------------------------- +// Function: ArrayType::setArrayInfo +///\brief Retrieves the rank and dimensions from the array datatype +/// and store the info in this ArrayType object. +///\exception H5::DataTypeIException +// Programmer Binh-Minh Ribler - January 2016 +//-------------------------------------------------------------------------- +void ArrayType::setArrayInfo() +{ + // Get the rank of the array type specified by id from the C API + int ndims = H5Tget_array_ndims(id); + if (ndims < 0) + { + throw DataTypeIException("ArrayType::setArrayInfo", "H5Tget_array_ndims failed"); + } + + // Get the dimensions from the C API + hsize_t* dims; + dims = new hsize_t[ndims]; + if (dims != NULL) + { + // Get the dimensions + ndims = H5Tget_array_dims2(id, dims); + if (ndims < 0) + throw DataTypeIException("ArrayType::setArrayInfo", "H5Tget_array_dims2 failed"); + + // Store the array's info in memory + rank = ndims; + dimensions = new hsize_t[rank]; + for (int i = 0; i < rank; i++) + dimensions[i] = dims[i]; + delete []dims; + } +} // setArrayInfo + +//-------------------------------------------------------------------------- // Function: ArrayType::getArrayNDims ///\brief Returns the number of dimensions for an array datatype. ///\return Number of dimensions ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 +// Modification +// Modified to use setArrayInfo(). +// If rank is positive, return rank +// If rank is invalid but object has a valid identifier, obtain the +// rank and dimensions, store them in the object, and return rank +// Otherwise, i.e., rank is invalid and object doesn't have a +// valid identifier, throw an exception //-------------------------------------------------------------------------- int ArrayType::getArrayNDims() { - // If the array's rank has not been stored, i.e. rank is init to -1, - // retrieve it via the C API - if (rank < 0) - { - rank = H5Tget_array_ndims(id); - if (rank < 0) - { - throw DataTypeIException("ArrayType::getArrayNDims", "H5Tget_array_ndims failed"); - } - } - return(rank); + // Validate the id first, this object could be a default object + if (!p_valid_id(id)) + throw DataTypeIException("ArrayType::getArrayNDims", "ArrayType object is not a valid array type."); + + // If the array's info has not been stored, i.e. "rank" still has its + // initial value, -1, and "dimensions" is still NULL, retrieve rank and + // dimensions via the C API and store them in this ArrayType object. + if (rank < 0 && dimensions == NULL) + setArrayInfo(); + + return(rank); } //-------------------------------------------------------------------------- @@ -139,25 +163,30 @@ int ArrayType::getArrayNDims() ///\return Number of dimensions ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - May 2004 +// Modification +// Jan, 2016 +// Modified to use setArrayInfo(). +// If the array information has not been stored, retrieve rank and +// dimensions of the array type identified by "id" via the C API. +// Copy "dimensions" to the user's buffer //-------------------------------------------------------------------------- int ArrayType::getArrayDims(hsize_t* dims) { - // If the array's dimensions have not been stored, retrieve them via C API - if (dimensions == NULL) - { - int ndims = H5Tget_array_dims2(id, dims); - if (ndims < 0) - throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); - // Store the array's info in memory - rank = ndims; - dimensions = new hsize_t[rank]; - for (int i = 0; i < rank; i++) - dimensions[i] = dims[i]; - } - // Otherwise, simply copy what's in 'dimensions' to 'dims' - for (int i = 0; i < rank; i++) - dims[i] = dimensions[i]; - return(rank); + // Validate the id first, this object could be a default object + if (!p_valid_id(id)) + throw DataTypeIException("ArrayType::getArrayDims", "ArrayType object is not a valid array type."); + + // If the array's info has not been stored, i.e. "rank" still has its + // initial value, -1, and "dimensions" is still NULL, retrieve rank and + // dimensions via the C API and store them in this ArrayType object. + if (rank < 0 && dimensions == NULL) + setArrayInfo(); + + // Copy what's in "dimensions" to user's buffer "dims" + for (int i = 0; i < rank; i++) + dims[i] = dimensions[i]; + + return(rank); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5ArrayType.h b/c++/src/H5ArrayType.h index 6577a6e..c0f4b38 100644 --- a/c++/src/H5ArrayType.h +++ b/c++/src/H5ArrayType.h @@ -31,6 +31,9 @@ class H5_DLLCPP ArrayType : public DataType { // specified base type. ArrayType(const DataType& base_type, int ndims, const hsize_t* dims); + // Stores the rank and dimensions in memory. + void setArrayInfo(); + // Returns the number of dimensions of this array datatype. int getArrayNDims(); diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 6d31a68..82575d6 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -228,12 +228,12 @@ hid_t CompType::p_get_member_type(unsigned member_num) const DataType CompType::getMemberDataType( unsigned member_num ) const { try { - DataType datatype; + DataType datatype; f_DataType_setId(&datatype, p_get_member_type(member_num)); - return(datatype); + return(datatype); } catch (DataTypeIException E) { - throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); + throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); } } @@ -249,9 +249,10 @@ DataType CompType::getMemberDataType( unsigned member_num ) const ArrayType CompType::getMemberArrayType( unsigned member_num ) const { try { - ArrayType arraytype(p_get_member_type(member_num)); + ArrayType arraytype; f_DataType_setId(&arraytype, p_get_member_type(member_num)); - return(arraytype); + arraytype.setArrayInfo(); + return(arraytype); } catch (DataTypeIException E) { throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); diff --git a/c++/test/Makefile.am b/c++/test/Makefile.am index 705ec72..07fe533 100644 --- a/c++/test/Makefile.am +++ b/c++/test/Makefile.am @@ -31,9 +31,10 @@ check_PROGRAMS=$(TEST_PROG) # The tests depend on the hdf5 library, test library, and the c++ library LDADD=$(LIBH5TEST) $(LIBH5CPP) $(LIBHDF5) -testhdf5_SOURCES=testhdf5.cpp dsets.cpp tattr.cpp tcompound.cpp \ - tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp tlinks.cpp tobject.cpp \ - trefer.cpp ttypes.cpp tvlstr.cpp h5cpputil.cpp +testhdf5_SOURCES=testhdf5.cpp dsets.cpp tattr.cpp tarray.cpp \ + tcompound.cpp tdspl.cpp tfile.cpp tfilter.cpp th5s.cpp \ + tlinks.cpp tobject.cpp trefer.cpp ttypes.cpp tvlstr.cpp \ + h5cpputil.cpp # Tell conclude.am that these are C++ tests. CXX_API=yes diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h index 8625213..b615194 100644 --- a/c++/test/h5cpputil.h +++ b/c++/test/h5cpputil.h @@ -132,6 +132,7 @@ template #ifdef __cplusplus extern "C" { #endif +void test_array(); void test_attr(); void test_compound(); void test_dsproplist(); @@ -146,6 +147,7 @@ void test_vlstrings(); void test_dset(); /* Prototypes for the cleanup routines */ +void cleanup_array(); void cleanup_attr(); void cleanup_compound(); void cleanup_dsproplist(); diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp new file mode 100644 index 0000000..69b4438 --- /dev/null +++ b/c++/test/tarray.cpp @@ -0,0 +1,312 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/***************************************************************************** + FILE + tarray.cpp - HDF5 C++ testing the array datatype functionality + + ***************************************************************************/ + +#ifdef OLD_HEADER_FILENAME +#include +#else +#include +#endif +#include + +#ifndef H5_NO_NAMESPACE +#ifndef H5_NO_STD + using std::cerr; + using std::endl; +#endif // H5_NO_STD +#endif + +#include "H5Cpp.h" // C++ API header file + +#ifndef H5_NO_NAMESPACE + using namespace H5; +#endif + +#include "h5cpputil.h" // C++ utilility header file + +const H5std_string FILENAME("tarray.h5"); +const hsize_t SPACE1_RANK = 1; +const hsize_t SPACE1_DIM1 = 4; +const hsize_t ARRAY1_RANK = 1; +const hsize_t ARRAY1_DIM1 = 4; + +typedef enum flt_t { + FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, FLT_OTHER +} flt_t; + +typedef enum int_t { + INT_CHAR, INT_UCHAR, INT_SHORT, INT_USHORT, INT_INT, INT_UINT, + INT_LONG, INT_ULONG, INT_LLONG, INT_ULLONG, INT_OTHER +} int_t; + + +/*------------------------------------------------------------------------- + * Function: test_array_compound_array + * + * Purpose: Tests 1-D array of compound datatypes (with array fields) + * + * Return: None. + * + * Programmer: Binh-Minh Ribler (using C version) + * January, 2016 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static void test_array_compound_array() +{ + SUBTEST("ArrayType::getArrayNDims & ArrayType::getArrayDims"); + typedef struct { // Typedef for compound datatype */ + int i; + float f[ARRAY1_DIM1]; + } s1_t; + s1_t wdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information to write + s1_t rdata[SPACE1_DIM1][ARRAY1_DIM1]; // Information read in + hsize_t sdims1[] = {SPACE1_DIM1}; + hsize_t tdims1[] = {ARRAY1_DIM1}; + int nmemb; // Number of compound members + int ii, jj, kk; // counting variables + H5T_class_t mclass; // Datatype class for field + + // Initialize array data to write + for (ii =0; ii < SPACE1_DIM1; ii++) + for (jj = 0; jj < ARRAY1_DIM1; jj++) { + wdata[ii][jj].i = ii * 10 + jj; + for(kk = 0; kk < ARRAY1_DIM1; kk++) + wdata[ii][jj].f[kk]=(float)(ii * 10.0F + jj * 2.5F + kk); + } // end for + + try { + // Create File + H5File file1(FILENAME, H5F_ACC_TRUNC); + + // Create dataspace for datasets + DataSpace space(SPACE1_RANK, sdims1, NULL); + + /* + * Create an array datatype of compounds, arrtype. Each compound + * datatype, comptype, contains an integer and an array of floats, + * arrfltype. + */ + + // Create a compound datatype + CompType comptype(sizeof(s1_t)); + + // Insert integer field + comptype.insertMember("i", HOFFSET(s1_t, i), PredType::NATIVE_INT); + + // Create an array of floats datatype + ArrayType arrfltype(PredType::NATIVE_FLOAT, ARRAY1_RANK, tdims1); + + // Insert float array field + comptype.insertMember("f", HOFFSET(s1_t, f), arrfltype); + + // Close array of floats field datatype + arrfltype.close(); + + // Create an array datatype of the compound datatype + ArrayType arrtype(comptype, ARRAY1_RANK, tdims1); + + // Close compound datatype comptype + comptype.close(); + + // Create a dataset + DataSet dataset = file1.createDataSet("Dataset1", arrtype, space); + + // Write dataset to disk + dataset.write(wdata, arrtype); + + // Close all + dataset.close(); + arrtype.close(); + space.close(); + file1.close(); + + // Re-open file + file1.openFile(FILENAME, H5F_ACC_RDONLY); + + // Open the dataset + dataset = file1.openDataSet("Dataset1"); + + /* + * Check the datatype array of compounds + */ + + // Verify that it is an array of compounds + DataType dstype = dataset.getDataType(); + mclass = dstype.getClass(); + verify_val(mclass, H5T_ARRAY, "f2_type.getClass", __LINE__, __FILE__); + dstype.close(); + + // Get the array datatype to check + ArrayType atype_check = dataset.getArrayType(); + + // Check the array rank + int ndims = atype_check.getArrayNDims(); + verify_val(ndims, ARRAY1_RANK, "atype_check.getArrayNDims", __LINE__, __FILE__); + + // Get the array dimensions + hsize_t rdims1[H5S_MAX_RANK]; + atype_check.getArrayDims(rdims1); + + // Check the array dimensions + for (ii =0; ii Date: Fri, 15 Jan 2016 10:57:00 -0500 Subject: [svn-r28906] Description: Added c++/test/tarray.cpp. --- MANIFEST | 1 + c++/test/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/MANIFEST b/MANIFEST index eb15f23..42a1736 100644 --- a/MANIFEST +++ b/MANIFEST @@ -381,6 +381,7 @@ ./c++/test/dsets.cpp ./c++/test/h5cpputil.cpp ./c++/test/h5cpputil.h +./c++/test/tarray.cpp ./c++/test/tattr.cpp ./c++/test/tcompound.cpp ./c++/test/tdspl.cpp diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index 6f1d857..4bebeac 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -13,6 +13,7 @@ PROJECT (HDF5_CPP_TEST) #----------------------------------------------------------------------------- set (CPP_TEST_SRCS ${HDF5_CPP_TEST_SOURCE_DIR}/testhdf5.cpp + ${HDF5_CPP_TEST_SOURCE_DIR}/tarray.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tattr.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tcompound.cpp ${HDF5_CPP_TEST_SOURCE_DIR}/tdspl.cpp -- cgit v0.12 From 8db372877985017e6e9b8eeff543a11471c10248 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 15 Jan 2016 18:08:10 -0500 Subject: [svn-r28916] Description: Normalize against incoming changes from the phdf5_metadata_opt branch. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- src/H5A.c | 126 ++++++++++++++++++++++++++++++++---------------------- src/H5D.c | 27 ++++-------- src/H5F.c | 18 +++----- src/H5G.c | 45 ++++++++----------- src/H5L.c | 116 +++++++++++++++++++++++++++---------------------- src/H5Lexternal.c | 4 ++ src/H5O.c | 69 ++++++++++++++---------------- src/H5Pfapl.c | 14 ++++-- src/H5Pint.c | 75 +++++++++++++++++++++++++++++++- src/H5Ppkg.h | 27 ------------ src/H5Pprivate.h | 45 ++++++++++++++++--- src/H5Ppublic.h | 4 ++ src/H5Tcommit.c | 27 ++++-------- 13 files changed, 346 insertions(+), 251 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index 97d082c..e478610 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -246,7 +246,7 @@ H5A_term_package(void) --------------------------------------------------------------------------*/ hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, - hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id) + hid_t acpl_id, hid_t aapl_id) { H5A_t *attr = NULL; /* Attribute created */ H5G_loc_t loc; /* Object location */ @@ -272,6 +272,10 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Go do the real work for attaching the attribute to the object */ if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") @@ -321,7 +325,7 @@ done: --------------------------------------------------------------------------*/ hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { H5A_t *attr = NULL; /* Attribute created */ @@ -360,14 +364,22 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, obj_loc.path = &obj_path; H5G_loc_reset(&obj_loc); - /* Find the object's location */ + /* Verify access property list and get correct dxpl */ dxpl_id = H5AC_ind_dxpl_id; + if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + + /* Find the object's location */ if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; - /* Go do the real work for attaching the attribute to the dataset */ + /* Verify access property list and get correct dxpl */ dxpl_id = H5AC_dxpl_id; + if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + + /* Go do the real work for attaching the attribute to the dataset */ if(NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") @@ -405,7 +417,7 @@ done: H5Aclose or resource leaks will develop. --------------------------------------------------------------------------*/ hid_t -H5Aopen(hid_t loc_id, const char *attr_name, hid_t H5_ATTR_UNUSED aapl_id) +H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute opened */ @@ -423,6 +435,10 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t H5_ATTR_UNUSED aapl_id) if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Read in attribute from object header */ if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name) @@ -468,7 +484,7 @@ done: --------------------------------------------------------------------------*/ hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t H5_ATTR_UNUSED aapl_id, hid_t lapl_id) + hid_t aapl_id, hid_t lapl_id) { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute opened */ @@ -493,6 +509,10 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Open the attribute on the object header */ if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") @@ -537,7 +557,7 @@ done: --------------------------------------------------------------------------*/ hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, hid_t H5_ATTR_UNUSED aapl_id, hid_t lapl_id) + H5_iter_order_t order, hsize_t n, hid_t aapl_id, hid_t lapl_id) { H5A_t *attr = NULL; /* Attribute opened */ H5G_loc_t loc; /* Object location */ @@ -565,6 +585,10 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Open the attribute in the object header */ if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") @@ -892,11 +916,10 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Open the attribute on the object header */ if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) @@ -1030,11 +1053,10 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") if(NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Open the attribute on the object header */ if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, dxpl_id))) @@ -1093,11 +1115,10 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(NULL == ainfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid info pointer") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Open the attribute on the object header */ if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, dxpl_id))) @@ -1193,11 +1214,10 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no old attribute name") if(!new_attr_name || !*new_attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new attribute name") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_attr_name, new_attr_name)) { @@ -1370,11 +1390,10 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -1496,11 +1515,11 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + dxpl_id = H5AC_ind_dxpl_id; + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -1508,13 +1527,16 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5G_loc_reset(&obj_loc); /* Find the object's location */ - dxpl_id = H5AC_ind_dxpl_id; if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; - /* Delete the attribute from the location */ + /* Verify access property list and get correct dxpl */ dxpl_id = H5AC_dxpl_id; + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + + /* Delete the attribute from the location */ if(H5O_attr_remove(obj_loc.oloc, attr_name, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") @@ -1577,11 +1599,11 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + dxpl_id = H5AC_ind_dxpl_id; + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -1589,13 +1611,16 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5G_loc_reset(&obj_loc); /* Find the object's location */ - dxpl_id = H5AC_ind_dxpl_id; if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; - /* Delete the attribute from the location */ + /* Verify access property list and get correct dxpl */ dxpl_id = H5AC_dxpl_id; + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + + /* Delete the attribute from the location */ if(H5O_attr_remove_by_idx(obj_loc.oloc, idx_type, order, n, dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") @@ -1717,11 +1742,10 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") if((ret_value = H5A_exists_by_name(loc, obj_name, attr_name, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") diff --git a/src/H5D.c b/src/H5D.c index 0fe6c4d..d8653a9 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -138,12 +138,9 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") - /* Get correct property list */ - if(H5P_DEFAULT == dapl_id) - dapl_id = H5P_DATASET_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&dapl_id, H5P_CLS_DACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Create the new dataset & get its ID */ if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id, dxpl_id))) @@ -221,12 +218,9 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") - /* Get correct property list */ - if(H5P_DEFAULT == dapl_id) - dapl_id = H5P_DATASET_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&dapl_id, H5P_CLS_DACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* build and open the new dataset */ if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, dxpl_id))) @@ -293,12 +287,9 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Get correct property list */ - if(H5P_DEFAULT == dapl_id) - dapl_id = H5P_DATASET_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&dapl_id, H5P_CLS_DACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Open the dataset */ if(NULL == (dset = H5D__open_name(&loc, name, dapl_id, dxpl_id))) diff --git a/src/H5F.c b/src/H5F.c index da08de4..cd35182 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -472,12 +472,9 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if(TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file create property list") - /* Check the file access property list */ - if(H5P_DEFAULT == fapl_id) - fapl_id = H5P_FILE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&fapl_id, H5P_CLS_FACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* * Adjust bit flags by turning on the creation bit and making sure that @@ -567,11 +564,10 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) if((flags & ~H5F_ACC_PUBLIC_FLAGS) || (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags") - if(H5P_DEFAULT == fapl_id) - fapl_id = H5P_FILE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&fapl_id, H5P_CLS_FACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Open the file */ if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, dxpl_id))) diff --git a/src/H5G.c b/src/H5G.c index 00a53b8..8798a82 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -316,12 +316,9 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group create property list") - /* Check the group access property list */ - if(H5P_DEFAULT == gapl_id) - gapl_id = H5P_GROUP_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&gapl_id, H5P_CLS_GACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Create the new group & get its ID */ if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, dxpl_id))) @@ -396,12 +393,9 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group create property list") - /* Check the group access property list */ - if(H5P_DEFAULT == gapl_id) - gapl_id = H5P_GROUP_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&gapl_id, H5P_CLS_GACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up group creation info */ gcrt_info.gcpl_id = gcpl_id; @@ -471,12 +465,9 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Check the group access property list */ - if(H5P_DEFAULT == gapl_id) - gapl_id = H5P_GROUP_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&gapl_id, H5P_CLS_GACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Open the group */ if((grp = H5G__open_name(&loc, name, gapl_id, dxpl_id)) == NULL) @@ -611,11 +602,10 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(!grp_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up opened group location to fill in */ grp_loc.oloc = &grp_oloc; @@ -680,11 +670,10 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!grp_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up opened group location to fill in */ grp_loc.oloc = &grp_oloc; diff --git a/src/H5L.c b/src/H5L.c index 264c00e..23eb395 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -357,6 +357,10 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Set up src & dst location pointers */ src_loc_p = &src_loc; dst_loc_p = &dst_loc; @@ -416,6 +420,10 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Set up src & dst location pointers */ src_loc_p = &src_loc; dst_loc_p = &dst_loc; @@ -473,6 +481,10 @@ H5Lcreate_soft(const char *link_target, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Create the link */ if(H5L_create_soft(link_target, &link_loc, link_name, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") @@ -525,6 +537,10 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Set up current & new location pointers */ cur_loc_p = &cur_loc; new_loc_p = &new_loc; @@ -589,6 +605,10 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Create external link */ if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") @@ -631,6 +651,10 @@ H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Unlink */ if(H5L_delete(&loc, name, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") @@ -680,11 +704,10 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up user data for unlink operation */ udata.idx_type = idx_type; @@ -737,11 +760,10 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Get the link value */ if(H5L_get_val(&loc, name, buf, size, lapl_id, dxpl_id) < 0) @@ -793,11 +815,10 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up user data for retrieving information */ udata.idx_type = idx_type; @@ -846,11 +867,10 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Check for the existence of the link */ if((ret_value = H5L__exists(&loc, name, lapl_id, dxpl_id)) < 0) @@ -891,15 +911,14 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Get the link information */ if(H5L_get_info(&loc, name, linfo, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) @@ -943,11 +962,10 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up user data for callback */ udata.idx_type = idx_type; @@ -959,8 +977,7 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, /* Traverse the group hierarchy to locate the object to get info about */ if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_info_by_idx_cb, &udata, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") - + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) @@ -1134,11 +1151,10 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up user data for callback */ udata.idx_type = idx_type; @@ -1152,7 +1168,7 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, /* Traverse the group hierarchy to locate the link to get name of */ if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_name_by_idx_cb, &udata, lapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + HGOTO_ERROR(H5E_LINK, H5E_EXISTS, FAIL, "name doesn't exist") /* Set the return value */ ret_value = udata.name_len; @@ -1275,11 +1291,10 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up iteration beginning/end info */ idx = (idx_p == NULL ? 0 : *idx_p); @@ -1292,7 +1307,7 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, /* Iterate over the links */ if((ret_value = H5G_iterate(loc_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data, lapl_id, dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") /* Set the index we stopped at */ if(idx_p) @@ -1409,15 +1424,14 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Call internal group visitation routine */ if((ret_value = H5G_visit(loc_id, group_name, idx_type, order, op, op_data, lapl_id, dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 324f2bf..3e8be66 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -598,6 +598,10 @@ H5Lcreate_external(const char *file_name, const char *obj_name, p += file_name_len; HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Create an external link */ if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") diff --git a/src/H5O.c b/src/H5O.c index 46ce5fa..01be3e6 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -298,11 +298,10 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -450,6 +449,10 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") + /* Link to the object */ if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") @@ -569,11 +572,10 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Check if the object exists */ if((ret_value = H5G_loc_exists(&loc, name, lapl_id, dxpl_id)) < 0) @@ -651,11 +653,10 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Retrieve the object's information */ if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, dxpl_id) < 0) @@ -707,11 +708,10 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -808,11 +808,10 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* (Re)set the object's comment */ if(H5G_loc_set_comment(&loc, name, comment, lapl_id, dxpl_id) < 0) @@ -893,11 +892,10 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Retrieve the object's comment */ if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, dxpl_id)) < 0) @@ -1018,11 +1016,10 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - if(H5P_DEFAULT == lapl_id) - lapl_id = H5P_LINK_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Call internal object visitation routine */ if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, dxpl_id)) < 0) @@ -1354,7 +1351,7 @@ H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hbool_t app_ref) H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t dxpl_id = H5AC_ind_dxpl_id; /* transfer property list used for this operation */ + hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl used by library */ hid_t ret_value = FAIL; FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 14e1c91..b92d3e9 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -426,13 +426,13 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the core VFD backing store write tracking flag */ - if(H5P_register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE, &H5F_def_core_write_tracking_flag_g , + if(H5P_register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE, &H5F_def_core_write_tracking_flag_g, NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC, H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of the core VFD backing store page size */ - if(H5P_register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE, &H5F_def_core_write_tracking_page_size_g , + if(H5P_register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE, &H5F_def_core_write_tracking_page_size_g, NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -3407,6 +3407,9 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value) * * Return: Non-negative on success/Negative on failure * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * *------------------------------------------------------------------------- */ herr_t @@ -3434,7 +3437,7 @@ H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pset_core_write_tracking() */ /*------------------------------------------------------------------------- @@ -3445,6 +3448,9 @@ done: * * Return: Non-negative on success/Negative on failure * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * *------------------------------------------------------------------------- */ herr_t @@ -3473,5 +3479,5 @@ H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_siz done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pget_core_write_tracking() */ diff --git a/src/H5Pint.c b/src/H5Pint.c index 443802c..d80e66d 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -139,6 +139,8 @@ hid_t H5P_CLS_DATATYPE_ACCESS_ID_g = FAIL; H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g = NULL; hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g = FAIL; H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g = NULL; +hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g = FAIL; +H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g = NULL; hid_t H5P_CLS_OBJECT_COPY_ID_g = FAIL; H5P_genclass_t *H5P_CLS_OBJECT_COPY_g = NULL; hid_t H5P_CLS_LINK_CREATE_ID_g = FAIL; @@ -163,6 +165,7 @@ hid_t H5P_LST_GROUP_ACCESS_ID_g = FAIL; hid_t H5P_LST_DATATYPE_CREATE_ID_g = FAIL; hid_t H5P_LST_DATATYPE_ACCESS_ID_g = FAIL; hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g = FAIL; +hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g = FAIL; hid_t H5P_LST_OBJECT_COPY_ID_g = FAIL; hid_t H5P_LST_LINK_CREATE_ID_g = FAIL; hid_t H5P_LST_LINK_ACCESS_ID_g = FAIL; @@ -186,6 +189,26 @@ const H5P_libclass_t H5P_CLS_ROOT[1] = {{ NULL /* Class close callback info */ }}; +/* Attribute access property list class library initialization object */ +/* (move to proper source code file when used for real) */ +const H5P_libclass_t H5P_CLS_AACC[1] = {{ + "attribute access", /* Class name for debugging */ + H5P_TYPE_ATTRIBUTE_ACCESS, /* Class type */ + + &H5P_CLS_LINK_ACCESS_g, /* Parent class */ + &H5P_CLS_ATTRIBUTE_ACCESS_g, /* Pointer to class */ + &H5P_CLS_ATTRIBUTE_ACCESS_ID_g, /* Pointer to class ID */ + &H5P_LST_ATTRIBUTE_ACCESS_ID_g, /* Pointer to default property list ID */ + NULL, /* Default property registration routine */ + + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + /* Group access property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_GACC[1] = {{ @@ -297,6 +320,7 @@ static H5P_libclass_t const * const init_class[] = { H5P_CLS_TCRT, /* Datatype creation */ H5P_CLS_TACC, /* Datatype access */ H5P_CLS_ACRT, /* Attribute creation */ + H5P_CLS_AACC, /* Attribute access */ H5P_CLS_LCRT /* Link creation */ }; @@ -487,6 +511,7 @@ H5P_term_package(void) H5P_LST_DATATYPE_CREATE_ID_g = H5P_LST_DATATYPE_ACCESS_ID_g = H5P_LST_ATTRIBUTE_CREATE_ID_g = + H5P_LST_ATTRIBUTE_ACCESS_ID_g = H5P_LST_OBJECT_COPY_ID_g = H5P_LST_LINK_CREATE_ID_g = H5P_LST_LINK_ACCESS_ID_g = @@ -513,6 +538,7 @@ H5P_term_package(void) H5P_CLS_DATATYPE_ACCESS_g = H5P_CLS_STRING_CREATE_g = H5P_CLS_ATTRIBUTE_CREATE_g = + H5P_CLS_ATTRIBUTE_ACCESS_g = H5P_CLS_OBJECT_COPY_g = H5P_CLS_LINK_CREATE_g = H5P_CLS_LINK_ACCESS_g = @@ -531,6 +557,7 @@ H5P_term_package(void) H5P_CLS_DATATYPE_ACCESS_ID_g = H5P_CLS_STRING_CREATE_ID_g = H5P_CLS_ATTRIBUTE_CREATE_ID_g = + H5P_CLS_ATTRIBUTE_ACCESS_ID_g = H5P_CLS_OBJECT_COPY_ID_g = H5P_CLS_LINK_CREATE_ID_g = H5P_CLS_LINK_ACCESS_ID_g = @@ -5253,7 +5280,7 @@ H5P__new_plist_of_type(H5P_plist_type_t type) FUNC_ENTER_PACKAGE /* Sanity checks */ - HDcompile_assert(H5P_TYPE_LINK_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); + HDcompile_assert(H5P_TYPE_ATTRIBUTE_ACCESS == (H5P_TYPE_MAX_TYPE - 1)); HDassert(type >= H5P_TYPE_USER && type <= H5P_TYPE_LINK_ACCESS); /* Check arguments */ @@ -5316,6 +5343,10 @@ H5P__new_plist_of_type(H5P_plist_type_t type) class_id = H5P_CLS_ATTRIBUTE_CREATE_ID_g; break; + case H5P_TYPE_ATTRIBUTE_ACCESS: + class_id = H5P_CLS_ATTRIBUTE_ACCESS_ID_g; + break; + case H5P_TYPE_OBJECT_COPY: class_id = H5P_CLS_OBJECT_COPY_ID_g; break; @@ -5403,3 +5434,45 @@ H5P_get_class(const H5P_genplist_t *plist) FUNC_LEAVE_NOAPI(plist->pclass) } /* end H5P_get_class() */ + +/*------------------------------------------------------------------------- + * Function: H5P_verify_apl_and_dxpl + * + * Purpose: Validate access property list and/or switch from generic + * property list to default of correct type. + * + * Also, if using internal DXPL and collective flag is set, + * switch to internal collective DXPL. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * Sunday, June 21, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_verify_apl_and_dxpl(hid_t *acspl_id, const H5P_libclass_t *libclass, hid_t *dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(acspl_id); + HDassert(libclass); + HDassert(dxpl_id); + + /* Set access plist to the default property list of the appropriate class if it's the generic default */ + if(H5P_DEFAULT == *acspl_id) + *acspl_id = *libclass->def_plist_id; + else { + /* Sanity check the access property list class */ + if(TRUE != H5P_isa_class(*acspl_id, *libclass->class_id)) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not the required access property list") + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_verify_apl_and_dxpl() */ + diff --git a/src/H5Ppkg.h b/src/H5Ppkg.h index 105baf7..5997845 100644 --- a/src/H5Ppkg.h +++ b/src/H5Ppkg.h @@ -115,33 +115,6 @@ struct H5P_genplist_t { H5SL_t *props; /* Skip list containing properties */ }; -/* Function pointer for library classes with properties to register */ -typedef herr_t (*H5P_init_class_op_t)(H5P_genclass_t *pclass); -typedef herr_t (*H5P_reg_prop_func_t)(H5P_genclass_t *pclass); - -/* - * Each library property list class has a variable of this type that contains - * class variables and methods used to initialize the class. - */ -typedef struct H5P_libclass_t { - const char *name; /* Class name */ - H5P_plist_type_t type; /* Class type */ - - H5P_genclass_t * * par_pclass; /* Pointer to global parent class property list class */ - H5P_genclass_t * * pclass; /* Pointer to global property list class */ - hid_t * const class_id; /* Pointer to global property list class ID */ - hid_t * const def_plist_id; /* Pointer to global default property list ID */ - H5P_reg_prop_func_t reg_prop_func; /* Register class's properties */ - - /* Class callback function pointers & info */ - H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ - void *create_data; /* Pointer to user data to pass along to create callback */ - H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ - void *copy_data; /* Pointer to user data to pass along to copy callback */ - H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ - void *close_data; /* Pointer to user data to pass along to close callback */ -} H5P_libclass_t; - /* Property list/class iterator callback function pointer */ typedef int (*H5P_iterate_int_t)(H5P_genprop_t *prop, void *udata); diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 05830d1..7e76a4f 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -73,9 +73,36 @@ typedef enum H5P_plist_type_t { H5P_TYPE_OBJECT_COPY = 15, H5P_TYPE_LINK_CREATE = 16, H5P_TYPE_LINK_ACCESS = 17, + H5P_TYPE_ATTRIBUTE_ACCESS = 18, H5P_TYPE_MAX_TYPE } H5P_plist_type_t; +/* Function pointer for library classes with properties to register */ +typedef herr_t (*H5P_reg_prop_func_t)(H5P_genclass_t *pclass); + +/* + * Each library property list class has a variable of this type that contains + * class variables and methods used to initialize the class. + */ +typedef struct H5P_libclass_t { + const char *name; /* Class name */ + H5P_plist_type_t type; /* Class type */ + + H5P_genclass_t * * par_pclass; /* Pointer to global parent class property list class */ + H5P_genclass_t * * pclass; /* Pointer to global property list class */ + hid_t * const class_id; /* Pointer to global property list class ID */ + hid_t * const def_plist_id; /* Pointer to global default property list ID */ + H5P_reg_prop_func_t reg_prop_func; /* Register class's properties */ + + /* Class callback function pointers & info */ + H5P_cls_create_func_t create_func; /* Function to call when a property list is created */ + void *create_data; /* Pointer to user data to pass along to create callback */ + H5P_cls_copy_func_t copy_func; /* Function to call when a property list is copied */ + void *copy_data; /* Pointer to user data to pass along to copy callback */ + H5P_cls_close_func_t close_func; /* Function to call when a property list is closed */ + void *close_data; /* Pointer to user data to pass along to close callback */ +} H5P_libclass_t; + /*****************************/ /* Library Private Variables */ /*****************************/ @@ -94,11 +121,20 @@ H5_DLLVAR H5P_genclass_t *H5P_CLS_GROUP_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_DATATYPE_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_ATTRIBUTE_CREATE_g; +H5_DLLVAR H5P_genclass_t *H5P_CLS_ATTRIBUTE_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_OBJECT_COPY_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_LINK_CREATE_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_LINK_ACCESS_g; H5_DLLVAR H5P_genclass_t *H5P_CLS_STRING_CREATE_g; +/* Internal property list classes */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_LACC[1]; /* Link access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_AACC[1]; /* Attribute access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_GACC[1]; /* Group access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_TACC[1]; /* Named datatype access */ +H5_DLLVAR const struct H5P_libclass_t H5P_CLS_FACC[1]; /* File access */ + /******************************/ /* Library Private Prototypes */ @@ -124,6 +160,8 @@ H5_DLL herr_t H5P_remove(H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_exist_plist(const H5P_genplist_t *plist, const char *name); H5_DLL htri_t H5P_class_isa(const H5P_genclass_t *pclass1, const H5P_genclass_t *pclass2); H5_DLL char *H5P_get_class_name(H5P_genclass_t *pclass); + +/* Internal helper routines */ H5_DLL herr_t H5P_get_nprops_pclass(const H5P_genclass_t *pclass, size_t *nprops, hbool_t recurse); H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); @@ -143,6 +181,7 @@ H5_DLL herr_t H5P_get_filter_by_id(H5P_genplist_t *plist, H5Z_filter_t id, unsigned int *flags, size_t *cd_nelmts, unsigned cd_values[], size_t namelen, char name[], unsigned *filter_config); H5_DLL htri_t H5P_filter_in_pline(H5P_genplist_t *plist, H5Z_filter_t id); +H5_DLL herr_t H5P_verify_apl_and_dxpl(hid_t *acspl_id, const H5P_libclass_t *libclass, hid_t *dxpl_id); /* Query internal fields of the property list struct */ H5_DLL hid_t H5P_get_plist_id(const H5P_genplist_t *plist); @@ -152,12 +191,6 @@ H5_DLL H5P_genclass_t *H5P_get_class(const H5P_genplist_t *plist); H5_DLL htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id); H5_DLL H5P_genplist_t *H5P_object_verify(hid_t plist_id, hid_t pclass_id); -/* Private functions to "peek" at properties of a certain type */ -H5_DLL unsigned H5P_peek_unsigned(H5P_genplist_t *plist, const char *name); -H5_DLL hid_t H5P_peek_hid_t(H5P_genplist_t *plist, const char *name); -H5_DLL void *H5P_peek_voidp(H5P_genplist_t *plist, const char *name); -H5_DLL size_t H5P_peek_size_t(H5P_genplist_t *plist, const char *name); - /* Private DCPL routines */ H5_DLL herr_t H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 932472c..6a97918 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -66,6 +66,7 @@ #define H5P_DATATYPE_ACCESS (H5OPEN H5P_CLS_DATATYPE_ACCESS_ID_g) #define H5P_STRING_CREATE (H5OPEN H5P_CLS_STRING_CREATE_ID_g) #define H5P_ATTRIBUTE_CREATE (H5OPEN H5P_CLS_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS (H5OPEN H5P_CLS_ATTRIBUTE_ACCESS_ID_g) #define H5P_OBJECT_COPY (H5OPEN H5P_CLS_OBJECT_COPY_ID_g) #define H5P_LINK_CREATE (H5OPEN H5P_CLS_LINK_CREATE_ID_g) #define H5P_LINK_ACCESS (H5OPEN H5P_CLS_LINK_ACCESS_ID_g) @@ -84,6 +85,7 @@ #define H5P_DATATYPE_CREATE_DEFAULT (H5OPEN H5P_LST_DATATYPE_CREATE_ID_g) #define H5P_DATATYPE_ACCESS_DEFAULT (H5OPEN H5P_LST_DATATYPE_ACCESS_ID_g) #define H5P_ATTRIBUTE_CREATE_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_CREATE_ID_g) +#define H5P_ATTRIBUTE_ACCESS_DEFAULT (H5OPEN H5P_LST_ATTRIBUTE_ACCESS_ID_g) #define H5P_OBJECT_COPY_DEFAULT (H5OPEN H5P_LST_OBJECT_COPY_ID_g) #define H5P_LINK_CREATE_DEFAULT (H5OPEN H5P_LST_LINK_CREATE_ID_g) #define H5P_LINK_ACCESS_DEFAULT (H5OPEN H5P_LST_LINK_ACCESS_ID_g) @@ -189,6 +191,7 @@ H5_DLLVAR hid_t H5P_CLS_DATATYPE_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_DATATYPE_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_STRING_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_CLS_ATTRIBUTE_ACCESS_ID_g; H5_DLLVAR hid_t H5P_CLS_OBJECT_COPY_ID_g; H5_DLLVAR hid_t H5P_CLS_LINK_CREATE_ID_g; H5_DLLVAR hid_t H5P_CLS_LINK_ACCESS_ID_g; @@ -206,6 +209,7 @@ H5_DLLVAR hid_t H5P_LST_GROUP_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_DATATYPE_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_DATATYPE_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_CREATE_ID_g; +H5_DLLVAR hid_t H5P_LST_ATTRIBUTE_ACCESS_ID_g; H5_DLLVAR hid_t H5P_LST_OBJECT_COPY_ID_g; H5_DLLVAR hid_t H5P_LST_LINK_CREATE_ID_g; H5_DLLVAR hid_t H5P_LST_LINK_ACCESS_ID_g; diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 0ab3b4e..51fb9d2 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -127,12 +127,9 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") - /* Get correct property list */ - if(H5P_DEFAULT == tapl_id) - tapl_id = H5P_DATATYPE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Commit the type */ if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, dxpl_id) < 0) @@ -268,12 +265,9 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list") - /* Get correct property list */ - if(H5P_DEFAULT == tapl_id) - tapl_id = H5P_DATATYPE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Commit the type */ if(H5T__commit(loc.oloc->file, type, tcpl_id, dxpl_id) < 0) @@ -547,12 +541,9 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Get correct property list */ - if(H5P_DEFAULT == tapl_id) - tapl_id = H5P_DATATYPE_ACCESS_DEFAULT; - else - if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") + /* Verify access property list and get correct dxpl */ + if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Set up datatype location to fill in */ type_loc.oloc = &oloc; -- cgit v0.12 From b9763eee6dd6a81d2696faf430e0cf7f27281462 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 15 Jan 2016 18:28:08 -0500 Subject: [svn-r28918] Description: I missed changes to a couple of expected error output files with the last checkin. Tested on: MacOSX/64 10.11.2 (amazon) w/serial & parallel (h5committest forthcoming) --- tools/h5dump/errfiles/tdset-2.err | 2 +- tools/h5dump/errfiles/tperror.err | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/h5dump/errfiles/tdset-2.err b/tools/h5dump/errfiles/tdset-2.err index 775351e..e594c1b 100644 --- a/tools/h5dump/errfiles/tdset-2.err +++ b/tools/h5dump/errfiles/tdset-2.err @@ -19,7 +19,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Lget_info(): unable to get link info - major: Symbol table + major: Links minor: Object not found #001: (file name) line (number) in H5L_get_info(): name doesn't exist major: Symbol table diff --git a/tools/h5dump/errfiles/tperror.err b/tools/h5dump/errfiles/tperror.err index 29f9e7f..b469029 100644 --- a/tools/h5dump/errfiles/tperror.err +++ b/tools/h5dump/errfiles/tperror.err @@ -19,7 +19,7 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Lget_info(): unable to get link info - major: Symbol table + major: Links minor: Object not found #001: (file name) line (number) in H5L_get_info(): name doesn't exist major: Symbol table -- cgit v0.12