staging: rtl8192u: Constufy ieee80211_qos_parameters structure
PATCH v2 1/1 staging: rtl8192u: Constufy ieee80211_qos_parameters structure
Declare def_qos_parameters instance of the ieee80211_qos_parameters structure as it is only passed src parameter to the function memcpy. The fields of def_qos_parameters structure are never modified and hence it can be declared as const.
Coccinelle Script:
@r1 disable optional_qualifier@
identifier i;
position p;
@@
static struct ieee80211_qos_parameters i@p ={...};
@ok1@
identifier r1.i;
position p;
expression e1,e2;
@@memcpy(e1,&i@p,e2)
@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
struct ieee80211_qos_parameters i={...};
---
Changes in v2:
- Improved the coccinelle script to check for safety of the modification.
- Improved the commit message.
--- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_core.c +1 -1
@@ -1814,7 +1814,7 @@ static void rtl8192_link_change(struct net_device *dev) } } -static struct ieee80211_qos_parameters def_qos_parameters = { +static const struct ieee80211_qos_parameters def_qos_parameters = { {cpu_to_le16 (3 ),cpu_to_le16 (3 ),cpu_to_le16 (3 ),cpu_to_le16 (3 )}, {cpu_to_le16 (7 ),cpu_to_le16 (7 ),cpu_to_le16 (7 ),cpu_to_le16 (7 )}, {2 ,2 ,2 ,2 },/* aifs */
Signature · 1 line
2.7.4
Quoted 6 lines · Gargi Sharma
Declare
def_qos_parametersinstance of theieee80211_qos_parametersstructure as it is only passed src parameter to the function memcpy. The fields ofdef_qos_parametersstructure are never modified and hence it can be declared as const.
The commit message is a bit incorrect here. Please ignore this patch.
thanks and apologies,
gargi
Quoted 35 lines
Coccinelle Script:
@r1 disable optional_qualifier@
identifier i;
position p;
@@static struct
ieee80211_qos_parametersi@p ={...};@ok1@
identifier r1.i;
position p;
expression e1,e2;
@@memcpy(e1,&i@p,e2)@bad@
position p!={r1.p,ok1.p};
identifier r1.i;
@@
i@p@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
structieee80211_qos_parametersi={...};Signed-off-by Gargi Sharma <[email protected]>---
Changes in v2:
- Improved the coccinelle script to check for safety of the modification.
- Improved the commit message.
Review
Quoted 5 lines
--- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)(quoted diff) +0
-0
b/drivers/staging/rtl8192u/r8192U_core.c
drivers/staging/rtl8192u/r8192U_core.c static void rtl8192_link_change(struct net_device
Quoted 4 lines
index b631990..bbb5f58 100644
drivers/staging/rtl8192u/r8192U_core.c +0
-0@@ -1814,7 +1814,7 @@ static void rtl8192_link_change(struct net_device
*dev)
Quoted 11 lines
drivers/staging/rtl8192u/r8192U_core.c +1
-2} } -static struct ieee80211_qos_parameters def_qos_parameters = { +static const struct ieee80211_qos_parameters def_qos_parameters = { {cpu_to_le16 (3 ),cpu_to_le16 (3 ),cpu_to_le16 (3 ),cpu_to_le16 (3 )}, {cpu_to_le16 (7 ),cpu_to_le16 (7 ),cpu_to_le16 (7 ),cpu_to_le16 (7 )}, {2 ,2 ,2 ,2 },/* aifs */ --2.7.4