From dtor_core@ameritech.net Tue Apr 26 00:45:51 2005 From: Dmitry Torokhov To: linux-kernel@vger.kernel.org Subject: [PATCH 3/5] Make kobject's name be const char * Date: Tue, 26 Apr 2005 02:32:00 -0500 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 Signed-off-by: Greg Kroah-Hartman --- --- gregkh-2.6.orig/include/linux/kobject.h 2005-05-02 10:47:22.000000000 -0700 +++ gregkh-2.6/include/linux/kobject.h 2005-05-02 10:53:14.000000000 -0700 @@ -33,7 +33,7 @@ extern u64 hotplug_seqnum; struct kobject { - char * k_name; + const char * k_name; char name[KOBJ_NAME_LEN]; struct kref kref; struct list_head entry; @@ -46,7 +46,7 @@ extern int kobject_set_name(struct kobject *, const char *, ...) __attribute__((format(printf,2,3))); -static inline char * kobject_name(struct kobject * kobj) +static inline const char * kobject_name(const struct kobject * kobj) { return kobj->k_name; } @@ -57,7 +57,7 @@ extern int kobject_add(struct kobject *); extern void kobject_del(struct kobject *); -extern int kobject_rename(struct kobject *, char *new_name); +extern int kobject_rename(struct kobject *, const char *new_name); extern int kobject_register(struct kobject *); extern void kobject_unregister(struct kobject *); --- gregkh-2.6.orig/lib/kobject.c 2005-05-02 10:52:50.000000000 -0700 +++ gregkh-2.6/lib/kobject.c 2005-05-02 10:53:14.000000000 -0700 @@ -280,7 +280,7 @@ * @new_name: object's new name */ -int kobject_rename(struct kobject * kobj, char *new_name) +int kobject_rename(struct kobject * kobj, const char *new_name) { int error = 0; --- gregkh-2.6.orig/lib/kobject_uevent.c 2005-05-02 10:53:10.000000000 -0700 +++ gregkh-2.6/lib/kobject_uevent.c 2005-05-02 10:53:14.000000000 -0700 @@ -197,7 +197,7 @@ int i = 0; int retval; char *kobj_path = NULL; - char *name = NULL; + const char *name = NULL; char *action_string; u64 seq; struct kobject *top_kobj = kobj; @@ -249,7 +249,7 @@ name = kobject_name(&kset->kobj); argv [0] = hotplug_path; - argv [1] = name; + argv [1] = (char *)name; /* won't be changed but 'const' has to go */ argv [2] = NULL; /* minimal command environment */