public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	akpm@osdl.org, Peter Zijlstra <peterz@infradead.org>,
	Soeren Sandmann Pedersen <sandmann@redhat.com>,
	Pekka Paalanen <pq@iki.fi>, Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 2/5] ftrace: replace simple_strtoul with strict_strtoul
Date: Fri, 18 Apr 2008 16:05:40 -0400	[thread overview]
Message-ID: <20080418200850.141548878@goodmis.org> (raw)
In-Reply-To: 20080418200538.788522018@goodmis.org

[-- Attachment #1: ftrace-use-strict_strtoul.patch --]
[-- Type: text/plain, Size: 2295 bytes --]

Andrew Morton suggested using strict_strtoul over simple_strtoul.
This patch replaces them in ftrace.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
---
 kernel/trace/trace.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

Index: linux-sched-devel.git/kernel/trace/trace.c
===================================================================
--- linux-sched-devel.git.orig/kernel/trace/trace.c	2008-04-18 15:47:40.000000000 -0400
+++ linux-sched-devel.git/kernel/trace/trace.c	2008-04-18 15:49:09.000000000 -0400
@@ -92,9 +92,16 @@ void trace_wake_up(void)
 
 static int __init set_nr_entries(char *str)
 {
+	unsigned long nr_entries;
+	int ret;
+
 	if (!str)
 		return 0;
-	trace_nr_entries = simple_strtoul(str, &str, 0);
+	ret = strict_strtoul(str, 0, &nr_entries);
+	/* nr_entries can not be zero */
+	if (ret < 0 || nr_entries == 0)
+		return 0;
+	trace_nr_entries = nr_entries;
 	return 1;
 }
 __setup("trace_entries=", set_nr_entries);
@@ -2050,8 +2057,9 @@ tracing_ctrl_write(struct file *filp, co
 		   size_t cnt, loff_t *ppos)
 {
 	struct trace_array *tr = filp->private_data;
-	long val;
 	char buf[64];
+	long val;
+	int ret;
 
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
@@ -2061,7 +2069,9 @@ tracing_ctrl_write(struct file *filp, co
 
 	buf[cnt] = 0;
 
-	val = simple_strtoul(buf, NULL, 10);
+	ret = strict_strtoul(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 
 	val = !!val;
 
@@ -2165,8 +2175,9 @@ tracing_max_lat_write(struct file *filp,
 		      size_t cnt, loff_t *ppos)
 {
 	long *ptr = filp->private_data;
-	long val;
 	char buf[64];
+	long val;
+	int ret;
 
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
@@ -2176,7 +2187,9 @@ tracing_max_lat_write(struct file *filp,
 
 	buf[cnt] = 0;
 
-	val = simple_strtoul(buf, NULL, 10);
+	ret = strict_strtoul(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 
 	*ptr = val * 1000;
 
@@ -2432,6 +2445,7 @@ tracing_entries_write(struct file *filp,
 {
 	unsigned long val;
 	char buf[64];
+	int ret;
 
 	if (cnt >= sizeof(buf))
 		return -EINVAL;
@@ -2441,7 +2455,9 @@ tracing_entries_write(struct file *filp,
 
 	buf[cnt] = 0;
 
-	val = simple_strtoul(buf, NULL, 10);
+	ret = strict_strtoul(buf, 10, &val);
+	if (ret < 0)
+		return ret;
 
 	/* must have at least 1 entry */
 	if (!val)

-- 

  parent reply	other threads:[~2008-04-18 20:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-18 20:05 [PATCH 0/5] ftrace update patches Steven Rostedt
2008-04-18 20:05 ` [PATCH 1/5] ftrace: simple clean ups Steven Rostedt
2008-04-18 20:15   ` Andrew Morton
2008-04-19  3:09     ` Steven Rostedt
2008-04-19  3:11     ` [PATCH 1/5 -v2] " Steven Rostedt
2008-04-18 20:05 ` Steven Rostedt [this message]
2008-04-18 20:05 ` [PATCH 3/5] ftrace: modulize the number of CPU buffers Steven Rostedt
2008-04-18 20:05 ` [PATCH 4/5] ftrace: limit trace entries Steven Rostedt
2008-04-18 20:19   ` Andrew Morton
2008-04-19  3:12     ` Steven Rostedt
2008-04-19  3:32       ` Andrew Morton
2008-04-19  3:17     ` [PATCH 4/5 -v2] " Steven Rostedt
2008-04-19  6:10     ` [PATCH 4/5] " Ingo Molnar
2008-04-18 20:05 ` [PATCH 5/5] ftrace: comment code Steven Rostedt
2008-04-19  6:11 ` [PATCH 0/5] ftrace update patches Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080418200850.141548878@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=pq@iki.fi \
    --cc=sandmann@redhat.com \
    --cc=srostedt@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox