Remove constant and unused code
v2 cover Remove constant and unused code
This patch removes unused code, changes the variable type to more effective one and, removes unnecessary constant definitions. After applying this patch, code becomes better.
Shivani Bhardwaj (3):
Staging: wilc1000: wilc_wfi_cfgoperations: Remove unused code
Staging: wilc1000: wilc_wfi_cfgoperations: Change variable to bool
Staging: wilc1000: wilc_wfi_netdevice: Remove definition of a constant
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 8 +++----- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-)
Signature · 1 line
2.1.0
PATCH v2 1/3 Staging: wilc1000: wilc_wfi_cfgoperations: Remove unused code
Remove a flag variable which is not used anywhere in the code. Semantic patch used:
@@
type T;
identifier i;
constant C;
position p != e.p;
@@
- T i@p;
<+... when != i
- i = C;
...+>
---
Changes in v2:
-Remove the definition of constant from header file, include one more patch.
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +0 -2
@@ -1764,7 +1764,6 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, {u32 i; -u8 flag =0 ;s32 s32Error =0 ;struct wilc_priv *priv =wiphy_priv (wiphy);
@@ -1777,7 +1776,6 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,/*If bssid is found, reset the values*/ PRINT_D (CFG80211_DBG ,"Reseting PMKID values\n" );memset (&priv->pmkid_list.pmkidlist[i],0 ,sizeof (struct host_if_pmkid )); - flag =PMKID_FOUND ;break ; } }
Signature · 1 line
2.1.0
PATCH v2 2/3 Staging: wilc1000: wilc_wfi_cfgoperations: Change variable to bool
In reply to Shivani BhardwajChange variable of the type u8 to bool as the only values acquired by it are true or false.
---
Changes in v2:
-Remove the definition of constant from header file, include one more patch.
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +3 -3
@@ -1714,7 +1714,7 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, {u32 i;s32 s32Error =0 ; -u8 flag =0 ; +bool pmkid_found = false;struct wilc_priv *priv =wiphy_priv (wiphy);
@@ -1725,7 +1725,7 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,if (!memcmp (pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,ETH_ALEN )) {/*If bssid already exists and pmkid value needs to reset*/ - flag =PMKID_FOUND ; + pmkid_found = true;PRINT_D (CFG80211_DBG ,"PMKID already exists\n" );break ; }
@@ -1736,7 +1736,7 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, ETH_ALEN);memcpy (priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,PMKID_LEN ); -if (!(flag ==PMKID_FOUND )) +if (!pmkid_found) priv->pmkid_list.numpmkid++; }else {PRINT_ER ("Invalid PMKID index\n" );
Signature · 1 line
2.1.0
PATCH v2 3/3 Staging: wilc1000: wilc_wfi_netdevice: Remove definition of a constant
In reply to Shivani BhardwajRemove definition of the constant PMKID_FOUND as it is not required to be used in the entire code.
---
Changes in v2:
-Remove the definition of constant from header file, include one more patch.
drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/wilc_wfi_netdevice.h +1 -2
@@ -14,8 +14,7 @@#define WILC_WFI_TIMEOUT 5#define WILC_MAX_NUM_PMKIDS 16#define PMKID_LEN 16 -#define PMKID_FOUND 1 -#define NUM_STA_ASSOCIATED 8 +#define NUM_STA_ASSOCIATED 8#include <linux/module.h> #include <linux/init.h>
Signature · 1 line
2.1.0