linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] proc: stop using seq_get_buf in proc_task_name
@ 2021-08-10 15:19 Christoph Hellwig
  2021-08-11  9:10 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2021-08-10 15:19 UTC (permalink / raw)
  To: akpm; +Cc: linux-fsdevel, linux-kernel

Use seq_escape_str and seq_printf instead of poking holes into the
seq_file abstraction.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/proc/array.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/fs/proc/array.c b/fs/proc/array.c
index ee0ce8cecc4a..49be8c8ef555 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -98,27 +98,17 @@
 
 void proc_task_name(struct seq_file *m, struct task_struct *p, bool escape)
 {
-	char *buf;
-	size_t size;
 	char tcomm[64];
-	int ret;
 
 	if (p->flags & PF_WQ_WORKER)
 		wq_worker_comm(tcomm, sizeof(tcomm), p);
 	else
 		__get_task_comm(tcomm, sizeof(tcomm), p);
 
-	size = seq_get_buf(m, &buf);
-	if (escape) {
-		ret = string_escape_str(tcomm, buf, size,
-					ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\");
-		if (ret >= size)
-			ret = -1;
-	} else {
-		ret = strscpy(buf, tcomm, size);
-	}
-
-	seq_commit(m, ret);
+	if (escape)
+		seq_escape_str(m, tcomm, ESCAPE_SPACE | ESCAPE_SPECIAL, "\n\\");
+	else
+		seq_printf(m, "%.64s", tcomm);
 }
 
 /*
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] proc: stop using seq_get_buf in proc_task_name
  2021-08-10 15:19 [PATCH] proc: stop using seq_get_buf in proc_task_name Christoph Hellwig
@ 2021-08-11  9:10 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2021-08-11  9:10 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: akpm, linux-fsdevel, linux-kernel

On Tue, Aug 10, 2021 at 05:19:45PM +0200, Christoph Hellwig wrote:
> Use seq_escape_str and seq_printf instead of poking holes into the
> seq_file abstraction.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Thanks! Looks good.
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-11  9:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10 15:19 [PATCH] proc: stop using seq_get_buf in proc_task_name Christoph Hellwig
2021-08-11  9:10 ` Christian Brauner

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).