From bbb4d22621213e8a0fcb4cfbe20622acda741ac3 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 13 Dec 2003 15:08:11 -0500 Subject: [svn-r7951] Purpose: Bug fix Description: Attributes which were created with scalar dataspaces were reporting their dataspace as a simple dataspace when queried later. Solution: Fix the dataspace handling code when reading in the attribute message from the file to set the extent type correctly. Platforms tested: FreeBSD 4.9 (sleipnir) too minor to require h5committest --- release_docs/RELEASE.txt | 4 +++- src/H5Oattr.c | 10 +++++++++- test/tattr.c | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 98301c5..d592401 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -71,9 +71,11 @@ Bug Fixes since HDF5-1.6.1 release Library ------- + - Fixed bug where scalar dataspaces for attributes were reporting as + simple dataspaces. QAK - 2003/12/13 - Fixed problem with selection offsets of hyperslab selections in chunked datasets causing the library to go into an infinite loop. - QAK - 2003/12/06 + QAK - 2003/12/13 - Fixed H5Giterate to avoid re-using index parameter after iteration callback has been called (allows iteration callback to modify the index parameter itself). QAK - 2003/12/06 diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 1aa0129..a75c127 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -178,8 +178,16 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p, H5O_shared_t UNUSED * hsize_t nelem; /* Number of elements in extent */ unsigned u; /* Local index variable */ - attr->ds->extent.type = H5S_SIMPLE; + /* Set the dataspace type to be simple or scalar as appropriate */ + if(simple->rank>0) + attr->ds->extent.type = H5S_SIMPLE; + else + attr->ds->extent.type = H5S_SCALAR; + + /* Copy the extent information */ HDmemcpy(&(attr->ds->extent.u.simple),simple, sizeof(H5S_simple_t)); + + /* Release temporary extent information */ H5FL_FREE(H5S_simple_t,simple); /* Compute the number of elements in the extent */ diff --git a/test/tattr.c b/test/tattr.c index ff64862..5104366 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -721,7 +721,9 @@ test_attr_scalar_read(void) { hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ + hid_t sid; /* Dataspace ID */ hid_t attr; /* Attribute ID */ + H5S_class_t stype; /* Dataspace class */ float rdata=0.0; /* Buffer for reading 1st attribute */ herr_t ret; /* Generic return value */ @@ -749,6 +751,18 @@ test_attr_scalar_read(void) CHECK(ret, FAIL, "H5Aread"); VERIFY(rdata, attr_data5, "H5Aread"); + /* Get the attribute's dataspace */ + sid = H5Aget_space(attr); + CHECK(sid, FAIL, "H5Aget_space"); + + /* Make certain the dataspace is scalar */ + stype = H5Sget_simple_extent_type (sid); + VERIFY(stype, H5S_SCALAR, "H5Sget_simple_extent_type"); + + /* Close dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + /* Close attribute */ ret=H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); -- cgit v0.12