diff options
author | Dana Robinson <43805+derobins@users.noreply.github.com> | 2022-07-11 15:59:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-11 15:59:51 (GMT) |
commit | fa7caf843508b250f085e88cf5edfc2606da1205 (patch) | |
tree | 8ecc6f13d62952ab8ee49ea59bae9c2a47684e9b /c++/src/H5IdComponent.cpp | |
parent | f599e2ac7fb7fb146b49e2f349a9c100e897f7ef (diff) | |
download | hdf5-fa7caf843508b250f085e88cf5edfc2606da1205.zip hdf5-fa7caf843508b250f085e88cf5edfc2606da1205.tar.gz hdf5-fa7caf843508b250f085e88cf5edfc2606da1205.tar.bz2 |
Fixes C++ sign-conversion warnings w/ clang 14 (#1870)
* Fixes sign-conversion warnings w/ clang 14
* Committing clang-format changes
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'c++/src/H5IdComponent.cpp')
-rw-r--r-- | c++/src/H5IdComponent.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index e1fc687..ce52fb0 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -397,10 +397,14 @@ IdComponent::p_get_file_name() const throw IdComponentException("", "H5Fget_name failed"); } + // The actual message size is the cast value + 1 for the terminal ASCII NUL + // (unfortunate in/out type sign mismatch) + size_t actual_name_size = static_cast<size_t>(name_size) + 1; + // Call H5Fget_name again to get the actual file name - char *name_C = new char[name_size + 1](); + char *name_C = new char[actual_name_size](); - name_size = H5Fget_name(temp_id, name_C, name_size + 1); + name_size = H5Fget_name(temp_id, name_C, actual_name_size); // Check for failure again if (name_size < 0) { @@ -411,7 +415,8 @@ IdComponent::p_get_file_name() const // Convert the C file name and return H5std_string file_name(name_C); delete[] name_C; - return (file_name); + + return file_name; } // |