[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7cebc1412d8d1338a7e52cc9291d00f5368c14e4.1713781332.git.christophe.jaillet@wanadoo.fr>
Date: Mon, 22 Apr 2024 12:24:07 +0200
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: David.Laight@...LAB.COM,
rasmus.villemoes@...vas.dk,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>
Cc: linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>,
linux-fsdevel@...r.kernel.org
Subject: [PATCH v2 2/2] seq_file: Simplify __seq_puts()
Change the implementation of the out-of-line __seq_puts() to simply be
a seq_write() call instead of duplicating the overflow/memcpy logic.
Suggested-by: Rasmus Villemoes <rasmus.villemoes@...vas.dk>
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
Changes in v2:
- New patch
Now than most (if not all) seq_puts() calls will be turned into a
seq_write() or seq_putc() at compilation time, the added function call in
__seq_puts() should not be noticeable.
It could be even better to just remove this __seq_puts() and call
seq_write(m, s, strlen(s)) directly in seq_puts() if it can't be
optimized at compile time.
---
fs/seq_file.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/fs/seq_file.c b/fs/seq_file.c
index 8ef0a07033ca..e676c8b0cf5d 100644
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -671,14 +671,7 @@ EXPORT_SYMBOL(seq_putc);
void __seq_puts(struct seq_file *m, const char *s)
{
- int len = strlen(s);
-
- if (m->count + len >= m->size) {
- seq_set_overflow(m);
- return;
- }
- memcpy(m->buf + m->count, s, len);
- m->count += len;
+ seq_write(m, s, strlen(s));
}
EXPORT_SYMBOL(__seq_puts);
--
2.44.0
Powered by blists - more mailing lists