Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6166398imm; Mon, 27 Aug 2018 10:49:09 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaj+a+CL9eg4ghwueuD5/i9yEZQMZtTFkGAsEDgk4GaRZTpNclexb3xJBSkOA0lbOwdxs28 X-Received: by 2002:a62:4e56:: with SMTP id c83-v6mr12191314pfb.240.1535392149003; Mon, 27 Aug 2018 10:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535392148; cv=none; d=google.com; s=arc-20160816; b=yBHh3tdF9RC42xWRFyeI39WU7TYaXjeM36TS3jIvJYToeo8tJXmI9uhUG0mueiQZnz teoJypYNnNK6m8qKjWVNfK95rgQKePiVuxIFZyIRoAYWY4N60bsJADawkQ1PArav6UIk Z+sYX7vkXuHZRxl0qfj7JAdyi9CL/rhIu6tf544a/Nst7ycll8RuyLK7i3tbBRYE4oDP WLkglQwha4/Lr9F28KbUnvVl+V5D7JI2fMrz6A3fDL1sl0fmoyWnr2a5BKDwWwCK+7Gx jD+XMoUwl3jTmPM3gf/FzgSEGTWiPJN+Sq8mWH44qyYc9UCHsbAshavYOusNrS174OfN ckcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=5CXHMxE7mPk2XXOLTqpwqS3NqGxHFtZR6O7NoWF37rc=; b=Pc/27vnkI3RlVCjVLWrdKvyDd/wkxN9+YvSMCteDsJYJGhlJEqurkNsjUU9ef6VO9D GK8eRkMtzF0UN72wLUI6bSPr6Rk2LaThuQQMbXvN6Ljs61uRGqBcd9kO0pLLU2FjWLVq NJ96AB6CGiWFIxG2IrAmdumLvopM2JUotMA5n7n3IH12Ea11Zd3PLrFWpRMiX0RKnchm JEAv3+0mjUIe4LpZ6xMqwCH6MQhQ+BACvMzum9uc3EYLK7q+XuQ32fHlD/PSER+oXhwm pN0yLhZwstEquL7Ae2yhKAb6VnpCvHTUlcCrf/K/YOgBTHHmuK9Z4zGeifqZphIIp7YW EoEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a140-v6si16768294pfa.61.2018.08.27.10.48.53; Mon, 27 Aug 2018 10:49:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727265AbeH0Vek (ORCPT + 99 others); Mon, 27 Aug 2018 17:34:40 -0400 Received: from mailout.easymail.ca ([64.68.200.34]:58318 "EHLO mailout.easymail.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726958AbeH0Vek (ORCPT ); Mon, 27 Aug 2018 17:34:40 -0400 Received: from localhost (localhost [127.0.0.1]) by mailout.easymail.ca (Postfix) with ESMTP id 45A7F21388; Mon, 27 Aug 2018 17:47:06 +0000 (UTC) Received: from mailout.easymail.ca ([127.0.0.1]) by localhost (emo02-pco.easydns.vpn [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CaXPrkDzHIZ6; Mon, 27 Aug 2018 17:47:06 +0000 (UTC) Received: from [192.168.1.87] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailout.easymail.ca (Postfix) with ESMTPSA id 3B6572143A; Mon, 27 Aug 2018 17:46:59 +0000 (UTC) Subject: Re: [PATCH] cpupower: remove stringop-truncation waring To: Anders Roxell , trenn@suse.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20180821120225.3516-1-anders.roxell@linaro.org> From: Shuah Khan Message-ID: Date: Mon, 27 Aug 2018 11:46:49 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180821120225.3516-1-anders.roxell@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/21/2018 06:02 AM, Anders Roxell wrote: > 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); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Passing the length of the input argument to strncpy() is almost always > wrong and provides no extra benefit over strcpy(), and since 'ondemand' > fits within 15 bytes" and it null terminates the string its safe to use > strcpy(). > > Fixes: 7fe2f6399a84 ("cpupowerutils - cpufrequtils extended with quite some features") > Signed-off-by: Anders Roxell > --- > 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 9ba8a44ad2a7..91b5b768ffd2 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); > + strcpy(config->governor, "ondemand"); This change is fine, however continuing to use strncpy with sizeof(config->governor). thanks, -- Shuah