/home/agreen/projects/dpdk/drivers/net/nfp/nfpcore/nfp_resource.c:76:2: error: ‘strncpy’ output may be truncated copying 8 bytes from a string of length 8 [-Werror=stringop-truncation] strncpy(name_pad, res->name, sizeof(name_pad)); --- drivers/net/nfp/nfpcore/nfp_resource.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c index e1df2b2e1..54c6dcf54 100644 --- a/drivers/net/nfp/nfpcore/nfp_resource.c +++ b/drivers/net/nfp/nfpcore/nfp_resource.c @@ -65,15 +65,15 @@ struct nfp_resource { static int nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res) { - char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ] = {}; + char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ + 2]; struct nfp_resource_entry entry; uint32_t cpp_id, key; int ret, i; cpp_id = NFP_CPP_ID(NFP_RESOURCE_TBL_TARGET, 3, 0); /* Atomic read */ - memset(name_pad, 0, NFP_RESOURCE_ENTRY_NAME_SZ); - strncpy(name_pad, res->name, sizeof(name_pad)); + memset(name_pad, 0, sizeof(name_pad)); + strncpy(name_pad, res->name, sizeof(name_pad) - 1); /* Search for a matching entry */ if (!memcmp(name_pad, NFP_RESOURCE_TBL_NAME "\0\0\0\0\0\0\0\0", 8)) {