From: Len Brown Date: Thu, 19 Mar 2020 22:33:12 +0000 (-0400) Subject: tools/power turbostat: Fix gcc build warnings X-Git-Tag: v5.4.31~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ba0ce3cbb866e1b8fe688a89a73a6d3861490a5;p=platform%2Fkernel%2Flinux-rpi.git tools/power turbostat: Fix gcc build warnings [ Upstream commit d8d005ba6afa502ca37ced5782f672c4d2fc1515 ] Warning: ‘__builtin_strncpy’ specified bound 20 equals destination size [-Wstringop-truncation] reduce param to strncpy, to guarantee that a null byte is always copied into destination buffer. Signed-off-by: Len Brown Signed-off-by: Sasha Levin --- diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c index 5d0fddda..78507cd 100644 --- a/tools/power/x86/turbostat/turbostat.c +++ b/tools/power/x86/turbostat/turbostat.c @@ -5323,9 +5323,9 @@ int add_counter(unsigned int msr_num, char *path, char *name, } msrp->msr_num = msr_num; - strncpy(msrp->name, name, NAME_BYTES); + strncpy(msrp->name, name, NAME_BYTES - 1); if (path) - strncpy(msrp->path, path, PATH_BYTES); + strncpy(msrp->path, path, PATH_BYTES - 1); msrp->width = width; msrp->type = type; msrp->format = format;