Skip to contentSkip to conversation

staging: rtl8192u: constify ieee80211_qos_parameters structure

PATCH Superseded Gargi Sharma 2 participants 4 messages Mar 1, 2017 Staging

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8192u: constify ieee80211_qos_parameters structure

Declare def_qos_parameters instance of the ieee80211_qos_parameters structure as const since no modification is done to it. It is only used in two other places in the driver where it is the src parameter to memcpy.

Done using Coccinelle script:

@r1 disable optional_qualifier@
identifier i;
position p;
@@

static struct ieee80211_qos_parameters i@p ={...};

@@
identifier r1.i;
@@
+const
struct ieee80211_qos_parameters i

---
 drivers/staging/rtl8192u/r8192U_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_core.c +1 -1
index b631990..bbb5f58 100644
@@ -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
#1 lore raw
Quoted 12 lines · Gargi Sharma

Declare def_qos_parameters instance of the ieee80211_qos_parameters structure as const since no modification is done to it. It is only used in two other places in the driver where it is the src parameter to memcpy.

Done using Coccinelle script:

@r1 disable optional_qualifier@
identifier i;
position p;
@@

Quoted 7 lines

static struct ieee80211_qos_parameters i@p ={...};

@@
identifier r1.i;
@@
+const
struct ieee80211_qos_parameters i

I'm not sure that it makes that much sense to write such a Coccinelle script. It is only being applied in one place. And the script is not doing anything to ensure that the change is safe. To make a structure const, you have to check on how it is used, to ensure that the fields are not modified anywhere.

I'm not even sure that the second rule would parse?

julia

Quoted 29 lines
---
 drivers/staging/rtl8192u/r8192U_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192u/r8192U_core.c +1 -2
index b631990..bbb5f58 100644
@@ -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/1488381326-7061-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 25 lines · Julia Lawall
Quoted 12 lines · Gargi Sharma

Declare def_qos_parameters instance of the ieee80211_qos_parameters structure as const since no modification is done to it. It is only used in two other places in the driver where it is the src parameter to memcpy.

Done using Coccinelle script:

@r1 disable optional_qualifier@
identifier i;
position p;
@@

Quoted 7 lines

static struct ieee80211_qos_parameters i@p ={...};

@@
identifier r1.i;
@@
+const
struct ieee80211_qos_parameters i

Quoted 5 lines

I'm not sure that it makes that much sense to write such a Coccinelle script. It is only being applied in one place. And the script is not doing anything to ensure that the change is safe. To make a structure const, you have to check on how it is used, to ensure that the fields are not modified anywhere.

The structure is only used inside memcpy as the src parameter. Perhaps what you mean is that I should check using Coccinelle that the structure is not modified anywhere?

Quoted 2 lines

I'm not even sure that the second rule would parse?

I missed a ; at the end while writing the script in the mail. Once that is included
the second rule parses.

gargi

Quoted 10 lines

julia

Review

Quoted 7 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

Quoted 4 lines

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
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

Quoted 2 lines
Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line
Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines
Quoted 2 lines

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/1488381326-7061-1-git-send-email-gs051095%40gmail.com .

Quoted 2 lines
Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 26 lines · Gargi Sharma
Quoted 25 lines · Julia Lawall
Quoted 19 lines · Gargi Sharma

Declare def_qos_parameters instance of the ieee80211_qos_parameters structure as const since no modification is done to it. It is only used in two other places in the driver where it is the src parameter to memcpy.

Done using Coccinelle script:

@r1 disable optional_qualifier@
identifier i;
position p;
@@

static struct ieee80211_qos_parameters i@p ={...};

@@
identifier r1.i;
@@
+const
struct ieee80211_qos_parameters i

Quoted 8 lines
Quoted 5 lines

I'm not sure that it makes that much sense to write such a Coccinelle script.  It is only being applied in one place.  And the script is not doing anything to ensure that the change is safe.  To make a structure const, you have to check on how it is used, to ensure that the fields are not modified anywhere.The structure is only used inside memcpy as the src

parameter. Perhaps what
you mean is that I should check using Coccinelle that the structure is not modified anywhere?

You can if you like, but you aren't obliged to. Coccinelle scripts don't have to be 100% safe. But the change that you propose, without careful additional checking, is more like 0% safe, so I think that it is a bit misleading to post a script for it.

julia

Quoted 57 lines
Quoted 3 lines

I'm not even sure that the second rule would parse?

I missed a ; at the end while writing the script in the mail. Once that is includedthe second rule parses.

gargi

Quoted 10 lines

julia

Review

Quoted 7 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

Quoted 4 lines

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
Quoted 11 lines
drivers/staging/rtl8192u/r8192U_core.c +1 -1
       }
  }
 
-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

Quoted 2 lines
Quoted 2 lines

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line
Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines
Quoted 2 lines

To post to this group, send email to [email protected].
To view this discussion on the web visithttps://groups.google.com/d/msgid/outreachy-kernel/1488381326-7061-1-git-se

nd-email-gs051095%40gmail.com.

Quoted 2 lines
Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.

--
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 visithttps://groups.google.com/d/msgid/outreachy-kernel/CAOCi2DFyYaRwvypnHD1RXmQ ye4Nis9Mky4qPiEc94O7zujGQmg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.