From 00909f278d64017c21c8348537231daba97be9dd Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 20 Jul 2004 12:11:36 -0500 Subject: [svn-r8901] Purpose: Bug fix Description: Allow buffer parameter to H5Dread & H5Dwrite to be NULL if there are no elements to transfer. Platforms tested: FreeBSD 4.10 (sleipnir) w/parallel Too minor to require h5committest --- release_docs/RELEASE.txt | 9 ++++++--- src/H5Dio.c | 6 ++---- test/tselect.c | 20 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 68d531c..c9d8bf9 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -146,11 +146,14 @@ Bug Fixes since HDF5-1.6.0 release Library ------- + - Allow NULL pointer for buffer parameter to H5Dread & H5Dwrite + when not writing data ("none" selection or hyperslab or point + selection with no elements defined). QAK - 2004/07/20 - Calling H5Gcreate() on "/" or "." throws an error instead of - failing quietly. JML - 2004/07/19 + failing quietly. JML - 2004/07/19 - Fixed bug where setting file address size to be very small could - trigger an assert if the file grew to more than 64 KB. Now throws - an error and data can be recovered. JL/NF - 2004/07/14 + trigger an assert if the file grew to more than 64 KB. Now throws + an error and data can be recovered. JL/NF - 2004/07/14 - Fixed bug where "resurrecting" a dataset was failing. QAK - 2004/07/14 - Fixed bug where incorrect data could be read from a chunked dataset diff --git a/src/H5Dio.c b/src/H5Dio.c index 0d9a91c..fb07831 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -480,7 +480,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - if (!buf) + if (!buf && H5S_GET_SELECT_NPOINTS(file_space)!=0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") /* read raw data */ @@ -568,7 +568,7 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, else if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - if (!buf) + if (!buf && H5S_GET_SELECT_NPOINTS(file_space)!=0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") /* write raw data */ @@ -649,7 +649,6 @@ H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* check args */ assert(dataset && dataset->ent.file); - assert(buf); /* Get memory datatype */ if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) @@ -846,7 +845,6 @@ H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, /* check args */ assert(dataset && dataset->ent.file); - assert(buf); /* Get the memory datatype */ if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) diff --git a/test/tselect.c b/test/tselect.c index 228002c..c1d985f 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -253,6 +253,12 @@ test_select_hyper(hid_t xfer_plist) ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,wbuf); CHECK(ret, FAIL, "H5Dwrite"); + /* Exercise check for NULL buffer and valid selection */ + H5E_BEGIN_TRY { + ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,NULL); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Dwrite"); + /* Close memory dataspace */ ret = H5Sclose(sid2); CHECK(ret, FAIL, "H5Sclose"); @@ -273,6 +279,12 @@ test_select_hyper(hid_t xfer_plist) ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,rbuf); CHECK(ret, FAIL, "H5Dread"); + /* Exercise check for NULL buffer and valid selection */ + H5E_BEGIN_TRY { + ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,xfer_plist,NULL); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Dread"); + /* Check that the values match with a dataset iterator */ tbuf=wbuf+(15*SPACE2_DIM2); ret = H5Diterate(rbuf,H5T_NATIVE_UCHAR,sid2,test_select_hyper_iter1,&tbuf); @@ -5408,6 +5420,14 @@ test_select_none(void) ret=H5Dwrite(dataset,H5T_NATIVE_INT,sid2,sid1,H5P_DEFAULT,wbuf); CHECK(ret, FAIL, "H5Dwrite"); + /* Write "nothing" to disk (with NULL buffer argument) */ + ret=H5Dwrite(dataset,H5T_NATIVE_INT,sid2,sid1,H5P_DEFAULT,NULL); + CHECK(ret, FAIL, "H5Dwrite"); + + /* Read "nothing" from disk (with NULL buffer argument) */ + ret=H5Dread(dataset,H5T_NATIVE_INT,sid2,sid1,H5P_DEFAULT,NULL); + CHECK(ret, FAIL, "H5Dread"); + /* Close memory dataspace */ ret = H5Sclose(sid2); CHECK(ret, FAIL, "H5Sclose"); -- cgit v0.12