aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2008-04-29 20:06:29 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-30 19:52:48 -0400
commita4ca6617421188f50774780cdc91c3782b7d08fe (patch)
tree661fbedcbd3deb8555b10a9406b7ffd50e288815 /lib/kobject.c
parent1cbfb7a5acd357de6c3f8e27e8d8f92b3867b1f3 (diff)
kobject: do not copy vargs, just pass them around
This prevents a few unneeded copies. Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index fd7874032163..718e5101c263 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -216,21 +216,12 @@ static int kobject_add_internal(struct kobject *kobj)
216static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, 216static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
217 va_list vargs) 217 va_list vargs)
218{ 218{
219 va_list aq;
220 char *name;
221
222 va_copy(aq, vargs);
223 name = kvasprintf(GFP_KERNEL, fmt, vargs);
224 va_end(aq);
225
226 if (!name)
227 return -ENOMEM;
228
229 /* Free the old name, if necessary. */ 219 /* Free the old name, if necessary. */
230 kfree(kobj->name); 220 kfree(kobj->name);
231 221
232 /* Now, set the new name */ 222 kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
233 kobj->name = name; 223 if (!kobj->name)
224 return -ENOMEM;
234 225
235 return 0; 226 return 0;
236} 227}
@@ -246,12 +237,12 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
246 */ 237 */
247int kobject_set_name(struct kobject *kobj, const char *fmt, ...) 238int kobject_set_name(struct kobject *kobj, const char *fmt, ...)
248{ 239{
249 va_list args; 240 va_list vargs;
250 int retval; 241 int retval;
251 242
252 va_start(args, fmt); 243 va_start(vargs, fmt);
253 retval = kobject_set_name_vargs(kobj, fmt, args); 244 retval = kobject_set_name_vargs(kobj, fmt, vargs);
254 va_end(args); 245 va_end(vargs);
255 246
256 return retval; 247 return retval;
257} 248}
@@ -301,12 +292,9 @@ EXPORT_SYMBOL(kobject_init);
301static int kobject_add_varg(struct kobject *kobj, struct kobject *parent, 292static int kobject_add_varg(struct kobject *kobj, struct kobject *parent,
302 const char *fmt, va_list vargs) 293 const char *fmt, va_list vargs)
303{ 294{
304 va_list aq;
305 int retval; 295 int retval;
306 296
307 va_copy(aq, vargs); 297 retval = kobject_set_name_vargs(kobj, fmt, vargs);
308 retval = kobject_set_name_vargs(kobj, fmt, aq);
309 va_end(aq);
310 if (retval) { 298 if (retval) {
311 printk(KERN_ERR "kobject: can not set name properly!\n"); 299 printk(KERN_ERR "kobject: can not set name properly!\n");
312 return retval; 300 return retval;