From patchwork Tue Aug 21 12:02:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 144714 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp5181541ljj; Tue, 21 Aug 2018 05:02:35 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxVyEGsZkrpj4hpy2EC3n3+hIGENRaeKodHf/Z9WUvuCBFTXS+l6llAcj216Tavgw2/+V1q X-Received: by 2002:a63:ee15:: with SMTP id e21-v6mr21054539pgi.421.1534852955228; Tue, 21 Aug 2018 05:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534852955; cv=none; d=google.com; s=arc-20160816; b=WQQHQmuUuTxCpRo2tQ3tRg4zMOnWkI0+v4XLeLy7AWObbSGYd2oVwjFC8wSXQfN2/W H4P31zG+A/Z2iwH1d4r4sgMRT7U2EmdGj3rospMfyFkzHl1H0t8icZjxpo3xqC4Gus33 VZsPC2PFvNiHnmfa1rGOn8j3EjaWBtkdkmFx8N+Qm+jwznCDKXLUKA/SHCOnO0ThEtis 01lYCuLviK0yX3nDWeGkKGf20Zc7a27ChCWUlT+C7UD+VmXT2QLoJQKQlKzqDAieEmPe YWok2pOcitW7ud5S+ZkGFnUoBy7JzcKw2+1MkepuVouTo4KplgWHAzYmzgckCjOekkx7 CaAA== 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:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=ASEXKtE9J3QGtrXxj8rWJowtdn/xKqROXNTd0odm7rg=; b=prbUpX+K/mPwewpFN1AKcITUiwv44wA3Pa3WBBHjYhZ/h9vbQ+YfbsCytaG4PyCgrk rzdleBPBEnVhRlaSYdJdwX0FVr1YnbvUGkcaKVDkKCxshaNrg3DEl28/3yUoEBCOghxQ mhELosgLjCA+JWa6IlRyVRfoHOrH5DQ4nlNbUO73dsSMaIqig3H3Bo0RTztQvr8iyWJy bc9UY0TM3Qb2UvGzjyEUlKoDppFK6FP4I8pm73u03xxDim2SqUYxca1u2u34s/NLH1eC rHX7taHN31GgCXLtN/aPf3N9c1aIvneLh0vdE8cewjLCeCAFTGdNpBrmZbgQ/HOmpUg8 Vn2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SIxSKjjD; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n31-v6si1214512pgb.602.2018.08.21.05.02.34; Tue, 21 Aug 2018 05:02:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SIxSKjjD; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbeHUPW0 (ORCPT + 10 others); Tue, 21 Aug 2018 11:22:26 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:36511 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726938AbeHUPW0 (ORCPT ); Tue, 21 Aug 2018 11:22:26 -0400 Received: by mail-lj1-f196.google.com with SMTP id u7-v6so14109042lji.3 for ; Tue, 21 Aug 2018 05:02:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ASEXKtE9J3QGtrXxj8rWJowtdn/xKqROXNTd0odm7rg=; b=SIxSKjjD8de5Dj7M2/G6qMTTSSTSaRJyL/moXpUvTh+A+iwzYZyfgfwtQCab8qxByv O8h2MxRd9oXSqrlJ3QEueM2vCrwBnHRBaEEJQN6ssyv8nq1Jn7f1ZXOg+haSHj8oBYZ3 5U18O7BwLedAy5aYM1WW8acbLu8Sb+mkpXEEs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ASEXKtE9J3QGtrXxj8rWJowtdn/xKqROXNTd0odm7rg=; b=Cy5gmyjlmWcEgn4bQxK6v6XBip/LbpG4nAzZ5kl1owDRwh70phFeL0cn0KWApfBGLj 7jPn4nU8xI2MrvrWOm8+RCCLaidS4VELyawUa/VehYlJv0dGNCa6JSw+LpkZCsANUakd u6MHbknP80D6Qihuk/4fVM0PaaNWiGYHa9laKY0h2K0naFk94ExDCPM/ORJv3Qjy30OL EQ/pQzv4gupAhhi9UkgTfi7Ma3p0SqvSLOl9IvuJKzBKOKs391wehxoOcFRMavQHeArq RCslJCL1pxTESGLaFT4ebIbrXR7BOC+e8MOE2XKPu6nNCFirN3+qG5GlI76TNwb+CEkc ySpg== X-Gm-Message-State: AOUpUlELZkxRK/SfB/C0RXEvhi1bJEQ2noi5g7wraj5SkKo6BVQQKgQ4 5Sf0XLbRC/+VA64nlvjkZ4reog== X-Received: by 2002:a2e:97c8:: with SMTP id m8-v6mr36334195ljj.52.1534852951686; Tue, 21 Aug 2018 05:02:31 -0700 (PDT) Received: from localhost (c-2c3d70d5.07-21-73746f28.bbcust.telenor.se. [213.112.61.44]) by smtp.gmail.com with ESMTPSA id u19-v6sm2059688lje.51.2018.08.21.05.02.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Aug 2018 05:02:31 -0700 (PDT) From: Anders Roxell To: trenn@suse.com, shuah@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Anders Roxell Subject: [PATCH] cpupower: remove stringop-truncation waring Date: Tue, 21 Aug 2018 14:02:25 +0200 Message-Id: <20180821120225.3516-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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(-) -- 2.18.0 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"); config->output = stdout;