[PATCH 2/5] ftrace: replace simple_strtoul with strict_strtoul

From: Steven Rostedt
Date: Fri Apr 18 2008 - 16:09:29 EST


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

Signed-off-by: Steven Rostedt <srostedt@xxxxxxxxxx>
---
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)

--
--
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/