[PATCH] trace: clean up some code

From: Amerigo Wang
Date: Tue May 12 2009 - 03:12:24 EST



64 bytes are big enough to hold "%ld" of any unsigned long, thus no need to
use snprintf.

Plus, kill an unnecessary local variable.

Signed-off-by: WANG Cong <amwang@xxxxxxxxxx>
Cc: Steven Rostedt <rostedt@xxxxxxxxxxx>

---
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index a884c09..c31cc05 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -2641,10 +2641,8 @@ tracing_max_lat_read(struct file *filp, char __user *ubuf,
char buf[64];
int r;

- r = snprintf(buf, sizeof(buf), "%ld\n",
+ r = sprintf(buf, "%ld\n",
*ptr == (unsigned long)-1 ? -1 : nsecs_to_usecs(*ptr));
- if (r > sizeof(buf))
- r = sizeof(buf);
return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
}

diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index c750f65..007e435 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -143,9 +143,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 = sprintf(buf, "%ld\n", *ptr);
return simple_read_from_buffer(ubuf, count, ppos, buf, r);
}

@@ -301,11 +299,7 @@ static const struct seq_operations stack_trace_seq_ops = {

static int stack_trace_open(struct inode *inode, struct file *file)
{
- int ret;
-
- ret = seq_open(file, &stack_trace_seq_ops);
-
- return ret;
+ return seq_open(file, &stack_trace_seq_ops);
}

static const struct file_operations stack_trace_fops = {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/