Skip to content

Commit

Permalink
Add tests for H5R get name APIs (#4657)
Browse files Browse the repository at this point in the history
Added functionality tests for the following APIs:
H5Rget_file_name
H5Rget_obj_name
H5Rget_attr_name

Also removed "+1" when returning a name length in H5R__get_attr_name().
The exter "+1" gave an incorrect value for the length of the referenced
object's attribute name.

Fixed GH-4447

* Fix Fortran test

The C API H5Rget_attr_name incorrectly added 1 to the length of the
referenced object's attribute name, so the Fortran API h5rget_attr_name_f
removed 1 from the returned value to accommodate the incorrectness.
This PR fixes H5Rget_attr_name so this workaround in h5rget_attr_name_f
is no longer needed.

* Add test H5Aget_name against H5Rget_attr_name
  • Loading branch information
bmribler authored Aug 12, 2024
1 parent 48aaf0c commit d875f74
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 147 deletions.
2 changes: 0 additions & 2 deletions fortran/src/H5Rff.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,6 @@ END FUNCTION H5Rget_attr_name
c_name(1:1)(1:1) = C_NULL_CHAR
name_len = H5Rget_attr_name(ref_ptr, c_name, 1_SIZE_T)
IF(name_len.LT.0_SIZE_T) hdferr = H5I_INVALID_HID_F
! Don't include the NULL term in the size
name_len = name_len - 1
ELSE
l = INT(LEN(name)+1,SIZE_T)
IF(H5Rget_attr_name(ref_ptr, c_name, l) .LT. 0_SIZE_T)THEN
Expand Down
9 changes: 9 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,15 @@ Bug Fixes since HDF5-1.14.0 release
===================================
Library
-------
- Fixed H5Rget_attr_name to return the length of the attribute's name
without the null terminator

H5Rget_file_name and H5Rget_obj_name both return the name's length
without the null terminator. H5Rget_attr_name now behaves consistently
with the other two APIs. Going forward, all the get character string
APIs in HDF5 will be modified/written in this manner, regarding the
length of a character string.

- Fixed library to allow usage of page buffering feature for serial file
access with parallel builds of HDF5

Expand Down
2 changes: 1 addition & 1 deletion src/H5Rint.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ H5R__get_attr_name(const H5R_ref_priv_t *ref, char *buf, size_t size)
buf[copy_len] = '\0';
}

ret_value = (ssize_t)(attr_name_len + 1);
ret_value = (ssize_t)(attr_name_len);

FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R__get_attr_name() */
Expand Down
2 changes: 1 addition & 1 deletion src/H5Rpublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ H5_DLL ssize_t H5Rget_obj_name(H5R_ref_t *ref_ptr, hid_t rapl_id, char *name, si
* \details H5Rget_attr_name() retrieves the attribute name for the
* attribute reference pointed to by \p ref_ptr.
*
* \details_namelen_plusone{attribute,H5Rget_attr_name}
* \details_namelen{attribute,H5Rget_attr_name}
*
* \since 1.12.0
*
Expand Down
Loading

0 comments on commit d875f74

Please sign in to comment.