All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] staging: Remove useless intialisation
@ 2015-10-14 20:54 Amitoj Kaur Chawla
  2015-10-14 20:56 ` [PATCH 1/5] staging: unisys: " Amitoj Kaur Chawla
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2015-10-14 20:54 UTC (permalink / raw)
  To: outreachy-kernel

This patchset removes multiple useless intialisations of variables
which are immediately reassigned.

The semantic patch used to find this is:

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
 ;
x = e;
// </smpl>


Amitoj Kaur Chawla (5):
  staging: unisys: Remove useless intialisation
  staging: speakup: speakup_audptr: Remove useless intialisation
  staging: speakup: varhandlers: Remove useless intialisation
  staging: rtl8712: rtl8712_recv: Remove useless intialisation
  staging: rtl8712: rtl871x_mp: Remove useless initialisation

 drivers/staging/rtl8712/rtl8712_recv.c         | 2 +-
 drivers/staging/rtl8712/rtl871x_mp.c           | 6 +++---
 drivers/staging/speakup/speakup_audptr.c       | 2 +-
 drivers/staging/speakup/varhandlers.c          | 2 +-
 drivers/staging/unisys/visorinput/visorinput.c | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

-- 
1.9.1



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

* [PATCH 1/5] staging: unisys: Remove useless intialisation
  2015-10-14 20:54 [PATCH 0/5] staging: Remove useless intialisation Amitoj Kaur Chawla
@ 2015-10-14 20:56 ` Amitoj Kaur Chawla
  2015-10-14 20:57 ` [PATCH 2/5] staging: speakup: speakup_audptr: " Amitoj Kaur Chawla
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2015-10-14 20:56 UTC (permalink / raw)
  To: outreachy-kernel

Remove intialisation of a variable that is immediately reassigned.

The semantic patch used to find this is:

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
 ;
x = e;
// </smpl>


Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/unisys/visorinput/visorinput.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorinput/visorinput.c b/drivers/staging/unisys/visorinput/visorinput.c
index 3a1b24f..6e42d59 100644
--- a/drivers/staging/unisys/visorinput/visorinput.c
+++ b/drivers/staging/unisys/visorinput/visorinput.c
@@ -264,7 +264,7 @@ register_client_keyboard(void *devdata,  /* opaque on purpose */
 
 {
 	int i, error;
-	struct input_dev *visorinput_dev = NULL;
+	struct input_dev *visorinput_dev;
 
 	visorinput_dev = input_allocate_device();
 	if (!visorinput_dev)
-- 
1.9.1



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

* [PATCH 2/5] staging: speakup: speakup_audptr: Remove useless intialisation
  2015-10-14 20:54 [PATCH 0/5] staging: Remove useless intialisation Amitoj Kaur Chawla
  2015-10-14 20:56 ` [PATCH 1/5] staging: unisys: " Amitoj Kaur Chawla
@ 2015-10-14 20:57 ` Amitoj Kaur Chawla
  2015-10-14 20:58 ` [PATCH 3/5] staging: speakup: varhandlers: " Amitoj Kaur Chawla
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2015-10-14 20:57 UTC (permalink / raw)
  To: outreachy-kernel

Remove intialisation of a variable that is immediately reassigned.

The semantic patch used to find this is:

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
 ;
x = e;
// </smpl>


Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/speakup/speakup_audptr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/speakup_audptr.c b/drivers/staging/speakup/speakup_audptr.c
index ea89e36..a9a6872 100644
--- a/drivers/staging/speakup/speakup_audptr.c
+++ b/drivers/staging/speakup/speakup_audptr.c
@@ -162,7 +162,7 @@ static void synth_version(struct spk_synth *synth)
 
 static int synth_probe(struct spk_synth *synth)
 {
-	int failed = 0;
+	int failed;
 
 	failed = spk_serial_synth_probe(synth);
 	if (failed == 0)
-- 
1.9.1



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

* [PATCH 3/5] staging: speakup: varhandlers: Remove useless intialisation
  2015-10-14 20:54 [PATCH 0/5] staging: Remove useless intialisation Amitoj Kaur Chawla
  2015-10-14 20:56 ` [PATCH 1/5] staging: unisys: " Amitoj Kaur Chawla
  2015-10-14 20:57 ` [PATCH 2/5] staging: speakup: speakup_audptr: " Amitoj Kaur Chawla
@ 2015-10-14 20:58 ` Amitoj Kaur Chawla
  2015-10-14 20:59 ` [PATCH 4/5] staging: rtl8712: rtl8712_recv: " Amitoj Kaur Chawla
  2015-10-14 21:01 ` [PATCH 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation Amitoj Kaur Chawla
  4 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2015-10-14 20:58 UTC (permalink / raw)
  To: outreachy-kernel

Remove intialisation of a variable that is immediately reassigned.

The semantic patch used to find this is:

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
 ;
x = e;
// </smpl>


Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/speakup/varhandlers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/varhandlers.c b/drivers/staging/speakup/varhandlers.c
index b2afec6..ab4fe8d 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -323,7 +323,7 @@ char *spk_strlwr(char *s)
 
 char *spk_s2uchar(char *start, char *dest)
 {
-	int val = 0;
+	int val;
 
 	val = simple_strtoul(skip_spaces(start), &start, 10);
 	if (*start == ',')
-- 
1.9.1



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

* [PATCH 4/5] staging: rtl8712: rtl8712_recv: Remove useless intialisation
  2015-10-14 20:54 [PATCH 0/5] staging: Remove useless intialisation Amitoj Kaur Chawla
                   ` (2 preceding siblings ...)
  2015-10-14 20:58 ` [PATCH 3/5] staging: speakup: varhandlers: " Amitoj Kaur Chawla
@ 2015-10-14 20:59 ` Amitoj Kaur Chawla
  2015-10-14 21:01 ` [PATCH 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation Amitoj Kaur Chawla
  4 siblings, 0 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2015-10-14 20:59 UTC (permalink / raw)
  To: outreachy-kernel

Remove intialisation of a variable that is immediately reassigned.

The semantic patch used to find this is:

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
 ;
x = e;
// </smpl>


Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/rtl8712/rtl8712_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index fae06d9..fd2b7e8 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -158,7 +158,7 @@ int r8712_free_recvframe(union recv_frame *precvframe,
 static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
 					   struct recv_stat *prxstat)
 {
-	u16 drvinfo_sz = 0;
+	u16 drvinfo_sz;
 
 	drvinfo_sz = (le32_to_cpu(prxstat->rxdw0)&0x000f0000)>>16;
 	drvinfo_sz <<= 3;
-- 
1.9.1



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

* [PATCH 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation
  2015-10-14 20:54 [PATCH 0/5] staging: Remove useless intialisation Amitoj Kaur Chawla
                   ` (3 preceding siblings ...)
  2015-10-14 20:59 ` [PATCH 4/5] staging: rtl8712: rtl8712_recv: " Amitoj Kaur Chawla
@ 2015-10-14 21:01 ` Amitoj Kaur Chawla
  2015-10-14 21:21   ` [Outreachy kernel] " Julia Lawall
  2015-10-15  6:35   ` [Outreachy kernel] [PATCH v2 " Julia Lawall
  4 siblings, 2 replies; 8+ messages in thread
From: Amitoj Kaur Chawla @ 2015-10-14 21:01 UTC (permalink / raw)
  To: outreachy-kernel

Remove intialisation of a variable that is immediately reassigned.

The semantic patch used to find this is:

// <smpl>
@@
type T;
identifier x;
constant C;
expression e;
@@

T x
- = C
 ;
x = e;
// </smpl>


Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/staging/rtl8712/rtl871x_mp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c
index 26201ea..00b80f7 100644
--- a/drivers/staging/rtl8712/rtl871x_mp.c
+++ b/drivers/staging/rtl8712/rtl871x_mp.c
@@ -295,7 +295,7 @@ void r8712_SetChannel(struct _adapter *pAdapter)
 
 static void SetCCKTxPower(struct _adapter *pAdapter, u8 TxPower)
 {
-	u16 TxAGC = 0;
+	u16 TxAGC;
 
 	TxAGC = TxPower;
 	set_bb_reg(pAdapter, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
@@ -726,7 +726,7 @@ static u32 GetPhyRxPktCounts(struct _adapter *pAdapter, u32 selbit)
 
 u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
 {
-	u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
+	u32 OFDM_cnt, CCK_cnt, HT_cnt;
 
 	OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT);
 	CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT);
@@ -736,7 +736,7 @@ u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
 
 u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter)
 {
-	u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
+	u32 OFDM_cnt, CCK_cnt, HT_cnt;
 
 	OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT);
 	CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT);
-- 
1.9.1



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

* Re: [Outreachy kernel] [PATCH 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation
  2015-10-14 21:01 ` [PATCH 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation Amitoj Kaur Chawla
@ 2015-10-14 21:21   ` Julia Lawall
  2015-10-15  6:35   ` [Outreachy kernel] [PATCH v2 " Julia Lawall
  1 sibling, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-10-14 21:21 UTC (permalink / raw)
  To: Amitoj Kaur Chawla; +Cc: outreachy-kernel

On Thu, 15 Oct 2015, Amitoj Kaur Chawla wrote:

> Remove intialisation of a variable that is immediately reassigned.
> 
> The semantic patch used to find this is:
> 
> // <smpl>
> @@
> type T;
> identifier x;
> constant C;
> expression e;
> @@
> 
> T x
> - = C
>  ;
> x = e;

In some cases there are many variables that have been simplified, but this 
rule doesn't reflect that, because in this rule the assignment has to come 
immediately after the declaration.  You could have made the following 
rule:

T x
- = C
;
... when != x
x = e;

But that could potentially give cases where the x = e is quite far away, 
which is probably not exactly what you want either.  So you could just say 
that you identified some further opportunities by hand, and cleaned them 
up too.

julia

> // </smpl>
> 
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/staging/rtl8712/rtl871x_mp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c
> index 26201ea..00b80f7 100644
> --- a/drivers/staging/rtl8712/rtl871x_mp.c
> +++ b/drivers/staging/rtl8712/rtl871x_mp.c
> @@ -295,7 +295,7 @@ void r8712_SetChannel(struct _adapter *pAdapter)
>  
>  static void SetCCKTxPower(struct _adapter *pAdapter, u8 TxPower)
>  {
> -	u16 TxAGC = 0;
> +	u16 TxAGC;
>  
>  	TxAGC = TxPower;
>  	set_bb_reg(pAdapter, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
> @@ -726,7 +726,7 @@ static u32 GetPhyRxPktCounts(struct _adapter *pAdapter, u32 selbit)
>  
>  u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
>  {
> -	u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
> +	u32 OFDM_cnt, CCK_cnt, HT_cnt;
>  
>  	OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT);
>  	CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT);
> @@ -736,7 +736,7 @@ u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
>  
>  u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter)
>  {
> -	u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
> +	u32 OFDM_cnt, CCK_cnt, HT_cnt;
>  
>  	OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT);
>  	CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT);
> -- 
> 1.9.1
> 
> -- 
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/654a2272bc6169ee93a7c08a62bc855969d878ba.1444855933.git.amitoj1606%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
> 


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

* Re: [Outreachy kernel] [PATCH v2 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation
  2015-10-14 21:01 ` [PATCH 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation Amitoj Kaur Chawla
  2015-10-14 21:21   ` [Outreachy kernel] " Julia Lawall
@ 2015-10-15  6:35   ` Julia Lawall
  1 sibling, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2015-10-15  6:35 UTC (permalink / raw)
  To: Amitoj Kaur Chawla; +Cc: outreachy-kernel

On Thu, 15 Oct 2015, Amitoj Kaur Chawla wrote:

> Remove intialisation of a variable that is immediately reassigned. The
> problem was found using coccinelle semantic patch and further opportunities were
> identified by hand.

Better, thanks.

julia

> The semantic patch used to find this is:
> 
> // <smpl>
> @@
> type T;
> identifier x;
> constant C;
> expression e;
> @@
> 
> T x
> - = C
>  ;
> x = e;
> // </smpl>
> 
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
> Changes in v2:
>         -Modify commit message
> 
>  drivers/staging/rtl8712/rtl871x_mp.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c
> index 26201ea..00b80f7 100644
> --- a/drivers/staging/rtl8712/rtl871x_mp.c
> +++ b/drivers/staging/rtl8712/rtl871x_mp.c
> @@ -295,7 +295,7 @@ void r8712_SetChannel(struct _adapter *pAdapter)
>  
>  static void SetCCKTxPower(struct _adapter *pAdapter, u8 TxPower)
>  {
> -	u16 TxAGC = 0;
> +	u16 TxAGC;
>  
>  	TxAGC = TxPower;
>  	set_bb_reg(pAdapter, rTxAGC_CCK_Mcs32, bTxAGCRateCCK, TxAGC);
> @@ -726,7 +726,7 @@ static u32 GetPhyRxPktCounts(struct _adapter *pAdapter, u32 selbit)
>  
>  u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
>  {
> -	u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
> +	u32 OFDM_cnt, CCK_cnt, HT_cnt;
>  
>  	OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT);
>  	CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT);
> @@ -736,7 +736,7 @@ u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter)
>  
>  u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter)
>  {
> -	u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0;
> +	u32 OFDM_cnt, CCK_cnt, HT_cnt;
>  
>  	OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT);
>  	CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT);
> -- 
> 1.9.1
> 
> -- 
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/654a2272bc6169ee93a7c08a62bc855969d878ba.1444855933.git.amitoj1606%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
> 


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

end of thread, other threads:[~2015-10-15  6:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-14 20:54 [PATCH 0/5] staging: Remove useless intialisation Amitoj Kaur Chawla
2015-10-14 20:56 ` [PATCH 1/5] staging: unisys: " Amitoj Kaur Chawla
2015-10-14 20:57 ` [PATCH 2/5] staging: speakup: speakup_audptr: " Amitoj Kaur Chawla
2015-10-14 20:58 ` [PATCH 3/5] staging: speakup: varhandlers: " Amitoj Kaur Chawla
2015-10-14 20:59 ` [PATCH 4/5] staging: rtl8712: rtl8712_recv: " Amitoj Kaur Chawla
2015-10-14 21:01 ` [PATCH 5/5] staging: rtl8712: rtl871x_mp: Remove useless initialisation Amitoj Kaur Chawla
2015-10-14 21:21   ` [Outreachy kernel] " Julia Lawall
2015-10-15  6:35   ` [Outreachy kernel] [PATCH v2 " Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.