From 3927d5ba6b2bd8dd12db9a349426761b8e6b75f9 Mon Sep 17 00:00:00 2001 From: Anders Roxell Date: Tue, 28 Aug 2018 11:31:18 +0200 Subject: [PATCH] cpupower: remove stringop-truncation waring MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The strncpy doesn't null terminate the string because the size is too short by one byte. parse.c: In function ‘prepare_default_config’: parse.c:148:2: warning: ‘strncpy’ output truncated before terminating nul copying 8 bytes from a string of the same length [-Wstringop-truncation] strncpy(config->governor, "ondemand", 8); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The normal method of passing the length of the destination buffer works correctly here. Fixes: 36675b894d54 ("cpupowerutils - cpufrequtils extended with quite some features") Signed-off-by: Anders Roxell Signed-off-by: Shuah Khan (Samsung OSG) --- tools/power/cpupower/bench/parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/cpupower/bench/parse.c b/tools/power/cpupower/bench/parse.c index 9ba8a44ad2a71..84caee38418f0 100644 --- a/tools/power/cpupower/bench/parse.c +++ b/tools/power/cpupower/bench/parse.c @@ -145,7 +145,7 @@ struct config *prepare_default_config() config->cpu = 0; config->prio = SCHED_HIGH; config->verbose = 0; - strncpy(config->governor, "ondemand", 8); + strncpy(config->governor, "ondemand", sizeof(config->governor)); config->output = stdout; -- 2.39.5