linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe()
@ 2017-07-19 22:49 Gustavo A. R. Silva
  2017-07-20  9:20 ` Marcel Holtmann
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-19 22:49 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo Padovan, Johan Hedberg
  Cc: linux-bluetooth, linux-kernel, Gustavo A. R. Silva

Remove unnecessary static on local variable hst.
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:

@bad exists@
position p;
identifier x;
type T;
@@

static T x@p;
...
x = <+...x...+>

@@
identifier x;
expression e;
type T;
position p != bad.p;
@@

-static
 T x@p;
 ... when != x
     when strict
?x = e;

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

before:
   text    data     bss     dec     hex filename
   4029    2528     128    6685    1a1d drivers/bluetooth/btwilink.o

after:
   text    data     bss     dec     hex filename
   4007    2472      64    6543    198f drivers/bluetooth/btwilink.o

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 drivers/bluetooth/btwilink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
index 85a3978..0cdb896 100644
--- a/drivers/bluetooth/btwilink.c
+++ b/drivers/bluetooth/btwilink.c
@@ -276,7 +276,7 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 
 static int bt_ti_probe(struct platform_device *pdev)
 {
-	static struct ti_st *hst;
+	struct ti_st *hst;
 	struct hci_dev *hdev;
 	int err;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe()
  2017-07-19 22:49 [PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe() Gustavo A. R. Silva
@ 2017-07-20  9:20 ` Marcel Holtmann
  2017-07-20 20:47   ` Gustavo A. R. Silva
  0 siblings, 1 reply; 3+ messages in thread
From: Marcel Holtmann @ 2017-07-20  9:20 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Gustavo F. Padovan, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-kernel

Hi Gustavo,

> Remove unnecessary static on local variable hst.
> 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:
> 
> @bad exists@
> position p;
> identifier x;
> type T;
> @@
> 
> static T x@p;
> ...
> x = <+...x...+>
> 
> @@
> identifier x;
> expression e;
> type T;
> position p != bad.p;
> @@
> 
> -static
> T x@p;
> ... when != x
>     when strict
> ?x = e;
> 
> In the following log you can see the difference in the object file size.
> This log is the output of the size command, before and after the code
> change:
> 
> before:
>   text    data     bss     dec     hex filename
>   4029    2528     128    6685    1a1d drivers/bluetooth/btwilink.o
> 
> after:
>   text    data     bss     dec     hex filename
>   4007    2472      64    6543    198f drivers/bluetooth/btwilink.o
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/bluetooth/btwilink.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe()
  2017-07-20  9:20 ` Marcel Holtmann
@ 2017-07-20 20:47   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-07-20 20:47 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Gustavo F. Padovan, Johan Hedberg, open list:BLUETOOTH DRIVERS,
	linux-kernel

Hi Marcel,

On 07/20/2017 04:20 AM, Marcel Holtmann wrote:
> Hi Gustavo,
>
>> Remove unnecessary static on local variable hst.
>> 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:
>>
>> @bad exists@
>> position p;
>> identifier x;
>> type T;
>> @@
>>
>> static T x@p;
>> ...
>> x = <+...x...+>
>>
>> @@
>> identifier x;
>> expression e;
>> type T;
>> position p != bad.p;
>> @@
>>
>> -static
>> T x@p;
>> ... when != x
>>     when strict
>> ?x = e;
>>
>> In the following log you can see the difference in the object file size.
>> This log is the output of the size command, before and after the code
>> change:
>>
>> before:
>>   text    data     bss     dec     hex filename
>>   4029    2528     128    6685    1a1d drivers/bluetooth/btwilink.o
>>
>> after:
>>   text    data     bss     dec     hex filename
>>   4007    2472      64    6543    198f drivers/bluetooth/btwilink.o
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/bluetooth/btwilink.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> patch has been applied to bluetooth-next tree.
>

Great, thanks!

-- 
Gustavo A. R. Silva

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-07-20 20:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-19 22:49 [PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe() Gustavo A. R. Silva
2017-07-20  9:20 ` Marcel Holtmann
2017-07-20 20:47   ` Gustavo A. R. Silva

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).