Commit 2abf114f authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Linus Torvalds

lib/kobject.c: use strreplace()

There's probably not many slashes in the name, but starting over when
we see one feels wrong.
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ff14417c
...@@ -257,23 +257,20 @@ static int kobject_add_internal(struct kobject *kobj) ...@@ -257,23 +257,20 @@ static int kobject_add_internal(struct kobject *kobj)
int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
va_list vargs) va_list vargs)
{ {
const char *old_name = kobj->name;
char *s; char *s;
if (kobj->name && !fmt) if (kobj->name && !fmt)
return 0; return 0;
kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); s = kvasprintf(GFP_KERNEL, fmt, vargs);
if (!kobj->name) { if (!s)
kobj->name = old_name;
return -ENOMEM; return -ENOMEM;
}
/* ewww... some of these buggers have '/' in the name ... */ /* ewww... some of these buggers have '/' in the name ... */
while ((s = strchr(kobj->name, '/'))) strreplace(s, '/', '!');
s[0] = '!'; kfree(kobj->name);
kobj->name = s;
kfree(old_name);
return 0; return 0;
} }
......
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