Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings that happen in Release build #4113

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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