* [PATCH v2] staging: rtl8192u: Constufy ieee80211_qos_parameters structure
@ 2017-03-02 5:19 Gargi Sharma
2017-03-02 5:37 ` Gargi Sharma
0 siblings, 1 reply; 2+ messages in thread
From: Gargi Sharma @ 2017-03-02 5:19 UTC (permalink / raw)
To: outreachy-kernel; +Cc: gregkh, Gargi Sharma
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={...};
Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
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(-)
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index b631990..bbb5f58 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] staging: rtl8192u: Constufy ieee80211_qos_parameters structure
2017-03-02 5:19 [PATCH v2] staging: rtl8192u: Constufy ieee80211_qos_parameters structure Gargi Sharma
@ 2017-03-02 5:37 ` Gargi Sharma
0 siblings, 0 replies; 2+ messages in thread
From: Gargi Sharma @ 2017-03-02 5:37 UTC (permalink / raw)
To: outreachy-kernel
[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]
On Thu, Mar 2, 2017 at 10:49 AM, Gargi Sharma <gs051095@gmail.com> wrote:
>
> 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.
>
The commit message is a bit incorrect here. Please ignore this patch.
thanks and apologies,
gargi
> 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={...};
>
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ---
> 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(-)
>
> diff --git a/drivers/staging/rtl8192u/r8192U_core.c
b/drivers/staging/rtl8192u/r8192U_core.c
> index b631990..bbb5f58 100644
> --- a/drivers/staging/rtl8192u/r8192U_core.c
> +++ b/drivers/staging/rtl8192u/r8192U_core.c
> @@ -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
>
[-- Attachment #2: Type: text/html, Size: 2427 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-02 5:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-02 5:19 [PATCH v2] staging: rtl8192u: Constufy ieee80211_qos_parameters structure Gargi Sharma
2017-03-02 5:37 ` Gargi Sharma
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.