[PATCH] cpu: maxfreq: fix build errors on arm32 + gcc10
Alex Hung
alex.hung at canonical.com
Fri Jan 8 14:38:06 UTC 2021
The below errors were observed on armhf with Groovy and Hirsute
cpu/maxfreq/maxfreq.c:28:23: error: ‘%s’ directive output may be
truncated writing between 3 and 2147483645 bytes into a region of
size 4072 [-Werror=format-truncation=]
28 | #define CPU_FREQ_PATH "/sys/devices/system/cpu"
| ^~~~~~~~~~~~~~~~~~~~~~~~~
cpu/maxfreq/maxfreq.c:143:4: note: in expansion of macro ‘CPU_FREQ_PATH’
143 | CPU_FREQ_PATH "/%s/cpufreq/scaling_available_frequencies",
| ^~~~~~~~~~~~~
cpu/maxfreq/maxfreq.c:143:20: note: format string is defined here
143 | CPU_FREQ_PATH "/%s/cpufreq/scaling_available_frequencies",
| ^~
Signed-off-by: Alex Hung <alex.hung at canonical.com>
---
src/cpu/maxfreq/maxfreq.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/src/cpu/maxfreq/maxfreq.c b/src/cpu/maxfreq/maxfreq.c
index 168a69e8..b0ce0fe9 100644
--- a/src/cpu/maxfreq/maxfreq.c
+++ b/src/cpu/maxfreq/maxfreq.c
@@ -139,9 +139,9 @@ static int maxfreq_test1(fwts_framework *fw)
strlen(entry->d_name) < 3)
continue;
- snprintf(path, sizeof(path),
- CPU_FREQ_PATH "/%s/cpufreq/scaling_available_frequencies",
- entry->d_name);
+ strncpy(path, CPU_FREQ_PATH, strlen(CPU_FREQ_PATH) + 1);
+ snprintf(path + strlen(CPU_FREQ_PATH), sizeof(path) - strlen(CPU_FREQ_PATH),
+ "/%s/cpufreq/scaling_available_frequencies", entry->d_name);
if ((data = fwts_get(path)) == NULL)
continue;
@@ -214,4 +214,3 @@ static fwts_framework_ops maxfreq_ops = {
};
FWTS_REGISTER("maxfreq", &maxfreq_ops, FWTS_TEST_ANYTIME, FWTS_FLAG_BATCH)
-
--
2.25.1
More information about the fwts-devel
mailing list