diff options
author | Pekka Enberg <penberg@cs.helsinki.fi> | 2006-06-23 05:05:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-23 10:43:06 -0400 |
commit | 66f969d064e46e6690c3426e2af846e76fb80e83 (patch) | |
tree | 3a1ab9196b5811ec287969a36dee12911fbd22f1 | |
parent | 481fad483487ea967fe20bbc9e565d787f7bf20f (diff) |
[PATCH] ipmi: strstrip conversion
Switch an open-coded strstrip() to use the new API.
Acked-by: Corey Minyard <minyard@acm.org>
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | drivers/char/ipmi/ipmi_watchdog.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 2d11ddd99e55..8f8867170973 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c | |||
@@ -212,24 +212,16 @@ static int set_param_str(const char *val, struct kernel_param *kp) | |||
212 | { | 212 | { |
213 | action_fn fn = (action_fn) kp->arg; | 213 | action_fn fn = (action_fn) kp->arg; |
214 | int rv = 0; | 214 | int rv = 0; |
215 | const char *end; | 215 | char *dup, *s; |
216 | char valcp[16]; | 216 | |
217 | int len; | 217 | dup = kstrdup(val, GFP_KERNEL); |
218 | 218 | if (!dup) | |
219 | /* Truncate leading and trailing spaces. */ | 219 | return -ENOMEM; |
220 | while (isspace(*val)) | 220 | |
221 | val++; | 221 | s = strstrip(dup); |
222 | end = val + strlen(val) - 1; | ||
223 | while ((end >= val) && isspace(*end)) | ||
224 | end--; | ||
225 | len = end - val + 1; | ||
226 | if (len > sizeof(valcp) - 1) | ||
227 | return -EINVAL; | ||
228 | memcpy(valcp, val, len); | ||
229 | valcp[len] = '\0'; | ||
230 | 222 | ||
231 | down_read(®ister_sem); | 223 | down_read(®ister_sem); |
232 | rv = fn(valcp, NULL); | 224 | rv = fn(s, NULL); |
233 | if (rv) | 225 | if (rv) |
234 | goto out_unlock; | 226 | goto out_unlock; |
235 | 227 | ||
@@ -239,6 +231,7 @@ static int set_param_str(const char *val, struct kernel_param *kp) | |||
239 | 231 | ||
240 | out_unlock: | 232 | out_unlock: |
241 | up_read(®ister_sem); | 233 | up_read(®ister_sem); |
234 | kfree(dup); | ||
242 | return rv; | 235 | return rv; |
243 | } | 236 | } |
244 | 237 | ||