[PATCH v2 2/2] seq_file: Simplify __seq_puts()
From: Christophe JAILLET
Date: Mon Apr 22 2024 - 06:24:52 EST
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@xxxxxxxxx>
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
---
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