diff options
-rw-r--r-- | src/H5A.c | 14 | ||||
-rw-r--r-- | src/H5Aint.c | 3 | ||||
-rw-r--r-- | src/H5Apkg.h | 1 | ||||
-rw-r--r-- | src/H5Oattr.c | 6 | ||||
-rw-r--r-- | test/tattr.c | 62 |
5 files changed, 63 insertions, 23 deletions
@@ -436,9 +436,6 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, if(H5S_set_latest_version(attr->shared->ds) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of dataspace") - /* Mark it initially set to initialized */ - attr->shared->initialized = TRUE; /*for now, set to false later*/ - /* Copy the object header information */ if(H5O_loc_copy(&(attr->oloc), loc->oloc, H5_COPY_DEEP) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry") @@ -498,9 +495,6 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") - /* Now it's safe to say it's uninitialized */ - attr->shared->initialized = FALSE; - done: /* Cleanup on failure */ if(ret_value < 0 && attr && H5A_close(attr) < 0) @@ -550,7 +544,6 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t UNUSED aapl_id) /* Read in attribute from object header */ if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header") - attr->shared->initialized = TRUE; /* Finish initializing attribute */ if(H5A_open_common(&loc, attr) < 0) @@ -805,7 +798,6 @@ H5A_open_by_idx(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, /* Read in attribute from object header */ if(NULL == (attr = H5O_attr_open_by_idx(obj_loc.oloc, idx_type, order, n, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to load attribute info from object header") - attr->shared->initialized = TRUE; /* Finish initializing attribute */ if(H5A_open_common(&obj_loc, attr) < 0) @@ -871,7 +863,6 @@ H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name, const char *attr_na /* Read in attribute from object header */ if(NULL == (attr = H5O_attr_open_by_name(obj_loc.oloc, attr_name, dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to load attribute info from object header") - attr->shared->initialized = TRUE; /* Finish initializing attribute */ if(H5A_open_common(loc, attr) < 0) @@ -1036,9 +1027,6 @@ H5A_write(H5A_t *attr, const H5T_t *mem_type, const void *buf, hid_t dxpl_id) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to modify attribute") } /* end if */ - /* Indicate the the attribute doesn't need fill-values */ - attr->shared->initialized = TRUE; - done: /* Release resources */ if(src_id >= 0) @@ -1144,7 +1132,7 @@ H5A_read(const H5A_t *attr, const H5T_t *mem_type, void *buf, hid_t dxpl_id) dst_type_size = H5T_GET_SIZE(mem_type); /* Check if the attribute has any data yet, if not, fill with zeroes */ - if(attr->obj_opened && !attr->shared->initialized) + if(attr->obj_opened && !attr->shared->data) HDmemset(buf, 0, (dst_type_size * nelmts)); else { /* Attribute exists and has a value */ /* Convert memory buffer into disk buffer */ diff --git a/src/H5Aint.c b/src/H5Aint.c index 2ac17fa..475239a 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1022,9 +1022,6 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si if(H5A_set_version(file_dst, attr_dst) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version") - /* Indicate that the fill values aren't to be written out */ - attr_dst->shared->initialized = TRUE; - /* Set return value */ ret_value = attr_dst; diff --git a/src/H5Apkg.h b/src/H5Apkg.h index 3c62635..4216fa3 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -75,7 +75,6 @@ /* Define the shared attribute structure */ typedef struct H5A_shared_t { unsigned version; /* Version to encode attribute with */ - hbool_t initialized;/* Indicate whether the attribute has been modified */ char *name; /* Attribute's name */ H5T_cset_t encoding; /* Character encoding of attribute name */ diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 27b9d5e..1e85c69 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -226,9 +226,6 @@ H5O_attr_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, unsigned UNUSED mesg_fl HDmemcpy(attr->shared->data, p, attr->shared->data_size); } /* end if */ - /* Indicate that the fill values aren't to be written out */ - attr->shared->initialized = 1; - /* Increment the reference count for this object header message in cache(compact storage) or for the object from dense storage. */ attr->shared->nrefs++; @@ -805,9 +802,6 @@ H5O_attr_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * stream, int in "Character Set of Name:", s); HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, - "Initialized:", - mesg->shared->initialized); - HDfprintf(stream, "%*s%-*s %t\n", indent, "", fwidth, "Object opened:", mesg->obj_opened); HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, diff --git a/test/tattr.c b/test/tattr.c index 4b130e6..5eb378f 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -10145,6 +10145,66 @@ test_attr_bug5(hid_t fcpl, hid_t fapl) /**************************************************************** ** +** test_attr_bug6(): Test basic H5A (attribute) code. +** Tests if reading an empty attribute is OK. +** +****************************************************************/ +static void +test_attr_bug6(hid_t fcpl, hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + hid_t aid1, aid2; /* Attribute IDs */ + hid_t sid; /* Dataspace ID */ + hsize_t dims[1] = {5}; /* Attribute dimensions */ + int intar[5]; /* Data reading buffer */ + herr_t ret; /* Generic return status */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing that empty attribute can be read\n")); + + /* Create file */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Open root group */ + gid = H5Gopen2(fid, "/", H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Create dataspace */ + sid = H5Screate_simple(1, dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Create attribute on group */ + aid1 = H5Acreate2(gid, "attr", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid1, FAIL, "H5Acreate2"); + + ret = H5Aclose(aid1); + CHECK(ret, FAIL, "H5Aclose"); + + /* Open the attribute again */ + aid2 = H5Aopen_name(gid, "attr"); + CHECK(aid2, FAIL, "H5Aopen_name"); + + ret = H5Aread(aid2, H5T_NATIVE_INT, intar); + CHECK(ret, FAIL, "H5Aread"); + + /* Close IDs */ + ret = H5Aclose(aid2); + CHECK(ret, FAIL, "H5Aclose"); + + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); +} + +/**************************************************************** +** ** test_attr(): Main H5A (attribute) testing routine. ** ****************************************************************/ @@ -10288,6 +10348,7 @@ test_attr(void) test_attr_bug3(my_fcpl, my_fapl); /* Test "self referential" attributes */ test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */ test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */ + test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */ } /* end for */ } /* end if */ else { @@ -10311,6 +10372,7 @@ test_attr(void) test_attr_bug3(fcpl, my_fapl); /* Test "self referential" attributes */ test_attr_bug4(fcpl, my_fapl); /* Test attributes on named datatypes */ test_attr_bug5(fcpl, my_fapl); /* Test opening/closing attributes through different file handles */ + test_attr_bug6(fcpl, my_fapl); /* Test reading empty attribute */ } /* end else */ } /* end for */ |