* [PATCH] char: ipmi: constify ipmi_smi_handlers structures
@ 2017-01-15 19:15 Bhumika Goyal
2017-01-15 20:28 ` Corey Minyard
0 siblings, 1 reply; 2+ messages in thread
From: Bhumika Goyal @ 2017-01-15 19:15 UTC (permalink / raw)
To: julia.lawall, minyard, benh, paulus, mpe, openipmi-developer,
linuxppc-dev, linux-kernel
Cc: Bhumika Goyal
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
Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
---
drivers/char/ipmi/ipmi_powernv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c
index 6e658aa..b338a4b 100644
--- a/drivers/char/ipmi/ipmi_powernv.c
+++ b/drivers/char/ipmi/ipmi_powernv.c
@@ -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,
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] char: ipmi: constify ipmi_smi_handlers structures
2017-01-15 19:15 [PATCH] char: ipmi: constify ipmi_smi_handlers structures Bhumika Goyal
@ 2017-01-15 20:28 ` Corey Minyard
0 siblings, 0 replies; 2+ messages in thread
From: Corey Minyard @ 2017-01-15 20:28 UTC (permalink / raw)
To: Bhumika Goyal, julia.lawall, benh, paulus, mpe,
openipmi-developer, linuxppc-dev, linux-kernel
On 01/15/2017 01:15 PM, Bhumika Goyal wrote:
> 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:
Thanks, queues for the next Linux patch mayhem.
-corey
> @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
>
> Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
> ---
> drivers/char/ipmi/ipmi_powernv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c
> index 6e658aa..b338a4b 100644
> --- a/drivers/char/ipmi/ipmi_powernv.c
> +++ b/drivers/char/ipmi/ipmi_powernv.c
> @@ -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,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-01-15 20:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-15 19:15 [PATCH] char: ipmi: constify ipmi_smi_handlers structures Bhumika Goyal
2017-01-15 20:28 ` Corey Minyard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).