public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shuah Khan <skhan@linuxfoundation.org>
To: tglx@linutronix.de, qais.yousef@arm.com, peterz@infradead.org,
	cai@lca.pw, mingo@kernel.org, ethp@qq.com, tyhicks@canonical.com,
	arnd@arndb.de
Cc: Shuah Khan <skhan@linuxfoundation.org>, linux-kernel@vger.kernel.org
Subject: [PATCH] kernel: Use scnprintf() in show_smt_*() instead of snprintf()
Date: Tue,  1 Sep 2020 17:49:30 -0600	[thread overview]
Message-ID: <20200901234930.359126-2-skhan@linuxfoundation.org> (raw)
In-Reply-To: <20200901234930.359126-1-skhan@linuxfoundation.org>

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@linuxfoundation.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


  reply	other threads:[~2020-09-01 23:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 23:49 [PATCH] kernel: events: Use scnprintf() in show_pmu_*() instead of snprintf() Shuah Khan
2020-09-01 23:49 ` Shuah Khan [this message]
2020-09-10 11:15   ` [PATCH] kernel: Use scnprintf() in show_smt_*() " Qais Yousef
2020-09-09  6:45 ` [PATCH] kernel: events: Use scnprintf() in show_pmu_*() " Alexander Shishkin
2020-09-09 16:19   ` Shuah Khan
2020-09-09 17:27     ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200901234930.359126-2-skhan@linuxfoundation.org \
    --to=skhan@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=cai@lca.pw \
    --cc=ethp@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qais.yousef@arm.com \
    --cc=tglx@linutronix.de \
    --cc=tyhicks@canonical.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox