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: 10571407 X-Patchwork-Delegate: shuah@kernel.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4DB68921 for ; Tue, 21 Aug 2018 12:02:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4567B2913F for ; Tue, 21 Aug 2018 12:02:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3951429F53; Tue, 21 Aug 2018 12:02:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6DE529F50 for ; Tue, 21 Aug 2018 12:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727257AbeHUPW0 (ORCPT ); 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-Google-Smtp-Source: AA+uWPz7l6V/1e60fNx4uJZqpBiZFQdU3twS8gLWwy4a510sOTlrYO3nBCKWI+Qj4oOKL6sgIOMJwQ== 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 X-Virus-Scanned: ClamAV using ClamSMTP 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"); config->output = stdout;