Skip to content

Commit

Permalink
Warnings (#4113)
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Mar 28, 2024
1 parent 38187b6 commit 7bb7dc8
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bindings/Fortran/f2c/adios2_f2c_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void FC_GLOBAL(adios2_retrieve_namelist_f2c,
len = static_cast<size_t>(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);
}
Expand Down
6 changes: 2 additions & 4 deletions source/adios2/helper/adiosNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/toolkit/format/bp5/BP5Deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion source/h5vol/H5Vol_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion testing/utils/cwriter/TestUtilsCWriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7bb7dc8

Please sign in to comment.