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

From: Alexey Dobriyan
Date: Mon Apr 20 2020 - 16:58:24 EST


Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxxxx>
---
fs/proc/fd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

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();
--
2.24.1