Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1692239 > unrolled thread

[PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe()

Started by"Gustavo A. R. Silva" <gustavo@embeddedor.com>
First post2017-07-20 00:50 +0200
Last post2017-07-20 22:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] bluetooth: btwilink: remove unnecessary static in  bt_ti_probe() "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-07-20 00:50 +0200
    Re: [PATCH] bluetooth: btwilink: remove unnecessary static in  bt_ti_probe() Marcel Holtmann <marcel@holtmann.org> - 2017-07-20 11:30 +0200
      Re: [PATCH] bluetooth: btwilink: remove unnecessary static in  bt_ti_probe() "Gustavo A. R. Silva" <gustavo@embeddedor.com> - 2017-07-20 22:50 +0200

#1692239 — [PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe()

From"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date2017-07-20 00:50 +0200
Subject[PATCH] bluetooth: btwilink: remove unnecessary static in bt_ti_probe()
Message-ID<u55X3-6Hd-1@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1692685

FromMarcel Holtmann <marcel@holtmann.org>
Date2017-07-20 11:30 +0200
Message-ID<u5fWp-5m0-9@gated-at.bofh.it>
In reply to#1692239
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

[toc] | [prev] | [next] | [standalone]


#1693224

From"Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date2017-07-20 22:50 +0200
Message-ID<u5qyu-3Q5-1@gated-at.bofh.it>
In reply to#1692685
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web