char: ipmi: constify ipmi_smi_handlers structures
PATCH 1/1 char: ipmi: constify ipmi_smi_handlers structures
Declare ipmi_smi_handlers structures as const as they are only passed as an argument to the function ipmi_register_smi. This argument is of type const, so ipmi_smi_handlers structures having similar properties can be declared const too.
Done using Coccinelle:
@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct ipmi_smi_handlers i@p={...};
@ok1@
identifier r1.i;
position p;
@@ipmi_register_smi(&i@p,...)
@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
struct ipmi_smi_handlers i;
Size details after cross compiling the .o file for powerpc architecture
File size before:
text data bss dec hex filename
2777 288 0 3065 bf9 drivers/char/ipmi/ipmi_powernv.o
File size after:
text data bss dec hex filename
2873 192 0 3065 bf9 drivers/char/ipmi/ipmi_powernv.o
--- drivers/char/ipmi/ipmi_powernv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/ipmi/ipmi_powernv.c +1 -1
@@ -196,7 +196,7 @@ static void ipmi_powernv_poll(void *send_info)ipmi_powernv_recv (smi); } -static struct ipmi_smi_handlers ipmi_powernv_smi_handlers = { +static const struct ipmi_smi_handlers ipmi_powernv_smi_handlers = { .owner =THIS_MODULE , .start_processing = ipmi_powernv_start_processing, .sender = ipmi_powernv_send,
Signature · 1 line
1.9.1
Quoted 5 lines · Bhumika Goyal
Declare
ipmi_smi_handlersstructures as const as they are only passed as an argument to the functionipmi_register_smi. This argument is of type const, soipmi_smi_handlersstructures having similar properties can be declared const too.
Done using Coccinelle:
Thanks, queues for the next Linux patch mayhem.
-corey
Quoted 52 lines
@r1 disable optional_qualifier@
identifier i;
position p;
@@
static structipmi_smi_handlersi@p={...};@ok1@
identifier r1.i;
position p;
@@ipmi_register_smi(&i@p,...)@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
+const
structipmi_smi_handlersi;Size details after cross compiling the .o file for powerpc architecture
File size before:
text data bss dec hex filename
2777 288 0 3065 bf9drivers/char/ipmi/ipmi_powernv.oFile size after:
text data bss dec hex filename2873 192 0 3065 bf9 drivers/char/ipmi/ipmi_powernv.oSigned-off-by Bhumika Goyal <[email protected]>--- drivers/char/ipmi/ipmi_powernv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/ipmi/ipmi_powernv.c +1
-1@@ -196,7 +196,7 @@ static void ipmi_powernv_poll(void *send_info)ipmi_powernv_recv (smi); } -static struct ipmi_smi_handlers ipmi_powernv_smi_handlers = { +static const struct ipmi_smi_handlers ipmi_powernv_smi_handlers = { .owner =THIS_MODULE , .start_processing = ipmi_powernv_start_processing, .sender = ipmi_powernv_send,