staging: rtl8192u: Constify ieee80211_qos_parameters structure
PATCH v3 1/1 staging: rtl8192u: Constify ieee80211_qos_parameters structure
Declare ieee80211_qos_parameters structure constant it is only passed as 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 v3:
- Fixed the commit message.
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 27 lines · Gargi Sharma
Declare
ieee80211_qos_parametersstructure constant it is only passed as src parameter to the function memcpy. The fields ofdef_qos_parametersstructure 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_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
Quoted 6 lines
@depends on !bad disable optional_qualifier@
identifier r1.i;
@@
static
+const
structieee80211_qos_parametersi={...};
This script is much more appropriate, thanks.
julia
Quoted 36 lines
Signed-off-by Gargi Sharma <[email protected]>---
Changes in v3:
- Fixed the commit message.
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
-2@@ -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 */ --2.7.4
--
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 [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488433574-26080-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.