Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2
Subsystems (8)
cover Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2
From: Emese Revfy <[email protected]>
Hello everyone!
The following patch series attempts to constify several structures that hold function pointers. This is only the initial batch, there are about over 150 candidate structures, some of which can be constified as well, I plan to submit them in the future.
The list of constified structures in this series (* marks this thread):acpi_dock_opsaddress_space_operationsbacklight_opsblock_device_operationsdma_map_opsextent_io_opsfile_lock_operationsfile_operationshv_opsintel_dvo_dev_opsitem_operationsiwl_opskgdb_archkgdb_io
* kset_uevent_opslock_manager_operationsmicrocode_opsmtrr_opsneigh_opsnlmsvc_bindingpci_raw_opsplatform_hibernation_opsplatform_suspend_opssnd_ac97_build_opssysfs_opsusb_mon_operationswd_ops
There are certain exceptions where a given instance of the structure cannot be const, they are marked with a comment in the patch.
The patches compile fine with an allyesconfig kernel on i386 and x86_64.
Please let me know if any of these structures should not be constified and any other issues you see with them.
Changelog:
----------
v1 -> v2
- updated to linus-git-053fe57
- extended comments with a reference to code that prevents constification
- split up patches by subsystem as suggested by Greg KH, Jiri Slaby
- added all Acked-by's received so far
- removed patch for super_operations for now
- removed patch for ptmx_fops
Thanks,
Emese
drivers/base/bus.c | 2 +- drivers/base/core.c | 2 +- drivers/base/memory.c | 2 +- fs/gfs2/sys.c | 2 +- include/linux/kobject.h | 10 +++++----- kernel/params.c | 2 +- lib/kobject.c | 4 ++-- lib/kobject_uevent.c | 2 +- mm/slub.c | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-)
PATCH 1/4 Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2
From: Emese Revfy <[email protected]>
--- drivers/base/bus.c | 2 +- drivers/base/core.c | 2 +- drivers/base/memory.c | 2 +- include/linux/kobject.h | 10 +++++----- lib/kobject.c | 4 ++-- lib/kobject_uevent.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-)
drivers/base/bus.c +1 -1
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops bus_uevent_ops = { +static const struct kset_uevent_ops bus_uevent_ops = { .filter = bus_uevent_filter, };
drivers/base/core.c +1 -1
@@ -252,7 +252,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,return retval; } -static struct kset_uevent_ops device_uevent_ops = { +static const struct kset_uevent_ops device_uevent_ops = { .filter = dev_uevent_filter, .name = dev_uevent_name, .uevent = dev_uevent,
drivers/base/memory.c +1 -1
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uevreturn retval; } -static struct kset_uevent_ops memory_uevent_ops = { +static const struct kset_uevent_ops memory_uevent_ops = { .name = memory_uevent_name, .uevent = memory_uevent, };
include/linux/kobject.h +5 -5
@@ -118,9 +118,9 @@ struct kobj_uevent_env { };struct kset_uevent_ops { -int (*filter)(struct kset *kset,struct kobject *kobj); -const char *(*name)(struct kset *kset,struct kobject *kobj); -int (*uevent)(struct kset *kset,struct kobject *kobj, +int (*const filter)(struct kset *kset,struct kobject *kobj); +const char *(*const name)(struct kset *kset,struct kobject *kobj); +int (*const uevent)(struct kset *kset,struct kobject *kobj,struct kobj_uevent_env *env); };
@@ -155,14 +155,14 @@ struct kset {struct list_head list;spinlock_t list_lock;struct kobject kobj; -struct kset_uevent_ops *uevent_ops; +const struct kset_uevent_ops *uevent_ops; };extern void kset_init (struct kset *kset);extern int __must_check kset_register (struct kset *kset);extern void kset_unregister (struct kset *kset);extern struct kset *__must_check kset_create_and_add (const char *name, -struct kset_uevent_ops *u, +const struct kset_uevent_ops *u,struct kobject *parent_kobj);static inline struct kset *to_kset (struct kobject *kobj)
lib/kobject.c +2 -2
@@ -789,7 +789,7 @@ static struct kobj_type kset_ktype = {* If the kset was not able to be created, NULL will be returned. */ static struct kset *kset_create (const char *name, -struct kset_uevent_ops *uevent_ops, +const struct kset_uevent_ops *uevent_ops,struct kobject *parent_kobj) {struct kset *kset;
@@ -832,7 +832,7 @@ static struct kset *kset_create(const char *name,* If the kset was not able to be created, NULL will be returned. */ struct kset *kset_create_and_add (const char *name, -struct kset_uevent_ops *uevent_ops, +const struct kset_uevent_ops *uevent_ops,struct kobject *parent_kobj) {struct kset *kset;
lib/kobject_uevent.c +1 -1
@@ -95,7 +95,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,const char *subsystem;struct kobject *top_kobj;struct kset *kset; -struct kset_uevent_ops *uevent_ops; +const struct kset_uevent_ops *uevent_ops;u64 seq;int i =0 ;int retval =0 ;
Signature · 1 line
1.6.5.3
PATCH 1/1 Constify struct kgdb_io for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- drivers/misc/kgdbts.c | 4 ++-- drivers/serial/kgdboc.c | 4 ++-- include/linux/kgdb.h | 18 +++++++++--------- kernel/kgdb.c | 6 +++--- 4 files changed, 16 insertions(+), 16 deletions(-)
drivers/misc/kgdbts.c +2 -2
@@ -118,7 +118,7 @@ } while (0)#define MAX_CONFIG_LEN 40 -static struct kgdb_io kgdbts_io_ops; +static const struct kgdb_io kgdbts_io_ops;static char get_buf[BUFMAX ];static int get_buf_cnt;static char put_buf[BUFMAX ];
@@ -1108,7 +1108,7 @@ static void kgdbts_post_exp_handler(void)module_put (THIS_MODULE ); } -static struct kgdb_io kgdbts_io_ops = { +static const struct kgdb_io kgdbts_io_ops = { .name ="kgdbts" , .read_char = kgdbts_get_char, .write_char = kgdbts_put_char,
drivers/serial/kgdboc.c +2 -2
@@ -18,7 +18,7 @@#define MAX_CONFIG_LEN 40 -static struct kgdb_io kgdboc_io_ops; +static const struct kgdb_io kgdboc_io_ops;/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */ static int configured =-1 ;
@@ -154,7 +154,7 @@ static void kgdboc_post_exp_handler(void)module_put (THIS_MODULE ); } -static struct kgdb_io kgdboc_io_ops = { +static const struct kgdb_io kgdboc_io_ops = { .name ="kgdboc" , .read_char = kgdboc_get_char, .write_char = kgdboc_put_char,
include/linux/kgdb.h +9 -9
@@ -251,20 +251,20 @@ struct kgdb_arch {*/ struct kgdb_io {const char *name; -int (*read_char) (void ); -void (*write_char) (u8 ); -void (*flush) (void ); -int (*init) (void ); -void (*pre_exception) (void ); -void (*post_exception) (void ); +int (*const read_char) (void ); +void (*const write_char) (u8 ); +void (*const flush) (void ); +int (*const init) (void ); +void (*const pre_exception) (void ); +void (*const post_exception) (void ); }; -extern struct kgdb_arch arch_kgdb_ops; +extern struct kgdb_arch arch_kgdb_ops;extern unsigned long __weak kgdb_arch_pc (int exception,struct pt_regs *regs); -extern int kgdb_register_io_module (struct kgdb_io *local_kgdb_io_ops); -extern void kgdb_unregister_io_module (struct kgdb_io *local_kgdb_io_ops); +extern int kgdb_register_io_module (const struct kgdb_io *local_kgdb_io_ops); +extern void kgdb_unregister_io_module (const struct kgdb_io *local_kgdb_io_ops);extern int kgdb_hex2long (char **ptr,unsigned long *long_val);extern int kgdb_mem2hex (char *mem,char *buf,int count);
kernel/kgdb.c +3 -3
@@ -86,7 +86,7 @@ static int kgdb_io_module_registered;/* Guard for recursive entry */ static int exception_level; -static struct kgdb_io *kgdb_io_ops; +static const struct kgdb_io *kgdb_io_ops;static DEFINE_SPINLOCK (kgdb_registration_lock);/* kgdb console driver is loaded */
@@ -1661,7 +1661,7 @@ static void kgdb_initial_breakpoint(void)* * Register it with the KGDB core. */ -int kgdb_register_io_module (struct kgdb_io *new_kgdb_io_ops) +int kgdb_register_io_module (const struct kgdb_io *new_kgdb_io_ops) {int err;
@@ -1706,7 +1706,7 @@ EXPORT_SYMBOL_GPL(kgdb_register_io_module);* * Unregister it with the KGDB core. */ -void kgdb_unregister_io_module (struct kgdb_io *old_kgdb_io_ops) +void kgdb_unregister_io_module (const struct kgdb_io *old_kgdb_io_ops) {BUG_ON (kgdb_connected);
Signature · 1 line
1.6.5.3
PATCH 2/4 Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- fs/gfs2/sys.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/gfs2/sys.c +1 -1
@@ -586,7 +586,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,return 0 ; } -static struct kset_uevent_ops gfs2_uevent_ops = { +static const struct kset_uevent_ops gfs2_uevent_ops = { .uevent = gfs2_uevent, };
Signature · 1 line
1.6.5.3
Quoted 4 lines · On Mon, 2009-12-14 at 01:00 +0100, [email protected] wrote:
From: Emese Revfy <[email protected]>
Signed-off-by Emese Revfy <[email protected]>
Steve.
Quoted 17 lines
--- fs/gfs2/sys.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)fs/gfs2/sys.c +1
-1@@ -586,7 +586,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,return 0 ; } -static struct kset_uevent_ops gfs2_uevent_ops = { +static const struct kset_uevent_ops gfs2_uevent_ops = { .uevent = gfs2_uevent, };
PATCH 3/4 Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- mm/slub.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
mm/slub.c +1 -1
@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };
Signature · 1 line
1.6.5.3
Quoted 13 lines · On Mon, Dec 14, 2009 at 2:00 AM, <[email protected]> wrote:
From: Emese Revfy <[email protected]>
Signed-off-by Emese Revfy <[email protected]>---
mm/slub.c | 2 +-1 files changed, 1 insertions(+), 1 deletions(-)mm/slub.c +0
-0
mm/slub.c static int uevent_filter(struct kset *kset, struct kobject *kobj) · line 4527
Quoted 7 lines
mm/slub.c +1
-1@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj) return 0; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };
CC mm/slub.omm/slub.c: In function 'slab_sysfs_init':mm/slub.c:4679: warning: passing argument 2 of 'kset_create_and_add' discards qualifiers from pointer target type include/linux/kobject.h:164: note: expected 'struct kset_uevent_ops *' but argument is of type 'const struct kset_uevent_ops *'
Hmm?
Quoted 29 lines · Pekka Enberg
Quoted 13 lines · On Mon, Dec 14, 2009 at 2:00 AM, <[email protected]> wrote:
From: Emese Revfy <[email protected]>
Signed-off-by Emese Revfy <[email protected]>--- mm/slub.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)mm/slub.c +0
-0mm/slub.c static int uevent_filter(struct kset *kset, struct kobject *kobj) · line 4527
Quoted 7 lines
mm/slub.c +1
-1@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };CC
mm/slub.omm/slub.c: In function 'slab_sysfs_init':mm/slub.c:4679: warning: passing argument 2 of 'kset_create_and_add' discards qualifiers from pointer target typeinclude/linux/kobject.h:164: note: expected 'structkset_uevent_ops*' but argument is of type 'const structkset_uevent_ops*'
Quoted 2 lines
Hmm?
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here.
Can you tell me what patch/tree combination you encountered this warning with? Thanks, Emese
David Rientjes
reviewerQuoted 20 lines · Emese Revfy
Quoted 20 lines
mm/slub.c static int uevent_filter(struct kset *kset, struct kobject *kobj) · line 4527
Quoted 12 lines
mm/slub.c +1
-1@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };CC
mm/slub.omm/slub.c: In function 'slab_sysfs_init':mm/slub.c:4679: warning: passing argument 2 of 'kset_create_and_add' discards qualifiers from pointer target typeinclude/linux/kobject.h:164: note: expected 'structkset_uevent_ops*' but argument is of type 'const structkset_uevent_ops*'
Quoted 8 lines
Quoted 2 lines
Hmm?
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here.
Can you tell me what patch/tree combination you encountered this warning with? Thanks, Emese
The warning emitted by gcc is pretty explicit; the second formal of kset_create_and_add() takes a 'struct kset_uevent_ops *' type while you're now passing 'const struct kset_uevent_ops *' as the result of your change. That said, kset_create() could probably be modified with the const qualifier, but that's outside the scope of your patchset and would have to be proposed seperately.
Quoted 29 lines · David Rientjes
Quoted 19 lines · Emese Revfy
Quoted 19 lines
mm/slub.c static int uevent_filter(struct kset *kset, struct kobject *kobj) · line 4527
Quoted 12 lines
mm/slub.c +1
-1@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };CC
mm/slub.omm/slub.c: In function 'slab_sysfs_init':mm/slub.c:4679: warning: passing argument 2 of 'kset_create_and_add' discards qualifiers from pointer target typeinclude/linux/kobject.h:164: note: expected 'structkset_uevent_ops*' but argument is of type 'const structkset_uevent_ops*'Quoted 7 lines
Quoted 2 lines
Hmm?
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here.
Can you tell me what patch/tree combination you encountered this warning with? Thanks, Emese
Quoted 6 lines
The warning emitted by gcc is pretty explicit; the second formal of
kset_create_and_add()takes a 'structkset_uevent_ops*' type while you're now passing 'const structkset_uevent_ops*' as the result of your change. That said,kset_create()could probably be modified with the const qualifier, but that's outside the scope of your patchset and would have to be proposed seperately.
I see what you mean, this was part of [PATCH 1/4] that I forgot to CC to you. Emese
Hi Emese,
Quoted 30 lines · Emese Revfy
Quoted 29 lines · David Rientjes
Quoted 26 lines · Emese Revfy
Quoted 19 lines
mm/slub.c static int uevent_filter(struct kset *kset, struct kobject *kobj) · line 4527
Quoted 12 lines
mm/slub.c +1
-1@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj) return 0; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };CC mm/slub.o
mm/slub.c: In function 'slab_sysfs_init':mm/slub.c:4679: warning: passing argument 2 of 'kset_create_and_add' discards qualifiers from pointer target typeinclude/linux/kobject.h:164: note: expected 'structkset_uevent_ops*' but argument is of type 'const structkset_uevent_ops*'Quoted 2 lines
Hmm?
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here.
Can you tell me what patch/tree combination you encountered this warning with? Thanks, Emese
Quoted 8 lines
Quoted 6 lines
The warning emitted by gcc is pretty explicit; the second formal of
kset_create_and_add()takes a 'structkset_uevent_ops*' type while you're now passing 'const structkset_uevent_ops*' as the result of your change. That said,kset_create()could probably be modified with the const qualifier, but that's outside the scope of your patchset and would have to be proposed seperately.I see what you mean, this was part of [PATCH 1/4] that I forgot to CC to you.
Then you might as well fold everything in one patch and send it to Andrew. I can't apply both in my tree and I don't want to apply something that doesn't compile cleanly.
Pekka
Emese Revfy kirjoitti:
Quoted 29 lines
Quoted 28 lines · Pekka Enberg
Quoted 13 lines · On Mon, Dec 14, 2009 at 2:00 AM, <[email protected]> wrote:
From: Emese Revfy <[email protected]>
Signed-off-by Emese Revfy <[email protected]>--- mm/slub.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)mm/slub.c +0
-0mm/slub.c static int uevent_filter(struct kset *kset, struct kobject *kobj) · line 4527
Quoted 7 lines
mm/slub.c +1
-1@@ -4522,7 +4522,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };CC
mm/slub.omm/slub.c: In function 'slab_sysfs_init':mm/slub.c:4679: warning: passing argument 2 of 'kset_create_and_add' discards qualifiers from pointer target typeinclude/linux/kobject.h:164: note: expected 'structkset_uevent_ops*' but argument is of type 'const structkset_uevent_ops*'
Quoted 6 lines
Quoted 2 lines
Hmm?
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here.
Can you tell me what patch/tree combination you encountered this warning with?
2.6.33-rc2 with your patch.
Re: [PATCH 1/1] Constify struct kset_uevent_ops for 2.6.33-rc2
Quoted 6 lines
Quoted 4 lines
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here. Can you tell me what patch/tree combination you encountered this warning with?
2.6.33-rc2 with your patch.
Here is the updated patch for 2.6.33-rc2 in one piece. Emese
From: Emese Revfy <[email protected]>
Constify struct kset_uevent_ops.
---
drivers/base/bus.c | 2 +- drivers/base/core.c | 2 +- drivers/base/memory.c | 2 +- fs/gfs2/sys.c | 2 +- include/linux/kobject.h | 10 +++++----- kernel/params.c | 2 +- lib/kobject.c | 4 ++-- lib/kobject_uevent.c | 2 +- mm/slub.c | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-)
drivers/base/bus.c +1 -1
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops bus_uevent_ops = { +static const struct kset_uevent_ops bus_uevent_ops = { .filter = bus_uevent_filter, };
drivers/base/core.c +1 -1
@@ -252,7 +252,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,return retval; } -static struct kset_uevent_ops device_uevent_ops = { +static const struct kset_uevent_ops device_uevent_ops = { .filter = dev_uevent_filter, .name = dev_uevent_name, .uevent = dev_uevent,
drivers/base/memory.c +1 -1
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uevreturn retval; } -static struct kset_uevent_ops memory_uevent_ops = { +static const struct kset_uevent_ops memory_uevent_ops = { .name = memory_uevent_name, .uevent = memory_uevent, };
fs/gfs2/sys.c +1 -1
@@ -576,7 +576,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,return 0 ; } -static struct kset_uevent_ops gfs2_uevent_ops = { +static const struct kset_uevent_ops gfs2_uevent_ops = { .uevent = gfs2_uevent, };
include/linux/kobject.h +5 -5
@@ -118,9 +118,9 @@ struct kobj_uevent_env { };struct kset_uevent_ops { -int (*filter)(struct kset *kset,struct kobject *kobj); -const char *(*name)(struct kset *kset,struct kobject *kobj); -int (*uevent)(struct kset *kset,struct kobject *kobj, +int (*const filter)(struct kset *kset,struct kobject *kobj); +const char *(*const name)(struct kset *kset,struct kobject *kobj); +int (*const uevent)(struct kset *kset,struct kobject *kobj,struct kobj_uevent_env *env); };
@@ -155,14 +155,14 @@ struct kset {struct list_head list;spinlock_t list_lock;struct kobject kobj; -struct kset_uevent_ops *uevent_ops; +const struct kset_uevent_ops *uevent_ops; };extern void kset_init (struct kset *kset);extern int __must_check kset_register (struct kset *kset);extern void kset_unregister (struct kset *kset);extern struct kset *__must_check kset_create_and_add (const char *name, -struct kset_uevent_ops *u, +const struct kset_uevent_ops *u,struct kobject *parent_kobj);static inline struct kset *to_kset (struct kobject *kobj)
kernel/params.c +1 -1
@@ -737,7 +737,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops module_uevent_ops = { +static const struct kset_uevent_ops module_uevent_ops = { .filter = uevent_filter, };
lib/kobject.c +2 -2
@@ -789,7 +789,7 @@ static struct kobj_type kset_ktype = {* If the kset was not able to be created, NULL will be returned. */ static struct kset *kset_create (const char *name, -struct kset_uevent_ops *uevent_ops, +const struct kset_uevent_ops *uevent_ops,struct kobject *parent_kobj) {struct kset *kset;
@@ -832,7 +832,7 @@ static struct kset *kset_create(const char *name,* If the kset was not able to be created, NULL will be returned. */ struct kset *kset_create_and_add (const char *name, -struct kset_uevent_ops *uevent_ops, +const struct kset_uevent_ops *uevent_ops,struct kobject *parent_kobj) {struct kset *kset;
lib/kobject_uevent.c +1 -1
@@ -95,7 +95,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,const char *subsystem;struct kobject *top_kobj;struct kset *kset; -struct kset_uevent_ops *uevent_ops; +const struct kset_uevent_ops *uevent_ops;u64 seq;int i =0 ;int retval =0 ;
mm/slub.c +1 -1
@@ -4538,7 +4538,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };
Re: [PATCH 1/1] Constify struct kset_uevent_ops for 2.6.33-rc2
Quoted 7 lines · Emese Revfy
Quoted 6 lines
Quoted 4 lines
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here. Can you tell me what patch/tree combination you encountered this warning with?
2.6.33-rc2 with your patch.
Quoted 7 lines
Here is the updated patch for 2.6.33-rc2 in one piece. Emese
From: Emese Revfy <[email protected]>
Constify struct
kset_uevent_ops.
Why is this needed? What does it accomplish?
thanks,
greg k-h
Re: [PATCH 1/1] Constify struct kset_uevent_ops for 2.6.33-rc2
Quoted 10 lines · Greg KH
Quoted 9 lines · Emese Revfy
Quoted 5 lines
Quoted 4 lines
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here. Can you tell me what patch/tree combination you encountered this warning with?
2.6.33-rc2 with your patch.
Here is the updated patch for 2.6.33-rc2 in one piece. Emese
Quoted 5 lines
Quoted 3 lines
From: Emese Revfy <[email protected]>
Constify struct
kset_uevent_ops.Why is this needed? What does it accomplish?
This is my contribution to the ops structure constification effort that some developers started a few years ago (Arjan, Al Viro, etc.) and that has been worked on somewhat sporadically ever since. For a summary of why this is useful please see Arjan's email:
http://lkml.org/lkml/2009/12/14/216
--
Emese
Re: [PATCH 1/1] Constify struct kset_uevent_ops for 2.6.33-rc2
Quoted 15 lines · Emese Revfy
Quoted 14 lines · Greg KH
Quoted 12 lines · Emese Revfy
Quoted 5 lines
Quoted 4 lines
I double checked both the declaration and definitions of the affected function/structure and they are consistently const here. Can you tell me what patch/tree combination you encountered this warning with?
2.6.33-rc2 with your patch.
Here is the updated patch for 2.6.33-rc2 in one piece. Emese
From: Emese Revfy <[email protected]>
Constify struct
kset_uevent_ops.
Quoted 7 lines
Quoted 1 line
Why is this needed? What does it accomplish?
This is my contribution to the ops structure constification effort that some developers started a few years ago (Arjan, Al Viro, etc.) and that has been worked on somewhat sporadically ever since. For a summary of why this is useful please see Arjan's email:
http://lkml.org/lkml/2009/12/14/216
Then please insert this kind of information in the patch itself, otherwise it is totally unknown.
Care to resend with the proper information in it?
thanks,
greg k-h
Re: [PATCH 1/1] Constify struct kset_uevent_ops for 2.6.33-rc2
From: Emese Revfy <[email protected]>
Constify struct kset_uevent_ops.
This is part of the ops structure constification
effort started by Arjan van de Ven et al.
Benefits of this constification:
* prevents modification of data that is shared
(referenced) by many other structure instances
at runtime
* detects/prevents accidental (but not intentional) modification attempts on archs that enforce read-only kernel data at runtime
* potentially better optimized code as the compiler can assume that the const data cannot be changed
* the compiler/linker move const data into .rodata and therefore exclude them from false sharing
---
drivers/base/bus.c | 2 +- drivers/base/core.c | 2 +- drivers/base/memory.c | 2 +- fs/gfs2/sys.c | 2 +- include/linux/kobject.h | 10 +++++----- kernel/params.c | 2 +- lib/kobject.c | 4 ++-- lib/kobject_uevent.c | 2 +- mm/slub.c | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-)
drivers/base/bus.c +1 -1
@@ -154,7 +154,7 @@ static int bus_uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops bus_uevent_ops = { +static const struct kset_uevent_ops bus_uevent_ops = { .filter = bus_uevent_filter, };
drivers/base/core.c +1 -1
@@ -252,7 +252,7 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,return retval; } -static struct kset_uevent_ops device_uevent_ops = { +static const struct kset_uevent_ops device_uevent_ops = { .filter = dev_uevent_filter, .name = dev_uevent_name, .uevent = dev_uevent,
drivers/base/memory.c +1 -1
@@ -44,7 +44,7 @@ static int memory_uevent(struct kset *kset, struct kobject *obj, struct kobj_uevreturn retval; } -static struct kset_uevent_ops memory_uevent_ops = { +static const struct kset_uevent_ops memory_uevent_ops = { .name = memory_uevent_name, .uevent = memory_uevent, };
fs/gfs2/sys.c +1 -1
@@ -576,7 +576,7 @@ static int gfs2_uevent(struct kset *kset, struct kobject *kobj,return 0 ; } -static struct kset_uevent_ops gfs2_uevent_ops = { +static const struct kset_uevent_ops gfs2_uevent_ops = { .uevent = gfs2_uevent, };
include/linux/kobject.h +5 -5
@@ -118,9 +118,9 @@ struct kobj_uevent_env { };struct kset_uevent_ops { -int (*filter)(struct kset *kset,struct kobject *kobj); -const char *(*name)(struct kset *kset,struct kobject *kobj); -int (*uevent)(struct kset *kset,struct kobject *kobj, +int (*const filter)(struct kset *kset,struct kobject *kobj); +const char *(*const name)(struct kset *kset,struct kobject *kobj); +int (*const uevent)(struct kset *kset,struct kobject *kobj,struct kobj_uevent_env *env); };
@@ -155,14 +155,14 @@ struct kset {struct list_head list;spinlock_t list_lock;struct kobject kobj; -struct kset_uevent_ops *uevent_ops; +const struct kset_uevent_ops *uevent_ops; };extern void kset_init (struct kset *kset);extern int __must_check kset_register (struct kset *kset);extern void kset_unregister (struct kset *kset);extern struct kset *__must_check kset_create_and_add (const char *name, -struct kset_uevent_ops *u, +const struct kset_uevent_ops *u,struct kobject *parent_kobj);static inline struct kset *to_kset (struct kobject *kobj)
kernel/params.c +1 -1
@@ -737,7 +737,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops module_uevent_ops = { +static const struct kset_uevent_ops module_uevent_ops = { .filter = uevent_filter, };
lib/kobject.c +2 -2
@@ -789,7 +789,7 @@ static struct kobj_type kset_ktype = {* If the kset was not able to be created, NULL will be returned. */ static struct kset *kset_create (const char *name, -struct kset_uevent_ops *uevent_ops, +const struct kset_uevent_ops *uevent_ops,struct kobject *parent_kobj) {struct kset *kset;
@@ -832,7 +832,7 @@ static struct kset *kset_create(const char *name,* If the kset was not able to be created, NULL will be returned. */ struct kset *kset_create_and_add (const char *name, -struct kset_uevent_ops *uevent_ops, +const struct kset_uevent_ops *uevent_ops,struct kobject *parent_kobj) {struct kset *kset;
lib/kobject_uevent.c +1 -1
@@ -95,7 +95,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,const char *subsystem;struct kobject *top_kobj;struct kset *kset; -struct kset_uevent_ops *uevent_ops; +const struct kset_uevent_ops *uevent_ops;u64 seq;int i =0 ;int retval =0 ;
mm/slub.c +1 -1
@@ -4538,7 +4538,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops slab_uevent_ops = { +static const struct kset_uevent_ops slab_uevent_ops = { .filter = uevent_filter, };
PATCH 4/4 Constify struct kset_uevent_ops for 2.6.32-git-053fe57ac v2
In reply to [email protected]From: Emese Revfy <[email protected]>
--- kernel/params.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/params.c +1 -1
@@ -739,7 +739,7 @@ static int uevent_filter(struct kset *kset, struct kobject *kobj)return 0 ; } -static struct kset_uevent_ops module_uevent_ops = { +static const struct kset_uevent_ops module_uevent_ops = { .filter = uevent_filter, };
Signature · 1 line
1.6.5.3