Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] Make kobject's name be const char *

kobject: make kobject's name const char * since users should not
attempt to change it (except by calling kobject_rename).

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Dmitry Torokhov and committed by
Greg Kroah-Hartman
f3b4f3c6 e3a15db2

+6 -6
+3 -3
include/linux/kobject.h
··· 33 33 extern u64 hotplug_seqnum; 34 34 35 35 struct kobject { 36 - char * k_name; 36 + const char * k_name; 37 37 char name[KOBJ_NAME_LEN]; 38 38 struct kref kref; 39 39 struct list_head entry; ··· 46 46 extern int kobject_set_name(struct kobject *, const char *, ...) 47 47 __attribute__((format(printf,2,3))); 48 48 49 - static inline char * kobject_name(struct kobject * kobj) 49 + static inline const char * kobject_name(const struct kobject * kobj) 50 50 { 51 51 return kobj->k_name; 52 52 } ··· 57 57 extern int kobject_add(struct kobject *); 58 58 extern void kobject_del(struct kobject *); 59 59 60 - extern int kobject_rename(struct kobject *, char *new_name); 60 + extern int kobject_rename(struct kobject *, const char *new_name); 61 61 62 62 extern int kobject_register(struct kobject *); 63 63 extern void kobject_unregister(struct kobject *);
+1 -1
lib/kobject.c
··· 279 279 * @new_name: object's new name 280 280 */ 281 281 282 - int kobject_rename(struct kobject * kobj, char *new_name) 282 + int kobject_rename(struct kobject * kobj, const char *new_name) 283 283 { 284 284 int error = 0; 285 285
+2 -2
lib/kobject_uevent.c
··· 197 197 int i = 0; 198 198 int retval; 199 199 char *kobj_path = NULL; 200 - char *name = NULL; 200 + const char *name = NULL; 201 201 char *action_string; 202 202 u64 seq; 203 203 struct kobject *top_kobj = kobj; ··· 249 249 name = kobject_name(&kset->kobj); 250 250 251 251 argv [0] = hotplug_path; 252 - argv [1] = name; 252 + argv [1] = (char *)name; /* won't be changed but 'const' has to go */ 253 253 argv [2] = NULL; 254 254 255 255 /* minimal command environment */