All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jules Irenge <jbi.octave@gmail.com>
To: tglx@linutronix.de
Cc: steven.price@arm.com, sathyanarayanan.kuppuswamy@linux.intel.com,
	linux-kernel@vger.kernel.org, dave.hansen@linux.intel.com,
	ak@linux.intel.com, Jason@zx2c4.com
Subject: [PATCH 5/7] kernel/cpu: Convert snprintf() to scnprintf()
Date: Mon, 26 Sep 2022 19:52:07 +0100	[thread overview]
Message-ID: <YzH01+6fErqu2Roo@fedora> (raw)

Coccinnelle reports a warning
Warning: Use scnprintf or sprintf
Adding to that, there has been a slow migration from snprintf to scnprintf.
This LWN article explains the rationale for this change
https: //lwn.net/Articles/69419/
Ie. snprintf() returns what *would* be the resulting length,
while scnprintf() returns the actual length.

Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
---
 kernel/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index bbad5e375d3b..f358d89c9580 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -2512,7 +2512,7 @@ static ssize_t control_show(struct device *dev,
 {
 	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 control_store(struct device *dev, struct device_attribute *attr,
@@ -2525,7 +2525,7 @@ static DEVICE_ATTR_RW(control);
 static ssize_t active_show(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_RO(active);
 
-- 
2.37.3


             reply	other threads:[~2022-09-26 18:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-26 18:52 Jules Irenge [this message]
2022-09-28  9:35 ` [PATCH 5/7] kernel/cpu: Convert snprintf() to scnprintf() Steven Price

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=YzH01+6fErqu2Roo@fedora \
    --to=jbi.octave@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=ak@linux.intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=steven.price@arm.com \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.