[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200901234930.359126-2-skhan@linuxfoundation.org>
Date: Tue, 1 Sep 2020 17:49:30 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: tglx@...utronix.de, qais.yousef@....com, peterz@...radead.org,
cai@....pw, mingo@...nel.org, ethp@...com, tyhicks@...onical.com,
arnd@...db.de
Cc: Shuah Khan <skhan@...uxfoundation.org>,
linux-kernel@...r.kernel.org
Subject: [PATCH] kernel: Use scnprintf() in show_smt_*() instead of snprintf()
Since snprintf() returns would-be-output size instead of the actual
output size, replace it with scnprintf(), so the show_smt_control(),
and show_smt_active() routines return the actual size.
Signed-off-by: Shuah Khan <skhan@...uxfoundation.org>
---
kernel/cpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 6ff2578ecf17..29a5ceb93cda 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2334,7 +2334,7 @@ show_smt_control(struct device *dev, struct device_attribute *attr, char *buf)
{
const char *state = smt_states[cpu_smt_control];
- return snprintf(buf, PAGE_SIZE - 2, "%s\n", state);
+ return scnprintf(buf, PAGE_SIZE - 2, "%s\n", state);
}
static ssize_t
@@ -2348,7 +2348,7 @@ static DEVICE_ATTR(control, 0644, show_smt_control, store_smt_control);
static ssize_t
show_smt_active(struct device *dev, struct device_attribute *attr, char *buf)
{
- return snprintf(buf, PAGE_SIZE - 2, "%d\n", sched_smt_active());
+ return scnprintf(buf, PAGE_SIZE - 2, "%d\n", sched_smt_active());
}
static DEVICE_ATTR(active, 0444, show_smt_active, NULL);
--
2.25.1
Powered by blists - more mailing lists