diff options
author | Peter Huewe <peterhuewe@gmx.de> | 2011-06-07 15:58:27 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2011-06-14 22:48:50 -0400 |
commit | 22fe9b54d859e53bfbbbdc1a0a77a82bc453927c (patch) | |
tree | 4aec2d069decbe0786ad5474908f5bbe49732ad4 /kernel/trace/trace.c | |
parent | 749230b06a753a22f6ed96e5dd60815d6ab12865 (diff) |
tracing: Convert to kstrtoul_from_user
This patch replaces the code for getting an unsigned long from a
userspace buffer by a simple call to kstroul_from_user.
This makes it easier to read and less error prone.
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Link: http://lkml.kernel.org/r/1307476707-14762-1-git-send-email-peterhuewe@gmx.de
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r-- | kernel/trace/trace.c | 65 |
1 files changed, 10 insertions, 55 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index cf22b4bf9896..c977018e87c2 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -2706,20 +2706,11 @@ tracing_ctrl_write(struct file *filp, const char __user *ubuf, | |||
2706 | size_t cnt, loff_t *ppos) | 2706 | size_t cnt, loff_t *ppos) |
2707 | { | 2707 | { |
2708 | struct trace_array *tr = filp->private_data; | 2708 | struct trace_array *tr = filp->private_data; |
2709 | char buf[64]; | ||
2710 | unsigned long val; | 2709 | unsigned long val; |
2711 | int ret; | 2710 | int ret; |
2712 | 2711 | ||
2713 | if (cnt >= sizeof(buf)) | 2712 | ret = kstrtoul_from_user(ubuf, cnt, 10, &val); |
2714 | return -EINVAL; | 2713 | if (ret) |
2715 | |||
2716 | if (copy_from_user(&buf, ubuf, cnt)) | ||
2717 | return -EFAULT; | ||
2718 | |||
2719 | buf[cnt] = 0; | ||
2720 | |||
2721 | ret = strict_strtoul(buf, 10, &val); | ||
2722 | if (ret < 0) | ||
2723 | return ret; | 2714 | return ret; |
2724 | 2715 | ||
2725 | val = !!val; | 2716 | val = !!val; |
@@ -3006,20 +2997,11 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf, | |||
3006 | size_t cnt, loff_t *ppos) | 2997 | size_t cnt, loff_t *ppos) |
3007 | { | 2998 | { |
3008 | unsigned long *ptr = filp->private_data; | 2999 | unsigned long *ptr = filp->private_data; |
3009 | char buf[64]; | ||
3010 | unsigned long val; | 3000 | unsigned long val; |
3011 | int ret; | 3001 | int ret; |
3012 | 3002 | ||
3013 | if (cnt >= sizeof(buf)) | 3003 | ret = kstrtoul_from_user(ubuf, cnt, 10, &val); |
3014 | return -EINVAL; | 3004 | if (ret) |
3015 | |||
3016 | if (copy_from_user(&buf, ubuf, cnt)) | ||
3017 | return -EFAULT; | ||
3018 | |||
3019 | buf[cnt] = 0; | ||
3020 | |||
3021 | ret = strict_strtoul(buf, 10, &val); | ||
3022 | if (ret < 0) | ||
3023 | return ret; | 3005 | return ret; |
3024 | 3006 | ||
3025 | *ptr = val * 1000; | 3007 | *ptr = val * 1000; |
@@ -3474,19 +3456,10 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
3474 | size_t cnt, loff_t *ppos) | 3456 | size_t cnt, loff_t *ppos) |
3475 | { | 3457 | { |
3476 | unsigned long val; | 3458 | unsigned long val; |
3477 | char buf[64]; | ||
3478 | int ret; | 3459 | int ret; |
3479 | 3460 | ||
3480 | if (cnt >= sizeof(buf)) | 3461 | ret = kstrtoul_from_user(ubuf, cnt, 10, &val); |
3481 | return -EINVAL; | 3462 | if (ret) |
3482 | |||
3483 | if (copy_from_user(&buf, ubuf, cnt)) | ||
3484 | return -EFAULT; | ||
3485 | |||
3486 | buf[cnt] = 0; | ||
3487 | |||
3488 | ret = strict_strtoul(buf, 10, &val); | ||
3489 | if (ret < 0) | ||
3490 | return ret; | 3463 | return ret; |
3491 | 3464 | ||
3492 | /* must have at least 1 entry */ | 3465 | /* must have at least 1 entry */ |
@@ -4139,19 +4112,10 @@ trace_options_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
4139 | { | 4112 | { |
4140 | struct trace_option_dentry *topt = filp->private_data; | 4113 | struct trace_option_dentry *topt = filp->private_data; |
4141 | unsigned long val; | 4114 | unsigned long val; |
4142 | char buf[64]; | ||
4143 | int ret; | 4115 | int ret; |
4144 | 4116 | ||
4145 | if (cnt >= sizeof(buf)) | 4117 | ret = kstrtoul_from_user(ubuf, cnt, 10, &val); |
4146 | return -EINVAL; | 4118 | if (ret) |
4147 | |||
4148 | if (copy_from_user(&buf, ubuf, cnt)) | ||
4149 | return -EFAULT; | ||
4150 | |||
4151 | buf[cnt] = 0; | ||
4152 | |||
4153 | ret = strict_strtoul(buf, 10, &val); | ||
4154 | if (ret < 0) | ||
4155 | return ret; | 4119 | return ret; |
4156 | 4120 | ||
4157 | if (val != 0 && val != 1) | 4121 | if (val != 0 && val != 1) |
@@ -4199,20 +4163,11 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt, | |||
4199 | loff_t *ppos) | 4163 | loff_t *ppos) |
4200 | { | 4164 | { |
4201 | long index = (long)filp->private_data; | 4165 | long index = (long)filp->private_data; |
4202 | char buf[64]; | ||
4203 | unsigned long val; | 4166 | unsigned long val; |
4204 | int ret; | 4167 | int ret; |
4205 | 4168 | ||
4206 | if (cnt >= sizeof(buf)) | 4169 | ret = kstrtoul_from_user(ubuf, cnt, 10, &val); |
4207 | return -EINVAL; | 4170 | if (ret) |
4208 | |||
4209 | if (copy_from_user(&buf, ubuf, cnt)) | ||
4210 | return -EFAULT; | ||
4211 | |||
4212 | buf[cnt] = 0; | ||
4213 | |||
4214 | ret = strict_strtoul(buf, 10, &val); | ||
4215 | if (ret < 0) | ||
4216 | return ret; | 4171 | return ret; |
4217 | 4172 | ||
4218 | if (val != 0 && val != 1) | 4173 | if (val != 0 && val != 1) |