From patchwork Tue Aug 28 09:31:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anders Roxell X-Patchwork-Id: 10578083 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 CD33417DB for ; Tue, 28 Aug 2018 09:31:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B433A299FC for ; Tue, 28 Aug 2018 09:31:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7C3829A22; Tue, 28 Aug 2018 09:31:44 +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 8C4DE299FC for ; Tue, 28 Aug 2018 09:31:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727162AbeH1NWN (ORCPT ); Tue, 28 Aug 2018 09:22:13 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:44759 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727130AbeH1NWM (ORCPT ); Tue, 28 Aug 2018 09:22:12 -0400 Received: by mail-lj1-f193.google.com with SMTP id q127-v6so805961ljq.11 for ; Tue, 28 Aug 2018 02:31:25 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=CCrycUkI2igXZYUZAQ5kmKLzX7nJozRTvvvVQw2759c=; b=APtlpFptnLaId7dDomOw0x8P0SSqHIgQ1fIFO03qLvZWIHs/rvQPZ6OVLdpTaDQaNq cKMOT1V+14KWUU8ZMHQeqDEfBBFU89qMOYOhZPf/6iz11twlbPZSMwa9xjeM2NQVm6t9 5GrLTXPyzby3fQ11TzeT/DFzpr0ySc1A53Euo= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CCrycUkI2igXZYUZAQ5kmKLzX7nJozRTvvvVQw2759c=; b=al+q2vxRaVye6D34EzSygJ706AiXK8MmaypBVq3HtMDk8Iei2qa5l7w1UHtMOb7O3Q X6iBH3OJN+ZmihfdhWrbZEcMNmD4zzye+Ahmvf3CqNC5CnFzFD2s4+8JtJF4BsSbY95H NG5ct4VZFa+y4hpQSOeEbj5iNdVP93v/rOZSt+rBsOzDslzpV1KUv+E+Owv9y5+Jt8rL a4MjyUw0SNCiXLwn4jUqf3Q2wGNHWHa1ugVQatTYt59iGKDJUMG3YpVCh5fA/XbmbRsp 7VGeUHwaRZiQjswynCkR0mIyAHSr6k/MCBwrASmZmGfcGZ6CyLHOkv6eADk0NYqq4Uyr uOPw== X-Gm-Message-State: APzg51ClsC9DJFbRlRJo6xxQ25UEpMx3INsCrd4pe20aP2rLxSPzXaQ0 vxhwCeZigCPDTxsNl18d8tVatA== X-Google-Smtp-Source: ANB0VdbYrSkPg38hT7XZsEixyb8ywUart2Hkrl0VVpEajdEVJ/BXHQJ7M4FLY42So7alFAtmrnmWTA== X-Received: by 2002:a2e:9198:: with SMTP id f24-v6mr647817ljg.64.1535448684304; Tue, 28 Aug 2018 02:31:24 -0700 (PDT) Received: from localhost (c-2c3d70d5.07-21-73746f28.bbcust.telenor.se. [213.112.61.44]) by smtp.gmail.com with ESMTPSA id j140-v6sm127633lfg.16.2018.08.28.02.31.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 02:31:23 -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 v2] cpupower: remove stringop-truncation waring Date: Tue, 28 Aug 2018 11:31:18 +0200 Message-Id: <20180828093118.28326-1-anders.roxell@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: References: 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); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The normal method of passing the length of the destination buffer works correctly here. 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..84caee38418f 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;