diff mbox series

[10/15] print_integer, proc: rewrite /proc/*/fd via print_integer()

Message ID 20200420205743.19964-10-adobriyan@gmail.com (mailing list archive)
State New, archived
Headers show
Series [01/15] sched: make nr_running() return "unsigned int" | expand

Commit Message

Alexey Dobriyan April 20, 2020, 8:57 p.m. UTC
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
 fs/proc/fd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index e098302b5101..059a3404c785 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -247,8 +247,8 @@  static int proc_readfd_common(struct file *file, struct dir_context *ctx,
 	     fd++, ctx->pos++) {
 		struct file *f;
 		struct fd_data data;
-		char name[10 + 1];
-		unsigned int len;
+		char buf[10];
+		char *p = buf + sizeof(buf);
 
 		f = fcheck_files(files, fd);
 		if (!f)
@@ -257,9 +257,9 @@  static int proc_readfd_common(struct file *file, struct dir_context *ctx,
 		rcu_read_unlock();
 		data.fd = fd;
 
-		len = snprintf(name, sizeof(name), "%u", fd);
+		p = _print_integer_u32(p, fd);
 		if (!proc_fill_cache(file, ctx,
-				     name, len, instantiate, tsk,
+				     p, buf + sizeof(buf) - p, instantiate, tsk,
 				     &data))
 			goto out_fd_loop;
 		cond_resched();