lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090512071148.5664.91161.sendpatchset@localhost.localdomain>
Date:	Tue, 12 May 2009 03:11:00 -0400
From:	Amerigo Wang <amwang@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	Steven Rostedt <rostedt@...dmis.org>, akpm@...ux-foundation.org,
	Amerigo Wang <amwang@...hat.com>
Subject: [PATCH] trace: clean up some code


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@...hat.com>
Cc: Steven Rostedt <rostedt@...dmis.org>

---
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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ