Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5042665imm; Tue, 21 Aug 2018 05:27:34 -0700 (PDT) X-Google-Smtp-Source: AA+uWPweCAMpZMVKyhienvmhT0Uf2nw90nE5u+uKolHwyoQP4H4hYGTYkIshzGa76HqFJKTC1vW3 X-Received: by 2002:a63:dc53:: with SMTP id f19-v6mr47181512pgj.56.1534854454336; Tue, 21 Aug 2018 05:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534854454; cv=none; d=google.com; s=arc-20160816; b=g6iW2N7jY3A+YuLRij7mSavQbOiHvpYHjOdOYiWvM8rhr4jYahuqX8aAFUR96SKeay WlpNavyFanDhpUprc7BLfP68EnG/Omg2wk8ackJAr5IGZB+q9wQdFfVKWxkfQrHJ7Vpw MQXopeYJ+61kRGiHim6+ZjiUSxVs/V71eO6ooMIeufJqVkoxQ1OScawo1zipg/Ze9eya ejIMht1uI2Mexc9RWq5Hl4uxQednS2+JgMfzJ2NFIbnon2nDia8tmg8OxZsYWC04BhBb ngEVhsBg3yqpEZzmiKb+8/Rsg5w3Vg3XqvOdLjf/Mc9u6OjjbHypKfLrOJRd+yVoyhv7 h3Pg== 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=ihZ2xSQju1DcJc0e3crTjryI+4wPzmWhP+meg4jIv4ey8OGxTFUJ2flPuHbbzKaSAo qAi0EeX+h4upKh1YliGqCuhTiTfYe+uY9qx+J9Sa23S2cvSxQtlLTKuPoV+EdlnJ0vd1 HDRDpF9zBpv4/JetmdSyk4Bj33fzmwaqYV0KlpIOt58MITKFIqtH3NqRNUgCpV0P3S1J 6Y9t1MW1ALEbhbyTlOHoOt8ac1PdGSClMH7O+2/9TXKAN/qsMQL5tQ3pVmXF1Emr+wNx BxMkWFDF2xsUxd7D0pyfAIrCfsmx8S2kvWqbY70UM3VkHrSaMlZ4egY1h4oVODgu67yZ NUXg== 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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 x61-v6si12634493plb.216.2018.08.21.05.27.18; Tue, 21 Aug 2018 05:27:34 -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; dkim=pass header.i=@linaro.org header.s=google header.b=SIxSKjjD; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727353AbeHUPW0 (ORCPT + 99 others); Tue, 21 Aug 2018 11:22:26 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:33381 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727162AbeHUPW0 (ORCPT ); Tue, 21 Aug 2018 11:22:26 -0400 Received: by mail-lj1-f195.google.com with SMTP id s12-v6so14099470ljj.0 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=ZhVcDH49uMp2lHTyqeh+TUXmw2M35VwdG+u4g9T4WOUB9XXb1/b6YCxdAwA4FuKFZB njUreBlEtnvYByi889c7LwT8BoVycn7ZBt+y3Bfaxwb7lLw0PDk36tW31JTnIJ6HhagC z2uAqMjYyqi/LBlCnXRQWKwFEK1hunjS1kB/fMfBS6ImvoTUp+OKK22fJm+mzDT4x9Fb JYbaruh2+1cXIv0KAx1N8PCZPdr68gmtAK7iZ7zxKjwYvme7mXiwyDLZYDp6xobdWVn1 a1o33Ti5D0ruddd7bk2aG4ouNiDfcUGc+KdMhd8ovLG3NJwxr6NXLycf8COzHaYvAMx1 /Nig== X-Gm-Message-State: AOUpUlHxl+LbaWE02Fqaegi03VL3g/OUkz5sFlcFg/6i+ZTxFrrKM4// WE72uN2IuxTjxIHAaw5oTeivJQ== 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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; -- 2.18.0