[PATCH] Reduce the sysfs path to 2K to work around a gcc warning

Colin King colin.king at canonical.com
Fri Apr 28 17:20:54 UTC 2017


From: Colin Ian King <colin.king at canonical.com>

2K for a sysfs path is more than plenty of space, plus it fixes
a new funcky gcc 7 warning when building with -Wall:

cpu/cpufreq/cpufreq.c:85:26: error: ‘%s’ directive output may be
 truncated writing up to 4095 bytes into a region of size 4072
 [-Werror=format-truncation=]
   snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,...

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/cpu/cpufreq/cpufreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cpu/cpufreq/cpufreq.c b/src/cpu/cpufreq/cpufreq.c
index 81751866..1cfac3aa 100644
--- a/src/cpu/cpufreq/cpufreq.c
+++ b/src/cpu/cpufreq/cpufreq.c
@@ -51,7 +51,7 @@ typedef struct {
 
 struct cpu {
 	int		idx;
-	char		sysfs_path[PATH_MAX];
+	char		sysfs_path[2048];	/* 2K is plenty */
 	bool		online;
 	bool		master;
 
@@ -85,7 +85,7 @@ static inline void cpu_mkpath(
 	snprintf(path, len, "%s/%s/cpufreq%s%s", FWTS_CPU_PATH,
 			cpu->sysfs_path,
 			name ? "/" : "",
-			name ?: "");
+			name ? name : "");
 }
 
 static int cpu_set_governor(fwts_framework *fw, struct cpu *cpu,
-- 
2.11.0




More information about the fwts-devel mailing list