* [PATCH] fs/ecryptfs: use scnprintf() in version show
@ 2025-06-16 10:41 Pranav Tyagi
2025-06-16 14:21 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Pranav Tyagi @ 2025-06-16 10:41 UTC (permalink / raw)
To: code
Cc: brauner, sandeen, colin.i.king, skhan, ecryptfs, linux-kernel,
linux-kernel-mentees, Pranav Tyagi
Replace all snprintf() instances with scnprintf(). snprintf() returns
the number of bytes that would have been written had there been enough
space. For sysfs attributes, snprintf() should not be used for the
show() method. Instead use scnprintf() which returns the number of
bytes actually written.
Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
---
fs/ecryptfs/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index 8dd1d7189c3b..2a97c2b1fc69 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -764,7 +764,7 @@ static struct kobject *ecryptfs_kobj;
static ssize_t version_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buff)
{
- return snprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
+ return scnprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
}
static struct kobj_attribute version_attr = __ATTR_RO(version);
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] fs/ecryptfs: use scnprintf() in version show
2025-06-16 10:41 [PATCH] fs/ecryptfs: use scnprintf() in version show Pranav Tyagi
@ 2025-06-16 14:21 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2025-06-16 14:21 UTC (permalink / raw)
To: Pranav Tyagi
Cc: code, brauner, sandeen, colin.i.king, skhan, ecryptfs,
linux-kernel, linux-kernel-mentees
On Mon, Jun 16, 2025 at 04:11:20PM +0530, Pranav Tyagi wrote:
> Replace all snprintf() instances with scnprintf(). snprintf() returns
> the number of bytes that would have been written had there been enough
> space. For sysfs attributes, snprintf() should not be used for the
> show() method. Instead use scnprintf() which returns the number of
> bytes actually written.
>
> Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
> ---
> fs/ecryptfs/main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
> index 8dd1d7189c3b..2a97c2b1fc69 100644
> --- a/fs/ecryptfs/main.c
> +++ b/fs/ecryptfs/main.c
> @@ -764,7 +764,7 @@ static struct kobject *ecryptfs_kobj;
> static ssize_t version_show(struct kobject *kobj,
> struct kobj_attribute *attr, char *buff)
> {
> - return snprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
> + return scnprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
sysfs_emit() or no change at all please.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-16 14:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 10:41 [PATCH] fs/ecryptfs: use scnprintf() in version show Pranav Tyagi
2025-06-16 14:21 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).