All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192u: constify ieee80211_qos_parameters structure
@ 2017-03-01 15:15 Gargi Sharma
  2017-03-01 15:24 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Gargi Sharma @ 2017-03-01 15:15 UTC (permalink / raw)
  To: outreachy-kernel; +Cc: gregkh, 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

Signed-off-by: Gargi Sharma <gs051095@gmail.com>
---
 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] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: rtl8192u: constify ieee80211_qos_parameters structure
  2017-03-01 15:15 [PATCH] staging: rtl8192u: constify ieee80211_qos_parameters structure Gargi Sharma
@ 2017-03-01 15:24 ` Julia Lawall
  2017-03-01 16:00   ` Gargi Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2017-03-01 15:24 UTC (permalink / raw)
  To: Gargi Sharma; +Cc: outreachy-kernel, gregkh



On Wed, 1 Mar 2017, Gargi Sharma wrote:

> 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

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

>
> Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> ---
>  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
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: rtl8192u: constify ieee80211_qos_parameters structure
  2017-03-01 15:24 ` [Outreachy kernel] " Julia Lawall
@ 2017-03-01 16:00   ` Gargi Sharma
  2017-03-01 20:07     ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Gargi Sharma @ 2017-03-01 16:00 UTC (permalink / raw)
  To: Julia Lawall; +Cc: outreachy-kernel, Greg KH

[-- Attachment #1: Type: text/plain, Size: 2691 bytes --]

On Wed, Mar 1, 2017 at 8:54 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
>
>
>
> On Wed, 1 Mar 2017, Gargi Sharma wrote:
>
> > 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
>
> 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?

>
> 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
>
> julia
>
> >
> > Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> > ---
> >  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
> >
> > --
> > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > 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.
> >

[-- Attachment #2: Type: text/html, Size: 3900 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Outreachy kernel] [PATCH] staging: rtl8192u: constify ieee80211_qos_parameters structure
  2017-03-01 16:00   ` Gargi Sharma
@ 2017-03-01 20:07     ` Julia Lawall
  0 siblings, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2017-03-01 20:07 UTC (permalink / raw)
  To: Gargi Sharma; +Cc: outreachy-kernel, Greg KH

[-- Attachment #1: Type: text/plain, Size: 3714 bytes --]



On Wed, 1 Mar 2017, Gargi Sharma wrote:

> On Wed, Mar 1, 2017 at 8:54 PM, Julia Lawall <julia.lawall@lip6.fr> wrote:
> >
> >
> >
> > On Wed, 1 Mar 2017, Gargi Sharma wrote:
> >
> > > 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
> >
> > 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

>
> >
> > 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
> >
> > julia
> >
> > >
> > > Signed-off-by: Gargi Sharma <gs051095@gmail.com>
> > > ---
> > >  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
> > >
> > > --
> > > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> > > To post to this group, send email to outreachy-kernel@googlegroups.com.
> > > 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.
> > > 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> 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.
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-01 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-01 15:15 [PATCH] staging: rtl8192u: constify ieee80211_qos_parameters structure Gargi Sharma
2017-03-01 15:24 ` [Outreachy kernel] " Julia Lawall
2017-03-01 16:00   ` Gargi Sharma
2017-03-01 20:07     ` Julia Lawall

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.