summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
Diffstat (limited to 'hl')
-rw-r--r--hl/fortran/src/H5DSfc.c8
-rw-r--r--hl/src/H5DS.c4
-rw-r--r--hl/test/test_ds.c8
3 files changed, 9 insertions, 11 deletions
diff --git a/hl/fortran/src/H5DSfc.c b/hl/fortran/src/H5DSfc.c
index 3135cfa..2e38939 100644
--- a/hl/fortran/src/H5DSfc.c
+++ b/hl/fortran/src/H5DSfc.c
@@ -331,12 +331,8 @@ nh5dsget_scale_name_c(hid_t_f *did, _fcd name, size_t_f *size)
/*
* Convert C name to FORTRAN and place it in the given buffer
*/
- if(size_c != 0) {
- HD5packFstring(c_scale_name, _fcdtocp(name), (size_t)*size);
- *size = (size_t_f)size_c-1; /* (-1) because we don't include the NULL ending in the length*/
- } else {
- *size = (size_t_f)size_c; /* if NULL then no name was found */
- }
+ HD5packFstring(c_scale_name, _fcdtocp(name), (size_t)*size);
+ *size = (size_t_f)size_c;
done:
if(c_scale_name) HDfree(c_scale_name);
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index e9ea9cf..cb3a1ce 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -1779,6 +1779,8 @@ out:
* Comments:
*
* Modifications:
+* The size of the name returned should not include the NULL termination
+* in its value so as to be consistent with other HDF5 APIs.
*
*-------------------------------------------------------------------------
*/
@@ -1875,7 +1877,7 @@ ssize_t H5DSget_scale_name(hid_t did,
buf=NULL;
}
- return (ssize_t) nbytes;
+ return (ssize_t) MAX(0,nbytes-1);
/* error zone */
out:
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index e290bbb..b81f8d4 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -1127,9 +1127,9 @@ herr_t test_cmp_scalename(hid_t fid, hid_t did, const char *name, const char *sc
if((dsid = H5Dopen2(fid, name, H5P_DEFAULT)) >= 0) {
if(H5DSis_attached(did, dsid, idx) == 1) {
if((name_len=H5DSget_scale_name(dsid,NULL,(size_t)0)) > 0) {
- name_out = (char*)HDmalloc(name_len * sizeof (char));
+ name_out = (char*)HDmalloc((name_len+1) * sizeof (char));
if(name_out != NULL) {
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) >= 0) {
+ if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) >= 0) {
if(HDstrcmp(scalename,name_out)==0) {
ret_value = SUCCEED;
}
@@ -3232,12 +3232,12 @@ static int test_simple(void)
goto out;
/* allocate a buffer */
- name_out = (char*)HDmalloc(name_len * sizeof (char));
+ name_out = (char*)HDmalloc((name_len+1) * sizeof (char));
if(name_out == NULL)
goto out;
/* get the scale name using this buffer */
- if(H5DSget_scale_name(dsid, name_out, (size_t)name_len) < 0)
+ if(H5DSget_scale_name(dsid, name_out, (size_t)name_len+1) < 0)
goto out;
if(HDstrcmp("Latitude set 0",name_out)!=0)