diff options
Diffstat (limited to 'test/tattr.c')
-rw-r--r-- | test/tattr.c | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/test/tattr.c b/test/tattr.c index 484d83f..828b8a8 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -274,60 +274,68 @@ test_attr_basic_write(hid_t fapl) attr_name_size = H5Aget_name(attr, (size_t)0, NULL); CHECK(attr_name_size, FAIL, "H5Aget_name"); - if(attr_name_size > 0) + if(attr_name_size > 0) { attr_name = (char*)HDcalloc((size_t)(attr_name_size + 1), sizeof(char)); - - ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name); - CHECK(ret, FAIL, "H5Aget_name"); - ret = HDstrcmp(attr_name, ATTR_TMP_NAME); - VERIFY(ret, 0, "HDstrcmp"); - - if(attr_name) - HDfree(attr_name); + CHECK(attr_name, NULL, "HDcalloc"); + + if(attr_name) { + ret = (herr_t)H5Aget_name(attr, (size_t)(attr_name_size + 1), attr_name); + CHECK(ret, FAIL, "H5Aget_name"); + ret = HDstrcmp(attr_name, ATTR_TMP_NAME); + VERIFY(ret, 0, "HDstrcmp"); + + HDfree(attr_name); + attr_name = NULL; + } /* end if */ + } /* end if */ /* Read attribute information immediately, without closing attribute */ ret = H5Aread(attr, H5T_NATIVE_INT, read_data1); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1[i],i,read_data1[i]); + for(i = 0; i < ATTR1_DIM1; i++) + if(attr_data1[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1[i], i, read_data1[i]); /* Close attribute */ - ret=H5Aclose(attr); + ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Open the second attribute again */ - attr2=H5Aopen(dataset, ATTR1A_NAME, H5P_DEFAULT); + attr2 = H5Aopen(dataset, ATTR1A_NAME, H5P_DEFAULT); CHECK(attr, FAIL, "H5Aopen"); /* Verify new attribute name */ attr_name_size = H5Aget_name(attr2, (size_t)0, NULL); CHECK(attr_name_size, FAIL, "H5Aget_name"); - if(attr_name_size>0) + if(attr_name_size > 0) { attr_name = (char*)HDcalloc((size_t)(attr_name_size+1), sizeof(char)); - - ret=(herr_t)H5Aget_name(attr2, (size_t)(attr_name_size+1), attr_name); - CHECK(ret, FAIL, "H5Aget_name"); - ret=HDstrcmp(attr_name, ATTR1A_NAME); - VERIFY(ret, 0, "HDstrcmp"); - - if(attr_name) - HDfree(attr_name); + CHECK(attr_name, NULL, "HDcalloc"); + + if(attr_name) { + ret = (herr_t)H5Aget_name(attr2, (size_t)(attr_name_size + 1), attr_name); + CHECK(ret, FAIL, "H5Aget_name"); + ret = HDstrcmp(attr_name, ATTR1A_NAME); + VERIFY(ret, 0, "HDstrcmp"); + + HDfree(attr_name); + attr_name = NULL; + } /* end if */ + } /* end if */ /* Read attribute information immediately, without closing attribute */ - ret=H5Aread(attr2,H5T_NATIVE_INT,read_data1); + ret = H5Aread(attr2, H5T_NATIVE_INT, read_data1); CHECK(ret, FAIL, "H5Aread"); /* Verify values read in */ - for(i=0; i<ATTR1_DIM1; i++) - if(attr_data1a[i]!=read_data1[i]) - TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n",__LINE__,i,attr_data1a[i],i,read_data1[i]); + for(i = 0; i < ATTR1_DIM1; i++) + if(attr_data1a[i] != read_data1[i]) + TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d, read_data1[%d]=%d\n", __LINE__, i, attr_data1a[i], i, read_data1[i]); /* Close attribute */ - ret=H5Aclose(attr2); + ret = H5Aclose(attr2); CHECK(ret, FAIL, "H5Aclose"); ret = H5Sclose(sid1); @@ -1539,7 +1547,7 @@ test_attr_delete(hid_t fapl) CHECK(attr, FAIL, "H5Aopen_by_idx"); /* Verify Name */ - name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN,attr_name); + name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR1_NAME), "H5Aget_name"); if(HDstrcmp(attr_name, ATTR1_NAME)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR1_NAME); @@ -1555,7 +1563,7 @@ test_attr_delete(hid_t fapl) /* Verify Name */ name_len = H5Aget_name(attr, (size_t)ATTR_NAME_LEN, attr_name); VERIFY(name_len, HDstrlen(ATTR3_NAME), "H5Aget_name"); - if(HDstrcmp(attr_name,ATTR3_NAME)) + if(HDstrcmp(attr_name, ATTR3_NAME)) TestErrPrintf("attribute name different: attr_name=%s, should be %s\n",attr_name,ATTR3_NAME); /* Close attribute */ |