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/H5Object.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/H5Object.cpp')
-rw-r--r-- | c++/src/H5Object.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp index cb803af..d092ef0 100644 --- a/c++/src/H5Object.cpp +++ b/c++/src/H5Object.cpp @@ -497,11 +497,16 @@ H5Object::getObjName() const } // Object's name exists, retrieve it else if (name_size > 0) { + + // The actual 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; + // Create buffer for C string - char *name_C = new char[name_size + 1](); + char *name_C = new char[actual_name_size](); // Use overloaded function - name_size = getObjName(name_C, name_size + 1); + name_size = getObjName(name_C, actual_name_size); // Convert the C object name to return obj_name = name_C; @@ -509,8 +514,9 @@ H5Object::getObjName() const // Clean up resource delete[] name_C; } + // Return object's name - return (obj_name); + return obj_name; } //-------------------------------------------------------------------------- @@ -534,7 +540,7 @@ H5Object::getObjName(H5std_string &obj_name, size_t len) const // If no length is provided, get the entire object name if (len == 0) { obj_name = getObjName(); - name_size = obj_name.length(); + name_size = static_cast<ssize_t>(obj_name.length()); } // If length is provided, get that number of characters in name else { @@ -553,7 +559,7 @@ H5Object::getObjName(H5std_string &obj_name, size_t len) const // Otherwise, keep obj_name intact // Return name size - return (name_size); + return name_size; } #ifndef DOXYGEN_SHOULD_SKIP_THIS |