All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: wilc1000: merge 'if' statements that test the same condition
@ 2018-02-24  7:47 Dafna Hirschfeld
  2018-02-24  8:03 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Dafna Hirschfeld @ 2018-02-24  7:47 UTC (permalink / raw)
  To: aditya.shankar, ganesh.krishna, gregkh; +Cc: outreachy-kernel

Merge the instructions of two 'if' statements that test the same
condition and move a 'memcpy' instruction related to a different variable.
Issue found with coccicheck.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
---
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 621810d..f6f2c7f8 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -962,15 +962,13 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
 
 				priv->wilc_ptk[key_index]->key = kmalloc(params->key_len, GFP_KERNEL);
 
+				memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
 				kfree(priv->wilc_ptk[key_index]->seq);
 
-				if (params->seq_len > 0)
+				if (params->seq_len > 0) {
 					priv->wilc_ptk[key_index]->seq = kmalloc(params->seq_len, GFP_KERNEL);
-
-				memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
-
-				if (params->seq_len > 0)
 					memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
+				}
 
 				priv->wilc_ptk[key_index]->cipher = params->cipher;
 				priv->wilc_ptk[key_index]->key_len = params->key_len;
-- 
2.7.4



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

end of thread, other threads:[~2018-02-25  8:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-24  7:47 [PATCH] staging: wilc1000: merge 'if' statements that test the same condition Dafna Hirschfeld
2018-02-24  8:03 ` [Outreachy kernel] " Julia Lawall
2018-02-24  9:02   ` Dafna Hirschfeld
2018-02-24  9:38     ` Julia Lawall
2018-02-25  6:06       ` Dafna Hirschfeld
2018-02-25  8:50         ` 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.