From patchwork Mon Apr 22 03:31:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13637633 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDAFDC4345F for ; Mon, 22 Apr 2024 03:31:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=PNALivSD7ElLgcPo/UlGgB7rqu7VQTakD9xDhbGjttw=; b=XCusFtA7Dab4Af MWZOg5EPwUci0XX0L4CD9d/c0hfk/sXCT5bXn4CEqt/RkfXNEJia9l5jLvEo+iE1cbJ5tJ84UaOqB 8Phcw/qSqvVVev8KZnnCqmUnghCWeXKictZJMQGp88yZvvR/wI8QvHtMOGZ/w+evi9+7IZyuUBX9k mx8C21IYQyw7TH1Kwf8j2BFWvkVpzyPC4hjSrbvWBb2zzNMNFDm5gZgzi7rkSi5AhdOHM/kXniIG+ Mtw7fCUwkdjmuvqYKm1wfRiiVUMve9DnmhKEqD6fRdYqRPSpGWuXKPSrtg8s1dCgXk7PILWO0tAHz fCBuiDw5pNa1pCk0Pn9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rykOt-0000000BrQ3-1k0V; Mon, 22 Apr 2024 03:31:27 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rykOp-0000000BrNW-1j4k for linux-arm-kernel@lists.infradead.org; Mon, 22 Apr 2024 03:31:25 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1e86d56b3bcso20771885ad.1 for ; Sun, 21 Apr 2024 20:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713756681; x=1714361481; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Li3+1Ghj2slvXiv+/E7e/F9kDJtZLuXuC3BIKi+jfUc=; b=nBQR8aiIOm4CuAHVggCRSmi9I99G/AzCwklEX+dXs6dDQM4Kvym1f1ZaJY7MthUFX/ /Jmz7ul/4CLo1rW8y2H2T76JWp9wa+MhRUzUtgon7vJDA3I+ldN9Gk6+gmN8g/mIxEji 7eBenCKjGJ7e9mKipMtcueDd7pOVG+BIQbuW0KRdc732by7/PbN8eIkyS+FygLEyn87F WUELzDm/5l0jsK3ps1MOrRvP5Fg9wJM4+jPpOGjmVlmZUsb23Lr45usmWvXrZDUFCwqr xMC73kIJHTITmw0+mXZBb7I5Ri7f7wU91kcjqbRQdugjOT6vzN0Lqn0Ljx0vBiBmDIgB CZbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713756681; x=1714361481; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Li3+1Ghj2slvXiv+/E7e/F9kDJtZLuXuC3BIKi+jfUc=; b=qZr6eJ+QWKIEJfqE6OC/Ut/wTfYsOWH9658nQzzuiPKcSrNL2GnEk0tCgCNELcLOjm aEnA3b9G4gL1iS4bJvBe37Yx3tAV8+qLDRGKt/li5UDXA4PEsFzWLbggeEZM31q3CDS7 rFvugdYeR09dkRMZelKRy4zxgsRpMauUZKihbiTmdNXo6v+oQtj6qzT7lsFUkKX2PKFe bE2RHM0f+SsotAeDYLJKskMelmtrJ9Cfe5fPwVkQeiy0qtok+P9qwrmAd7xCNiaovSuz Ux2vl8D7eBf+yh4bCp6KDU/74OWe94YfnEIHUFCqex7DBTI0zCcbojk+k0vKA62xxb23 6z4A== X-Forwarded-Encrypted: i=1; AJvYcCUgbTgIkBARVehnLAJHWkKx6yn8spR9zI0gdkDzYGC72zKwWNDdrP/sYaUi3racQYulwkWGZ0Xwmn2HytHb91sVSnfzSofh6/htW1xXNjuEYWpsT2k= X-Gm-Message-State: AOJu0YyblrXDcMVpGjPZX9X7I1n9llgmm3lepNaUdtRDNmiis80KycXQ QLDDDcGI/0Te9DywpcSKS1GZpHRkFEKYQzHNEaejrXbAJzfgrNMUxw1pHKuqIaw= X-Google-Smtp-Source: AGHT+IEGPELzo18c9HmsXyfk6vYoiNKnZbbOrQi5Dlekvq6DhkR5uumMN7p3RYSBJx4+oqieaxGcdQ== X-Received: by 2002:a17:903:244b:b0:1e5:5041:b18a with SMTP id l11-20020a170903244b00b001e55041b18amr11845236pls.40.1713756680930; Sun, 21 Apr 2024 20:31:20 -0700 (PDT) Received: from localhost ([122.172.87.52]) by smtp.gmail.com with ESMTPSA id w5-20020a1709029a8500b001e435350a7bsm6981020plp.259.2024.04.21.20.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Apr 2024 20:31:20 -0700 (PDT) From: Viresh Kumar To: "Rafael J. Wysocki" , Yangtao Li , Viresh Kumar , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, Vincent Guittot , kernel test robot , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: sun50i: Fix build warning around snprint() Date: Mon, 22 Apr 2024 09:01:09 +0530 Message-Id: <285de20a187f3e4baeb28f639b5bf55e914a3821.1713756666.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240421_203123_533244_7CD54D34 X-CRM114-Status: GOOD ( 12.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The Sun50i driver generates a warning with W=1: warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] Fix it by allocating a big enough array to print an integer. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202404191715.LDwMm2gP-lkp@intel.com/ Signed-off-by: Viresh Kumar Acked-by: Chen-Yu Tsai Reviewed-by: Andre Przywara Tested-by: Andre Przywara Reviewed-by: Julian Calaby --- drivers/cpufreq/sun50i-cpufreq-nvmem.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/sun50i-cpufreq-nvmem.c b/drivers/cpufreq/sun50i-cpufreq-nvmem.c index 30e5c337611c..cd50cea16a87 100644 --- a/drivers/cpufreq/sun50i-cpufreq-nvmem.c +++ b/drivers/cpufreq/sun50i-cpufreq-nvmem.c @@ -19,8 +19,6 @@ #include #include -#define MAX_NAME_LEN 7 - #define NVMEM_MASK 0x7 #define NVMEM_SHIFT 5 @@ -208,7 +206,7 @@ static int sun50i_cpufreq_get_efuse(void) static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) { int *opp_tokens; - char name[MAX_NAME_LEN]; + char name[] = "speedXXXXXXXXXXX"; /* Integers can take 11 chars max */ unsigned int cpu, supported_hw; struct dev_pm_opp_config config = {}; int speed; @@ -235,7 +233,7 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev) config.supported_hw_count = 1; } - snprintf(name, MAX_NAME_LEN, "speed%d", speed); + snprintf(name, sizeof(name), "speed%d", speed); config.prop_name = name; for_each_possible_cpu(cpu) {