Skip to contentSkip to conversation

msi-wmi: remove unnecessary static in msi_wmi_notify()

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Jul 18, 2017 – Jul 19, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 msi-wmi: remove unnecessary static in msi_wmi_notify()

Remove unnecessary static on local variable _key_. Such variable is initialized before being used, on every execution path throughout the function. The static has no benefit and, removing it reduces the object file size.

This issue was detected using Coccinelle and the following semantic patch:
https://github.com/GustavoARSilva/coccinelle/blob/master/static/static_unused.cocci

In the following log you can see a significant difference in the object file size. Also, there is a significant difference in the bss segment. This log is the output of the size command, before and after the code change:

before:

   text    data     bss     dec     hex filename
   6530    3736     320   10586    295a drivers/platform/x86/msi-wmi.o

after:

   text    data     bss     dec     hex filename
   6494    3648     256   10398    289e drivers/platform/x86/msi-wmi.o
---
 drivers/platform/x86/msi-wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/msi-wmi.c +1 -1
index f6209b7..6201382 100644
@@ -184,7 +184,7 @@ static const struct backlight_ops msi_backlight_ops = {
 static void msi_wmi_notify(u32 value, void *context)
 {
 	struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
-	static struct key_entry *key;
+	struct key_entry *key;
 	union acpi_object *obj;
 	acpi_status status;
 
Signature · 1 line
2.5.0
#1 lore raw
Quoted 13 lines · Gustavo A. R. Silva

Remove unnecessary static on local variable _key_. Such variable is initialized before being used, on every execution path throughout the function. The static has no benefit and, removing it reduces the object file size.

This issue was detected using Coccinelle and the following semantic patch:
https://github.com/GustavoARSilva/coccinelle/blob/master/static/static_unused.cocci

In the following log you can see a significant difference in the object file size. Also, there is a significant difference in the bss segment. This log is the output of the size command, before and after the code change:

Quoted 8 lines

before:

   text    data     bss     dec     hex filename
   6530    3736     320   10586    295a drivers/platform/x86/msi-wmi.o

after:

   text    data     bss     dec     hex filename
   6494    3648     256   10398    289e drivers/platform/x86/msi-wmi.o

Pushed to testing, thanks.

P.S. Please, use subsystem prefix next time.

Quoted 21 lines
---
 drivers/platform/x86/msi-wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/msi-wmi.c +1 -2
index f6209b7..6201382 100644
@@ -184,7 +184,7 @@ static const struct backlight_ops msi_backlight_ops = {
 static void msi_wmi_notify(u32 value, void *context)
 {
        struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
-       static struct key_entry *key;
+       struct key_entry *key;
        union acpi_object *obj;
        acpi_status status;
 
--

2.5.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko