| From b9c28f522bf21c64d17064a2620fc71041c4940d Mon Sep 17 00:00:00 2001 |
| From: Len Brown <len.brown@intel.com> |
| Date: Thu, 19 Mar 2020 18:33:12 -0400 |
| Subject: [PATCH] tools/power turbostat: Fix gcc build warnings |
| MIME-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| commit d8d005ba6afa502ca37ced5782f672c4d2fc1515 upstream. |
| |
| 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 <len.brown@intel.com> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c |
| index 5c0154cf190c..eead7b44ce2f 100644 |
| --- a/tools/power/x86/turbostat/turbostat.c |
| +++ b/tools/power/x86/turbostat/turbostat.c |
| @@ -5302,9 +5302,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; |
| -- |
| 2.7.4 |
| |