From d265b02901d30f1be6a6ef3ca4741a5fb807b6af Mon Sep 17 00:00:00 2001 From: Greg Eisenhauer Date: Wed, 27 Mar 2024 21:44:45 -0400 Subject: [PATCH] Warnings --- bindings/Fortran/f2c/adios2_f2c_io.cpp | 2 +- source/adios2/helper/adiosNetwork.cpp | 6 ++---- source/adios2/toolkit/format/bp5/BP5Deserializer.cpp | 2 +- source/h5vol/H5Vol_attr.c | 2 +- testing/utils/cwriter/TestUtilsCWriter.c | 2 +- 5 files changed, 6 insertions(+), 8 deletions(-) diff --git a/bindings/Fortran/f2c/adios2_f2c_io.cpp b/bindings/Fortran/f2c/adios2_f2c_io.cpp index da477de384..b1acb6079e 100644 --- a/bindings/Fortran/f2c/adios2_f2c_io.cpp +++ b/bindings/Fortran/f2c/adios2_f2c_io.cpp @@ -288,7 +288,7 @@ void FC_GLOBAL(adios2_retrieve_namelist_f2c, len = static_cast(namelist_len); } // copy C string without '\0' - strncpy(fs, info->names[i], len); + memcpy(fs, info->names[i], len); // pad with spaces memset(fs + len, ' ', namelist_len - len); } diff --git a/source/adios2/helper/adiosNetwork.cpp b/source/adios2/helper/adiosNetwork.cpp index 309260fcdf..11837376ae 100644 --- a/source/adios2/helper/adiosNetwork.cpp +++ b/source/adios2/helper/adiosNetwork.cpp @@ -4,8 +4,6 @@ * * adiosNetwork.cpp implementation of adiosNetwork.h functions * - * Created on: March 22, 2019 - * Author: William F Godoy godoywf@ornl.gov */ #include "adiosNetwork.h" @@ -82,7 +80,7 @@ std::string GetFQDN() noexcept // printf("hostname: %s\n", p->ai_canonname); if (strchr(p->ai_canonname, '.') != NULL) { - strncpy(hostname, p->ai_canonname, sizeof(hostname)); + strncpy(hostname, p->ai_canonname, sizeof(hostname) - 1); break; } } @@ -138,7 +136,7 @@ AvailableIpAddresses() noexcept for (struct if_nameindex *p = head; !(p->if_index == 0 && p->if_name == NULL); ++p) { struct ifreq req; - strncpy(req.ifr_name, p->if_name, IFNAMSIZ); + strncpy(req.ifr_name, p->if_name, IFNAMSIZ - 1); if (ioctl(socket_handler, SIOCGIFADDR, &req) < 0) { if (errno == EADDRNOTAVAIL) diff --git a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp index 9c1a127408..f78f554c9d 100644 --- a/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Deserializer.cpp @@ -366,7 +366,7 @@ BP5Deserializer::ControlInfo *BP5Deserializer::BuildControl(FMFormat Format) size_t VarIndex = 0; while (FieldList[i].field_name) { - size_t HeaderSkip; + size_t HeaderSkip = 0; char *ExprStr = NULL; int Derived = 0; ret = (ControlInfo *)realloc(ret, sizeof(*ret) + ControlCount * sizeof(struct ControlInfo)); diff --git a/source/h5vol/H5Vol_attr.c b/source/h5vol/H5Vol_attr.c index 17a89cb0d5..8a4dc84081 100644 --- a/source/h5vol/H5Vol_attr.c +++ b/source/h5vol/H5Vol_attr.c @@ -183,7 +183,7 @@ herr_t H5VL_adios2_attr_get(void *obj, H5VL_attr_get_args_t *args, hid_t dxpl_id *ret_val = strlen(attrDef->m_Name); if (buf) { - strncpy(buf, attrDef->m_Name, *ret_val); + memcpy(buf, attrDef->m_Name, *ret_val); } } else if (H5VL_OBJECT_BY_IDX == loc_params->type) diff --git a/testing/utils/cwriter/TestUtilsCWriter.c b/testing/utils/cwriter/TestUtilsCWriter.c index 04db7d8d6e..ed5acc3ac7 100644 --- a/testing/utils/cwriter/TestUtilsCWriter.c +++ b/testing/utils/cwriter/TestUtilsCWriter.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) char engineName[32] = "BPFile"; if (argc > 1) { - strncpy(engineName, argv[1], sizeof(engineName)); + strncpy(engineName, argv[1], sizeof(engineName) - 1); } // IO