Commit 66f969d0 authored by Pekka Enberg's avatar Pekka Enberg Committed by Linus Torvalds

[PATCH] ipmi: strstrip conversion

Switch an open-coded strstrip() to use the new API.
Acked-by: default avatarCorey Minyard <minyard@acm.org>
Signed-off-by: default avatarPekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 481fad48
...@@ -212,24 +212,16 @@ static int set_param_str(const char *val, struct kernel_param *kp) ...@@ -212,24 +212,16 @@ static int set_param_str(const char *val, struct kernel_param *kp)
{ {
action_fn fn = (action_fn) kp->arg; action_fn fn = (action_fn) kp->arg;
int rv = 0; int rv = 0;
const char *end; char *dup, *s;
char valcp[16];
int len; dup = kstrdup(val, GFP_KERNEL);
if (!dup)
/* Truncate leading and trailing spaces. */ return -ENOMEM;
while (isspace(*val))
val++; s = strstrip(dup);
end = val + strlen(val) - 1;
while ((end >= val) && isspace(*end))
end--;
len = end - val + 1;
if (len > sizeof(valcp) - 1)
return -EINVAL;
memcpy(valcp, val, len);
valcp[len] = '\0';
down_read(&register_sem); down_read(&register_sem);
rv = fn(valcp, NULL); rv = fn(s, NULL);
if (rv) if (rv)
goto out_unlock; goto out_unlock;
...@@ -239,6 +231,7 @@ static int set_param_str(const char *val, struct kernel_param *kp) ...@@ -239,6 +231,7 @@ static int set_param_str(const char *val, struct kernel_param *kp)
out_unlock: out_unlock:
up_read(&register_sem); up_read(&register_sem);
kfree(dup);
return rv; return rv;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment