[PATCH] trace: code optimization
From: liuyang34
Date: Thu Jan 09 2020 - 04:12:25 EST
use scnprintf instead of snprinr and no need to check
the return size again
Signed-off-by: liuyang34 <liuyang34@xxxxxxxxxx>
---
kernel/trace/trace_stack.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index c557f42..7b15e9a 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -329,9 +329,7 @@ stack_max_size_read(struct file *filp, char __user *ubuf,
char buf[64];
int r;
- r = snprintf(buf, sizeof(buf), "%ld\n", *ptr);
- if (r > sizeof(buf))
- r = sizeof(buf);
+ r = scnprintf(buf, sizeof(buf), "%ld\n", *ptr);
return simple_read_from_buffer(ubuf, count, ppos, buf, r);
}
--
2.7.4