[PATCH] ACS ACR122U not working: pn533_usb 1-1:1.0: NFC: fix memdup.cocci warnings

2018-05-18 Thread Julia Lawall

From: kbuild test robot <fengguang...@intel.com>

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: fe1c559e1567 ("ACS ACR122U not working: pn533_usb 1-1:1.0: NFC: Couldn't 
poweron...")
CC: Greg KH <gre...@linuxfoundation.org>
Signed-off-by: kbuild test robot <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---

url:
https://github.com/0day-ci/linux/commits/Greg-KH/NFC-pn533-don-t-send-USB-data-off-of-the-stack/20180518-100416
:: branch date: 54 minutes ago
:: commit date: 54 minutes ago

 usb.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -153,10 +153,9 @@ static int pn533_usb_send_ack(struct pn5
char *buffer;
int rc;

-   buffer = kmalloc(sizeof(ack), GFP_KERNEL);
+   buffer = kmemdup(ack, sizeof(ack), GFP_KERNEL);
if (!buffer)
return -ENOMEM;
-   memcpy(buffer, ack, sizeof(ack));

phy->out_urb->transfer_buffer = (u8 *)ack;
phy->out_urb->transfer_buffer_length = sizeof(ack);
@@ -390,10 +389,9 @@ static int pn533_acr122_poweron_rdr(stru

dev_dbg(>udev->dev, "%s\n", __func__);

-   buffer = kmalloc(sizeof(cmd), GFP_KERNEL);
+   buffer = kmemdup(cmd, sizeof(cmd), GFP_KERNEL);
if (!buffer)
return -ENOMEM;
-   memcpy(buffer, cmd, sizeof(cmd));

init_completion();
cntx = phy->in_urb->context;  /* backup context */


[PATCH] mwifiex: delete unneeded include

2018-05-06 Thread Julia Lawall
Nothing that is defined in 11ac.h is referenced in cmdevt.c.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/net/wireless/marvell/mwifiex/cmdevt.c |1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/cmdevt.c 
b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
index 7014f44..9cfcdf6 100644
--- a/drivers/net/wireless/marvell/mwifiex/cmdevt.c
+++ b/drivers/net/wireless/marvell/mwifiex/cmdevt.c
@@ -25,7 +25,6 @@
 #include "main.h"
 #include "wmm.h"
 #include "11n.h"
-#include "11ac.h"
 
 static void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
 



[PATCH] staging: wilc1000: fix memdup.cocci warnings

2018-03-26 Thread Julia Lawall
From: Fengguang Wu <fengguang...@intel.com>

drivers/staging/wilc1000/host_interface.c:946:32-39: WARNING opportunity for 
kmemdup
drivers/staging/wilc1000/host_interface.c:970:30-37: WARNING opportunity for 
kmemdup

 Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Fixes: aaea2164bdff ("staging: wilc1000: check for kmalloc allocation failures")
CC: Colin Ian King <colin.k...@canonical.com>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git
staging-next
head:   12a0148711a440f5b7111f95a34dfce88cdb47d6
commit: aaea2164bdff39697d0f1ec69dcae62632e37974 [400/412] staging:
wilc1000: check for kmalloc allocation failures

In the first hunk, should 6 be ETH_ALEN?

 host_interface.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -943,12 +943,12 @@ static s32 handle_connect(struct wilc_vi
}

if (conn_attr->bssid) {
-   hif_drv->usr_conn_req.bssid = kmalloc(6, GFP_KERNEL);
+   hif_drv->usr_conn_req.bssid = kmemdup(conn_attr->bssid, 6,
+ GFP_KERNEL);
if (!hif_drv->usr_conn_req.bssid) {
result = -ENOMEM;
goto error;
}
-   memcpy(hif_drv->usr_conn_req.bssid, conn_attr->bssid, 6);
}

hif_drv->usr_conn_req.ssid_len = conn_attr->ssid_len;
@@ -967,15 +967,13 @@ static s32 handle_connect(struct wilc_vi

hif_drv->usr_conn_req.ies_len = conn_attr->ies_len;
if (conn_attr->ies) {
-   hif_drv->usr_conn_req.ies = kmalloc(conn_attr->ies_len,
+   hif_drv->usr_conn_req.ies = kmemdup(conn_attr->ies,
+   conn_attr->ies_len,
GFP_KERNEL);
if (!hif_drv->usr_conn_req.ies) {
result = -ENOMEM;
goto error;
}
-   memcpy(hif_drv->usr_conn_req.ies,
-  conn_attr->ies,
-  conn_attr->ies_len);
}

hif_drv->usr_conn_req.security = conn_attr->security;


Re: [PATCH] wireless: iwlegacy: make const array static to shink object code size Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit

2017-09-22 Thread Julia Lawall


On Fri, 22 Sep 2017, Joe Perches wrote:

> On Fri, 2017-09-22 at 12:06 +0200, Julia Lawall wrote:
> >
> > On Fri, 22 Sep 2017, Colin Ian King wrote:
> >
> > > On 22/09/17 11:03, Joe Perches wrote:
> > > > On Fri, 2017-09-22 at 09:23 +0200, Julia Lawall wrote:
> > > > >
> > > > > On Thu, 21 Sep 2017, Colin King wrote:
> > > > >
> > > > > > From: Colin Ian King <colin.k...@canonical.com>
> > > > > >
> > > > > > Don't populate const array ac_to_fifo on the stack in an inlined
> > > > > > function, instead make it static.  Makes the object code smaller
> > > > > > by over 800 bytes:
> > > > > >
> > > > > >textdata bss dec hex filename
> > > > > >  159029   331541216  193399   2f377 4965-mac.o
> > > > > >
> > > > > >textdata bss dec hex filename
> > > > > >  158122   332501216  192588   2f04c 4965-mac.o
> > > > > >
> > > > > > (gcc version 7.2.0 x86_64)
> > > > >
> > > > > Gcc 7 must be much more aggressive about inlining than gcc 4.  Here 
> > > > > is the
> > > > > change that I got on this file:
> > > > >
> > > > >  text  data bss dec hex filename
> > > > > -   76346  1494 152   77992   130a8 
> > > > > drivers/net/wireless/intel/iwlegacy/4965-mac.o
> > > > > +   76298  1494 152   77944   13078 
> > > > > drivers/net/wireless/intel/iwlegacy/4965-mac.o
> > > > > decrease of 48
> > > >
> > > > More likely different CONFIG options.
> > > >
> > > > e.g. allyesconfig vs defconfig with wireless
> > > >
> > >
> > > yup, I used allyesconfig
> >
> > Mine is also allyesconfig.
>
> Odd.
>
> Here is what I get: (Sorry, no gcc-7)
>
> gcc4: gcc-4.9 (Ubuntu 4.9.4-2ubuntu1) 4.9.4
> gcc5: gcc-5 (Ubuntu 5.4.1-8ubuntu1) 5.4.1 20170304
> gcc6: gcc-6 (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406
>
> $ size drivers/net/wireless/intel/iwlegacy/4965-mac.o*
>    text      data bss dec hex filename
>  118559      1766 152  120477   1d69d 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc4.allyesconfig.new
>  118623      1766 152  120541   1d6dd 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc4.allyesconfig.old

My gcc is 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

You get a savings of 64 and I got a savings of 48, but it's not that big a
difference, compared to what the later versions give.

julia

>   51595      1156   0   52751    ce0f 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc4.defconfig.new
>   51659      1156   0   52815    ce4f 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc4.defconfig.old
>  141956     29790    1216  172962   2a3a2 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc5.allyesconfig.new
>  142671     29702    1216  173589   2a615 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc5.allyesconfig.old
>   51733      1156   0   52889    ce99 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc5.defconfig.new
>   51813      1156   0   52969    cee9 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc5.defconfig.old
>  152991     29790    1216  183997   2cebd 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc6.allyesconfig.new
>  153722     29702    1216  184640   2d140 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc6.allyesconfig.old
>   51813      1156   0   52969    cee9 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc6.defconfig.new
>   51893      1156   0   53049    cf39 
> drivers/net/wireless/intel/iwlegacy/4965-mac.o.gcc6.defconfig.old
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Re: [PATCH] wireless: iwlegacy: make const array static to shink object code size Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit

2017-09-22 Thread Julia Lawall


On Fri, 22 Sep 2017, Colin Ian King wrote:

> On 22/09/17 11:03, Joe Perches wrote:
> > On Fri, 2017-09-22 at 09:23 +0200, Julia Lawall wrote:
> >>
> >> On Thu, 21 Sep 2017, Colin King wrote:
> >>
> >>> From: Colin Ian King <colin.k...@canonical.com>
> >>>
> >>> Don't populate const array ac_to_fifo on the stack in an inlined
> >>> function, instead make it static.  Makes the object code smaller
> >>> by over 800 bytes:
> >>>
> >>>text  data bss dec hex filename
> >>>  159029 331541216  193399   2f377 4965-mac.o
> >>>
> >>>text  data bss dec hex filename
> >>>  158122 332501216  192588   2f04c 4965-mac.o
> >>>
> >>> (gcc version 7.2.0 x86_64)
> >>
> >> Gcc 7 must be much more aggressive about inlining than gcc 4.  Here is the
> >> change that I got on this file:
> >>
> >>  text  data bss dec hex filename
> >> -   76346  1494 152   77992   130a8 
> >> drivers/net/wireless/intel/iwlegacy/4965-mac.o
> >> +   76298  1494 152   77944   13078 
> >> drivers/net/wireless/intel/iwlegacy/4965-mac.o
> >> decrease of 48
> >
> > More likely different CONFIG options.
> >
> > e.g. allyesconfig vs defconfig with wireless
> >
> yup, I used allyesconfig

Mine is also allyesconfig.

julia

>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


Re: [PATCH] wireless: iwlegacy: make const array static to shink object code size Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit

2017-09-22 Thread Julia Lawall


On Thu, 21 Sep 2017, Colin King wrote:

> From: Colin Ian King 
>
> Don't populate const array ac_to_fifo on the stack in an inlined
> function, instead make it static.  Makes the object code smaller
> by over 800 bytes:
>
>text  data bss dec hex filename
>  159029 331541216  193399   2f377 4965-mac.o
>
>text  data bss dec hex filename
>  158122 332501216  192588   2f04c 4965-mac.o
>
> (gcc version 7.2.0 x86_64)

Gcc 7 must be much more aggressive about inlining than gcc 4.  Here is the
change that I got on this file:

 text  data bss dec hex filename
-   76346  1494 152   77992   130a8 
drivers/net/wireless/intel/iwlegacy/4965-mac.o
+   76298  1494 152   77944   13078 
drivers/net/wireless/intel/iwlegacy/4965-mac.o
decrease of 48

julia

>
> Signed-off-by: Colin Ian King 
> ---
>  drivers/net/wireless/intel/iwlegacy/4965-mac.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c 
> b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
> index de9b6522c43f..65eba2c24292 100644
> --- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
> +++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
> @@ -1480,7 +1480,7 @@ il4965_get_ac_from_tid(u16 tid)
>  static inline int
>  il4965_get_fifo_from_tid(u16 tid)
>  {
> - const u8 ac_to_fifo[] = {
> + static const u8 ac_to_fifo[] = {
>   IL_TX_FIFO_VO,
>   IL_TX_FIFO_VI,
>   IL_TX_FIFO_BE,
> --
> 2.14.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


Re: [Outreachy kernel] [PATCH v4 1/3] staging: wilc1000: Rename struct tstrRSSI to rssi_history_buffer

2017-02-24 Thread Julia Lawall


On Fri, 24 Feb 2017, Tahia Khan wrote:

> Rename struct tstrRSSI to rssi_history_buffer for clarity
> and to remove camel casing.
>
> Signed-off-by: Tahia Khan <tahia.k...@gmail.com>

Acked-by: Julia Lawall <julia.law...@lip6.fr>


> ---
>  drivers/staging/wilc1000/coreconfigurator.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
> b/drivers/staging/wilc1000/coreconfigurator.h
> index cff1698..1c77529 100644
> --- a/drivers/staging/wilc1000/coreconfigurator.h
> +++ b/drivers/staging/wilc1000/coreconfigurator.h
> @@ -70,7 +70,7 @@ enum connect_status {
>   CONNECT_STS_FORCE_16_BIT = 0x
>  };
>
> -struct tstrRSSI {
> +struct rssi_history_buffer {
>   u8 u8Full;
>   u8 u8Index;
>   s8 as8RSSI[NUM_RSSI];
> @@ -93,7 +93,7 @@ struct network_info {
>   u8 *ies;
>   u16 ies_len;
>   void *join_params;
> - struct tstrRSSI str_rssi;
> + struct rssi_history_buffer str_rssi;
>   u64 tsf_hi;
>  };
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/da73d1aef379243ba94a5c1a4e1d6663160451fd.1487947616.git.tahia.khan%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v3 1/3] staging: wilc1000: Rename struct tstrRSSI to rssi_history_buffer

2017-02-23 Thread Julia Lawall


On Fri, 24 Feb 2017, Tahia Khan wrote:

> Rename struct tstrRSSI to rssi_history_buffer for clarity and to remove camel 
> casing.

Here the commit log messge line is definitely too long.

julia

>
> Signed-off-by: Tahia Khan 
> ---
>  drivers/staging/wilc1000/coreconfigurator.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
> b/drivers/staging/wilc1000/coreconfigurator.h
> index cff1698..1c77529 100644
> --- a/drivers/staging/wilc1000/coreconfigurator.h
> +++ b/drivers/staging/wilc1000/coreconfigurator.h
> @@ -70,7 +70,7 @@ enum connect_status {
>   CONNECT_STS_FORCE_16_BIT = 0x
>  };
>
> -struct tstrRSSI {
> +struct rssi_history_buffer {
>   u8 u8Full;
>   u8 u8Index;
>   s8 as8RSSI[NUM_RSSI];
> @@ -93,7 +93,7 @@ struct network_info {
>   u8 *ies;
>   u16 ies_len;
>   void *join_params;
> - struct tstrRSSI str_rssi;
> + struct rssi_history_buffer str_rssi;
>   u64 tsf_hi;
>  };
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/da73d1aef379243ba94a5c1a4e1d6663160451fd.1487912400.git.tahia.khan%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] [PATCH v3 2/3] staging: wilc1000: Rename tstrRSSI members and change type of u8Full to bool

2017-02-23 Thread Julia Lawall


On Fri, 24 Feb 2017, Tahia Khan wrote:

> Remove Hungarian notation and camel casing from all tstrRSSI members' names.
> Additionally, change type of u8Full to bool since it only takes values 1 or 0.

Acked-by: Julia Lawall <julia.law...@lip6.fr>

Maybe the second line of the commit message is a little too long.  It is
under 80 characters, but they come out a bit indented in the git log, so a
little shorter is better.

julia

>
> Signed-off-by: Tahia Khan <tahia.k...@gmail.com>
> ---
>  drivers/staging/wilc1000/coreconfigurator.h   |  6 +++---
>  drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 14 +++---
>  2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
> b/drivers/staging/wilc1000/coreconfigurator.h
> index 1c77529..9712d89 100644
> --- a/drivers/staging/wilc1000/coreconfigurator.h
> +++ b/drivers/staging/wilc1000/coreconfigurator.h
> @@ -71,9 +71,9 @@ enum connect_status {
>  };
>
>  struct rssi_history_buffer {
> - u8 u8Full;
> - u8 u8Index;
> - s8 as8RSSI[NUM_RSSI];
> + bool full;
> + u8 index;
> + s8 samples[NUM_RSSI];
>  };
>
>  struct network_info {
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> index f7ce47c..9601ab8 100644
> --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> @@ -205,11 +205,11 @@ static u32 get_rssi_avg(struct network_info 
> *network_info)
>  {
>   u8 i;
>   int rssi_v = 0;
> - u8 num_rssi = (network_info->str_rssi.u8Full) ?
> -NUM_RSSI : (network_info->str_rssi.u8Index);
> + u8 num_rssi = (network_info->str_rssi.full) ?
> +NUM_RSSI : (network_info->str_rssi.index);
>
>   for (i = 0; i < num_rssi; i++)
> - rssi_v += network_info->str_rssi.as8RSSI[i];
> + rssi_v += network_info->str_rssi.samples[i];
>
>   rssi_v /= num_rssi;
>   return rssi_v;
> @@ -346,13 +346,13 @@ static void add_network_to_shadow(struct network_info 
> *pstrNetworkInfo,
>   } else {
>   ap_index = ap_found;
>   }
> - rssi_index = last_scanned_shadow[ap_index].str_rssi.u8Index;
> - last_scanned_shadow[ap_index].str_rssi.as8RSSI[rssi_index++] = 
> pstrNetworkInfo->rssi;
> + rssi_index = last_scanned_shadow[ap_index].str_rssi.index;
> + last_scanned_shadow[ap_index].str_rssi.samples[rssi_index++] = 
> pstrNetworkInfo->rssi;
>   if (rssi_index == NUM_RSSI) {
>   rssi_index = 0;
> - last_scanned_shadow[ap_index].str_rssi.u8Full = 1;
> + last_scanned_shadow[ap_index].str_rssi.full = true;
>   }
> - last_scanned_shadow[ap_index].str_rssi.u8Index = rssi_index;
> + last_scanned_shadow[ap_index].str_rssi.index = rssi_index;
>   last_scanned_shadow[ap_index].rssi = pstrNetworkInfo->rssi;
>   last_scanned_shadow[ap_index].cap_info = pstrNetworkInfo->cap_info;
>   last_scanned_shadow[ap_index].ssid_len = pstrNetworkInfo->ssid_len;
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/e4e0e4da09635d0cb7ef43223022490b6de739a8.1487912400.git.tahia.khan%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] Re: [PATCH v2] staging: wilc1000: renames struct tstrRSSI and its members u8Index, u8Full

2017-02-23 Thread Julia Lawall


On Thu, 23 Feb 2017, 'Arend Van Spriel' via outreachy-kernel wrote:

> On 23-2-2017 8:08, Julia Lawall wrote:
> >> Thanks for the feedback Arend, I really appreciate it. I've decided to go 
> >> with
> >> these changes in my follow-up patch request:
> >>
> >> - rename tstrRSSI to 'rssi_history_buffer' as Aren suggested since it 
> >> makes the
> >> purpose of the struct clear
> >> - remove Hungarian notation from all tstrRSSI members' names
> >> - change type of u8Full to bool since it's only ever 1 or 0
> >> - change name of as8RSSI to 'samples' since this buffer is only ever used 
> >> to
> >> compute an average, and the "rssi" prefix is implied by the struct's name
> >> - rename str_rssi to rssi_history in the network_info struct for clarity
> >>
> >> Since my reasoning for these changes deviates from just "renaming to
> >> avoid camel casing" (as in the original checkpatch.pl warning), would it 
> >> still
> >> make sense to submit all this in a single patch? I know my commit message
> >> needs to change but I wonder if this is too much detail.
> >
> > I would strongly suggest not to do it all in a single patch.  Even if these
> > changes are not very complicated conceptually, there is always a chance of
> > doing things wrong.  Taking the problems one by one will improve the chance
> > that the result is correct.  Also, the results will be easier for you and
> > others to review if each patch only does one thing.  And easier to revert
> > if needed later if something goes wrong.
>
> It is all related to cleaning up stuff in a single struct which I
> consider "one thing" here. To me it looks a bit silly if you rename one
> struct member when it is obvious that the other two need to be renamed
> as well. The only somewhat sensible split I see here is: 1) rename the
> struct itself, 2) rename the struct members, and 3) rename str_rssi
> member in struct network_info.

OK.  I guess I mainly saw the change of type as being different.

julia


>
> Regards,
> Arend
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/1ffdd756-aaa4-5e1e-b72f-3e5d1f2daeb2%40broadcom.com.
> For more options, visit https://groups.google.com/d/optout.
>


Re: [Outreachy kernel] Re: [PATCH v2] staging: wilc1000: renames struct tstrRSSI and its members u8Index, u8Full

2017-02-22 Thread Julia Lawall
> Thanks for the feedback Arend, I really appreciate it. I've decided to go with
> these changes in my follow-up patch request:
>
> - rename tstrRSSI to 'rssi_history_buffer' as Aren suggested since it makes 
> the
> purpose of the struct clear
> - remove Hungarian notation from all tstrRSSI members' names
> - change type of u8Full to bool since it's only ever 1 or 0
> - change name of as8RSSI to 'samples' since this buffer is only ever used to
> compute an average, and the "rssi" prefix is implied by the struct's name
> - rename str_rssi to rssi_history in the network_info struct for clarity
>
> Since my reasoning for these changes deviates from just "renaming to
> avoid camel casing" (as in the original checkpatch.pl warning), would it still
> make sense to submit all this in a single patch? I know my commit message
> needs to change but I wonder if this is too much detail.

I would strongly suggest not to do it all in a single patch.  Even if these
changes are not very complicated conceptually, there is always a chance of
doing things wrong.  Taking the problems one by one will improve the chance
that the result is correct.  Also, the results will be easier for you and
others to review if each patch only does one thing.  And easier to revert
if needed later if something goes wrong.

julia


Re: [Outreachy kernel] [PATCH] staging: wilc1000: renames struct tstrRSSI and its members u8Index, u8Full

2017-02-21 Thread Julia Lawall


On Tue, 21 Feb 2017, Tahia Khan wrote:

> Fixes multiple camel case checks on struct tstrRSSI from checkpatch.pl:
>
> Avoid CamelCase: 
> Avoid CamelCase: 
> Avoid CamelCase: 
>
> Signed-off-by: Tahia Khan 
> ---
>  drivers/staging/wilc1000/coreconfigurator.h   |  8 
>  drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 10 +-
>  2 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/wilc1000/coreconfigurator.h 
> b/drivers/staging/wilc1000/coreconfigurator.h
> index cff1698..c9cf23b 100644
> --- a/drivers/staging/wilc1000/coreconfigurator.h
> +++ b/drivers/staging/wilc1000/coreconfigurator.h
> @@ -70,9 +70,9 @@ enum connect_status {
>   CONNECT_STS_FORCE_16_BIT = 0x
>  };
>
> -struct tstrRSSI {
> - u8 u8Full;
> - u8 u8Index;
> +struct tstr_RSSI {
> + u8 u8_full;
> + u8 u8_index;

The kernel doesn't use variable names that incorporate types.  These could
just be full and index.

julia

>   s8 as8RSSI[NUM_RSSI];
>  };
>
> @@ -93,7 +93,7 @@ struct network_info {
>   u8 *ies;
>   u16 ies_len;
>   void *join_params;
> - struct tstrRSSI str_rssi;
> + struct tstr_RSSI str_rssi;
>   u64 tsf_hi;
>  };
>
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> index f7ce47c..30285b9 100644
> --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> @@ -205,8 +205,8 @@ static u32 get_rssi_avg(struct network_info *network_info)
>  {
>   u8 i;
>   int rssi_v = 0;
> - u8 num_rssi = (network_info->str_rssi.u8Full) ?
> -NUM_RSSI : (network_info->str_rssi.u8Index);
> + u8 num_rssi = (network_info->str_rssi.u8_full) ?
> +NUM_RSSI : (network_info->str_rssi.u8_index);
>
>   for (i = 0; i < num_rssi; i++)
>   rssi_v += network_info->str_rssi.as8RSSI[i];
> @@ -346,13 +346,13 @@ static void add_network_to_shadow(struct network_info 
> *pstrNetworkInfo,
>   } else {
>   ap_index = ap_found;
>   }
> - rssi_index = last_scanned_shadow[ap_index].str_rssi.u8Index;
> + rssi_index = last_scanned_shadow[ap_index].str_rssi.u8_index;
>   last_scanned_shadow[ap_index].str_rssi.as8RSSI[rssi_index++] = 
> pstrNetworkInfo->rssi;
>   if (rssi_index == NUM_RSSI) {
>   rssi_index = 0;
> - last_scanned_shadow[ap_index].str_rssi.u8Full = 1;
> + last_scanned_shadow[ap_index].str_rssi.u8_full = 1;
>   }
> - last_scanned_shadow[ap_index].str_rssi.u8Index = rssi_index;
> + last_scanned_shadow[ap_index].str_rssi.u8_index = rssi_index;
>   last_scanned_shadow[ap_index].rssi = pstrNetworkInfo->rssi;
>   last_scanned_shadow[ap_index].cap_info = pstrNetworkInfo->cap_info;
>   last_scanned_shadow[ap_index].ssid_len = pstrNetworkInfo->ssid_len;
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to outreachy-ker...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/outreachy-kernel/20170222045543.GA27847%40coolbox.
> For more options, visit https://groups.google.com/d/optout.
>


[PATCH] rtlwifi: btcoexist: fix semicolon.cocci warnings

2017-02-09 Thread Julia Lawall
Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

CC: Larry Finger <larry.fin...@lwfinger.net>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
---

 halbtc8821a2ant.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c
+++ b/drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c
@@ -2877,7 +2877,7 @@ static void halbtc8821a2ant_action_pan_e
  false, false);
btc8821a2ant_sw_mech2(btcoexist, false, false,
  false, 0x18);
-   };
+   }
} else {
/* fw mechanism */
if ((bt_rssi_state == BTC_RSSI_STATE_HIGH) ||


[PATCH] mt76: fix debugfs_simple_attr.cocci warnings

2017-02-02 Thread Julia Lawall
Use DEFINE_DEBUGFS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTRIBUTE
for debugfs files.

Rationale: DEFINE_SIMPLE_ATTRIBUTE + debugfs_create_file()
imposes some significant overhead as compared to
DEFINE_DEBUGFS_ATTRIBUTE + debugfs_create_file_unsafe().

Generated by: scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci

CC: Felix Fietkau <n...@nbd.name>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang...@intel.com>
---

I'm just passing this along.  I don't personally know anything about this
issue.

 debugfs.c |7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

--- a/drivers/net/wireless/mediatek/mt76/debugfs.c
+++ b/drivers/net/wireless/mediatek/mt76/debugfs.c
@@ -33,7 +33,8 @@ mt76_reg_get(void *data, u64 *val)
return 0;
 }

-DEFINE_SIMPLE_ATTRIBUTE(fops_regval, mt76_reg_get, mt76_reg_set, "0x%08llx\n");
+DEFINE_DEBUGFS_ATTRIBUTE(fops_regval, mt76_reg_get, mt76_reg_set,
+"0x%08llx\n");

 static int
 mt76_queues_read(struct seq_file *s, void *data)
@@ -64,8 +65,8 @@ struct dentry *mt76_register_debugfs(str
return NULL;

debugfs_create_u32("regidx", S_IRUSR | S_IWUSR, dir, >debugfs_reg);
-   debugfs_create_file("regval", S_IRUSR | S_IWUSR, dir, dev,
-   _regval);
+   debugfs_create_file_unsafe("regval", S_IRUSR | S_IWUSR, dir, dev,
+  _regval);
debugfs_create_blob("eeprom", S_IRUSR, dir, >eeprom);
if (dev->otp.data)
debugfs_create_blob("otp", S_IRUSR, dir, >otp);


Re: [PATCH 05/11 V2] rtlwifi: btcoexist: Change logging in halbtc8192e2ant.c (fwd)

2017-02-01 Thread Julia Lawall
Indeed, there are the four cases where the then and else branches are the
same.  Is it generated code?

julia

-- Forwarded message --
Date: Thu, 2 Feb 2017 06:10:01 +0800
From: kbuild test robot <fengguang...@intel.com>
To: kbu...@01.org
Cc: Julia Lawall <julia.law...@lip6.fr>
Subject: Re: [PATCH 05/11 V2] rtlwifi: btcoexist: Change logging in
halbtc8192e2ant.c

In-Reply-To: <20170120212716.29887-6-larry.fin...@lwfinger.net>

Hi Larry,

[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on v4.10-rc6 next-20170201]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Larry-Finger/rtlwifi-Various-updates/20170202-045716
base:   
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git 
master
:: branch date: 72 minutes ago
:: commit date: 73 minutes ago

>> drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c:2186:11-13: 
>> WARNING: possible condition with no effect (if == else)
   drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c:2208:11-13: 
WARNING: possible condition with no effect (if == else)
   drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c:2232:11-13: 
WARNING: possible condition with no effect (if == else)
   drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c:2254:11-13: 
WARNING: possible condition with no effect (if == else)

git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 2e5b0b84cf4c19a9b761ecbfbcbec52ac35f39da
vim +2186 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c

2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2170 if (!coex_dm->auto_tdma_adjust) {
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2171 coex_dm->auto_tdma_adjust = true;
2e5b0b84 drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2017-02-01  2172 RT_TRACE(rtlpriv, COMP_BT_COEXIST, 
DBG_LOUD,
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2173  "[BTCoex], first run 
TdmaDurationAdjust()!!\n");
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2174 if (sco_hid) {
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2175 if (tx_pause) {
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2176 if (max_interval == 1) {
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2177 
halbtc8192e2ant_ps_tdma(btcoexist,
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2178 
NORMAL_EXEC,
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2179 
true, 13);
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2180 
coex_dm->tdma_adj_type = 13;
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2181 } else if (max_interval 
== 2) {
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2182 
halbtc8192e2ant_ps_tdma(btcoexist,
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2183 
NORMAL_EXEC,
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2184 
true, 14);
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2185 
coex_dm->tdma_adj_type = 14;
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04 @2186 } else if (max_interval 
== 3) {
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2187 
halbtc8192e2ant_ps_tdma(btcoexist,
2187e9a2 drivers/net/wireless/rtlwifi/btcoexist/halbtc8192e2ant.c Larry 
Finger 2014-09-04  2188 
  

Re: [PATCH 2/4] ath10k: Add support to update btcoex priority value via nl80211

2016-11-09 Thread Julia Lawall
It seems possible that one might like to release the mutex lock before the
return on line 7556.

julia



On Wed, 9 Nov 2016, kbuild test robot wrote:

> Hi Tamizh,
>
> [auto build test WARNING on ath6kl/ath-next]
> [cannot apply to v4.9-rc4 next-20161108]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
>
> url:
> https://github.com/0day-ci/linux/commits/c_traja-qti-qualcomm-com/ath10k-Add-support-for-BTCOEX-feature/20161109-043718
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git ath-next
> :: branch date: 2 hours ago
> :: commit date: 2 hours ago
>
> >> drivers/net/wireless/ath/ath10k/mac.c:7556:2-8: preceding lock on line 7545
>
> git remote add linux-review https://github.com/0day-ci/linux
> git remote update linux-review
> git checkout 2fc922b27f111b9e8089a3e94a17ee827e769c55
> vim +7556 drivers/net/wireless/ath/ath10k/mac.c
>
> 2fc922b2 Tamizh chelvam 2016-11-08  7539
> 2fc922b2 Tamizh chelvam 2016-11-08  7540  if 
> (!(test_bit(ATH10K_FLAG_BTCOEX, >dev_flags))) {
> 2fc922b2 Tamizh chelvam 2016-11-08  7541  ret = -EINVAL;
> 2fc922b2 Tamizh chelvam 2016-11-08  7542  goto exit;
> 2fc922b2 Tamizh chelvam 2016-11-08  7543  }
> 2fc922b2 Tamizh chelvam 2016-11-08  7544
> 2fc922b2 Tamizh chelvam 2016-11-08 @7545  mutex_lock(>conf_mutex);
> 2fc922b2 Tamizh chelvam 2016-11-08  7546
> 2fc922b2 Tamizh chelvam 2016-11-08  7547  if (ar->state != 
> ATH10K_STATE_ON &&
> 2fc922b2 Tamizh chelvam 2016-11-08  7548  ar->state != 
> ATH10K_STATE_RESTARTED) {
> 2fc922b2 Tamizh chelvam 2016-11-08  7549  ret = -ENETDOWN;
> 2fc922b2 Tamizh chelvam 2016-11-08  7550  goto exit;
> 2fc922b2 Tamizh chelvam 2016-11-08  7551  }
> 2fc922b2 Tamizh chelvam 2016-11-08  7552
> 2fc922b2 Tamizh chelvam 2016-11-08  7553  btcoex_prio = 
> ath10k_mac_get_btcoex_prio(btcoex_priority);
> 2fc922b2 Tamizh chelvam 2016-11-08  7554
> 2fc922b2 Tamizh chelvam 2016-11-08  7555  if (btcoex_prio > 0x3f)
> 2fc922b2 Tamizh chelvam 2016-11-08 @7556  return -E2BIG;
> 2fc922b2 Tamizh chelvam 2016-11-08  7557
> 2fc922b2 Tamizh chelvam 2016-11-08  7558  ret = 
> ath10k_wmi_set_coex_param(ar, btcoex_prio);
> 2fc922b2 Tamizh chelvam 2016-11-08  7559
>
> ---
> 0-DAY kernel test infrastructureOpen Source Technology Center
> https://lists.01.org/pipermail/kbuild-all   Intel Corporation
>


Re: [PATCH] Revert "rtlwifi: rtl818x: constify local structures"

2016-10-10 Thread Julia Lawall


On Mon, 10 Oct 2016, Larry Finger wrote:

> On 10/10/2016 11:56 AM, Johannes Berg wrote:
> > On Mon, 2016-10-10 at 10:25 -0500, Larry Finger wrote:
> > > This reverts commit d86e64768859fca82c78e52877ceeba04e25d27a.
> > >
> > > For drivers rtl8188ee, rtl8192ce, rtl8192ee, rtl8723ae, and
> > > rtl8821ae,
> > > the Coccinelle script missed the fact that the code changes the
> > > firmware
> > > name. When that happens, the kernel issues a BUG splat because
> > > it is unable to overwrite the old name.
> >
> > Hmm. That seems somewhat problematic, for example if you have multiple
> > devices that use the same driver but need different firmware?
> >
> > Not that I really know what's going on, but changing static variables
> > based on runtime seems like it could cause issues in such cases.
>
> I think the situation is OK, but I have created a patch that converts all the
> firmware names into local strings in the routines that initiate firmware
> loading. That way the affected structs can be constified without problem.

Great, thanks :)

julia

>
> @Kalle: Please drop the patch with this subject.
>
> Thanks,
>
> Larry
>


Re: [PATCH 00/26] constify local structures

2016-09-12 Thread Julia Lawall


On Mon, 12 Sep 2016, Jarkko Sakkinen wrote:

> On Mon, Sep 12, 2016 at 04:43:58PM +0300, Felipe Balbi wrote:
> >
> > Hi,
> >
> > Jarkko Sakkinen <jarkko.sakki...@linux.intel.com> writes:
> > > On Mon, Sep 12, 2016 at 10:54:07AM +0200, Julia Lawall wrote:
> > >>
> > >>
> > >> On Sun, 11 Sep 2016, Jarkko Sakkinen wrote:
> > >>
> > >> > On Sun, Sep 11, 2016 at 03:05:42PM +0200, Julia Lawall wrote:
> > >> > > Constify local structures.
> > >> > >
> > >> > > The semantic patch that makes this change is as follows:
> > >> > > (http://coccinelle.lip6.fr/)
> > >> >
> > >> > Just my two cents but:
> > >> >
> > >> > 1. You *can* use a static analysis too to find bugs or other issues.
> > >> > 2. However, you should manually do the commits and proper commit
> > >> >messages to subsystems based on your findings. And I generally think
> > >> >that if one contributes code one should also at least smoke test 
> > >> > changes
> > >> >somehow.
> > >> >
> > >> > I don't know if I'm alone with my opinion. I just think that one should
> > >> > also do the analysis part and not blindly create and submit patches.
> > >>
> > >> All of the patches are compile tested.  And the individual patches are
> > >
> > > Compile-testing is not testing. If you are not able to test a commit,
> > > you should explain why.
> >
> > Dude, Julia has been doing semantic patching for years already and
> > nobody has raised any concerns so far. There's already an expectation
> > that Coccinelle *works* and Julia's sematic patches are sound.
> >
> > Besides, adding 'const' is something that causes virtually no functional
> > changes to the point that build-testing is really all you need. Any
> > problems caused by adding 'const' to a definition will be seen by build
> > errors or warnings.
> >
> > Really, just stop with the pointless discussion and go read a bit about
> > Coccinelle and what semantic patches are giving you. The work done by
> > Julia and her peers are INRIA have measurable benefits.
> >
> > You're really making a thunderstorm in a glass of water.
>
> Hmm... I've been using coccinelle in cyclic basis for some time now.
> My comment was oversized but I didn't mean it to be impolite or attack
> of any kind for that matter.

No problem :)  Thanks for the feedback.

julia


Re: [PATCH 00/26] constify local structures

2016-09-12 Thread Julia Lawall


On Mon, 12 Sep 2016, Felipe Balbi wrote:

>
> Hi,
>
> Jarkko Sakkinen <jarkko.sakki...@linux.intel.com> writes:
> > On Mon, Sep 12, 2016 at 10:54:07AM +0200, Julia Lawall wrote:
> >>
> >>
> >> On Sun, 11 Sep 2016, Jarkko Sakkinen wrote:
> >>
> >> > On Sun, Sep 11, 2016 at 03:05:42PM +0200, Julia Lawall wrote:
> >> > > Constify local structures.
> >> > >
> >> > > The semantic patch that makes this change is as follows:
> >> > > (http://coccinelle.lip6.fr/)
> >> >
> >> > Just my two cents but:
> >> >
> >> > 1. You *can* use a static analysis too to find bugs or other issues.
> >> > 2. However, you should manually do the commits and proper commit
> >> >messages to subsystems based on your findings. And I generally think
> >> >that if one contributes code one should also at least smoke test 
> >> > changes
> >> >somehow.
> >> >
> >> > I don't know if I'm alone with my opinion. I just think that one should
> >> > also do the analysis part and not blindly create and submit patches.
> >>
> >> All of the patches are compile tested.  And the individual patches are
> >
> > Compile-testing is not testing. If you are not able to test a commit,
> > you should explain why.
>
> Dude, Julia has been doing semantic patching for years already and
> nobody has raised any concerns so far. There's already an expectation
> that Coccinelle *works* and Julia's sematic patches are sound.
>
> Besides, adding 'const' is something that causes virtually no functional
> changes to the point that build-testing is really all you need. Any
> problems caused by adding 'const' to a definition will be seen by build
> errors or warnings.
>
> Really, just stop with the pointless discussion and go read a bit about
> Coccinelle and what semantic patches are giving you. The work done by
> Julia and her peers are INRIA have measurable benefits.
>
> You're really making a thunderstorm in a glass of water.

Thanks for the defense, but since a lot of these patches torned out to be
wrong, due to an incorrect parse by Coccinelle, combined with an
unpleasantly lax compiler, Jarkko does have a point that I should have
looked at the patches more carefully.  In any case, I have written to the
maintainers relevant to the patches that turned out to be incorrect.

julia


Re: [PATCH 00/26] constify local structures

2016-09-12 Thread Julia Lawall


On Mon, 12 Sep 2016, Jarkko Sakkinen wrote:

> On Mon, Sep 12, 2016 at 10:54:07AM +0200, Julia Lawall wrote:
> >
> >
> > On Sun, 11 Sep 2016, Jarkko Sakkinen wrote:
> >
> > > On Sun, Sep 11, 2016 at 03:05:42PM +0200, Julia Lawall wrote:
> > > > Constify local structures.
> > > >
> > > > The semantic patch that makes this change is as follows:
> > > > (http://coccinelle.lip6.fr/)
> > >
> > > Just my two cents but:
> > >
> > > 1. You *can* use a static analysis too to find bugs or other issues.
> > > 2. However, you should manually do the commits and proper commit
> > >messages to subsystems based on your findings. And I generally think
> > >that if one contributes code one should also at least smoke test 
> > > changes
> > >somehow.
> > >
> > > I don't know if I'm alone with my opinion. I just think that one should
> > > also do the analysis part and not blindly create and submit patches.
> >
> > All of the patches are compile tested.  And the individual patches are
>
> Compile-testing is not testing. If you are not able to test a commit,
> you should explain why.
>
> > submitted to the relevant maintainers.  The individual commit messages
> > give a more detailed explanation of the strategy used to decide that the
> > structure was constifiable.  It seemed redundant to put that in the cover
> > letter, which will not be committed anyway.
>
> I don't mean to be harsh but I do not care about your thought process
> *that much* when I review a commit (sometimes it might make sense to
> explain that but it depends on the context).
>
> I mostly only care why a particular change makes sense for this
> particular subsystem. The report given by a static analysis tool can
> be a starting point for making a commit but it's not sufficient.
> Based on the report you should look subsystems as individuals.

OK, thanks for the feedback.

julia


Re: [PATCH 00/26] constify local structures

2016-09-12 Thread Julia Lawall


On Sun, 11 Sep 2016, Jarkko Sakkinen wrote:

> On Sun, Sep 11, 2016 at 03:05:42PM +0200, Julia Lawall wrote:
> > Constify local structures.
> >
> > The semantic patch that makes this change is as follows:
> > (http://coccinelle.lip6.fr/)
>
> Just my two cents but:
>
> 1. You *can* use a static analysis too to find bugs or other issues.
> 2. However, you should manually do the commits and proper commit
>messages to subsystems based on your findings. And I generally think
>that if one contributes code one should also at least smoke test changes
>somehow.
>
> I don't know if I'm alone with my opinion. I just think that one should
> also do the analysis part and not blindly create and submit patches.

All of the patches are compile tested.  And the individual patches are
submitted to the relevant maintainers.  The individual commit messages
give a more detailed explanation of the strategy used to decide that the
structure was constifiable.  It seemed redundant to put that in the cover
letter, which will not be committed anyway.

julia

>
> Anyway, I'll apply the TPM change at some point. As I said they were
> for better. Thanks.
>
> /Jarkko
>
> > // 
> > // The first rule ignores some cases that posed problems
> > @r disable optional_qualifier@
> > identifier s != {peri_clk_data,threshold_attr,tracer_flags,tracer};
> > identifier i != {s5k5baf_cis_rect,smtcfb_fix};
> > position p;
> > @@
> > static struct s i@p = { ... };
> >
> > @lstruct@
> > identifier r.s;
> > @@
> > struct s { ... };
> >
> > @used depends on lstruct@
> > identifier r.i;
> > @@
> > i
> >
> > @bad1@
> > expression e;
> > identifier r.i;
> > assignment operator a;
> > @@
> >  (<+...i...+>) a e
> >
> > @bad2@
> > identifier r.i;
> > @@
> >  &(<+...i...+>)
> >
> > @bad3@
> > identifier r.i;
> > declarer d;
> > @@
> >  d(...,<+...i...+>,...);
> >
> > @bad4@
> > identifier r.i;
> > type T;
> > T[] e;
> > identifier f;
> > position p;
> > @@
> >
> > f@p(...,
> > (
> >   (<+...i...+>)
> > &
> >   e
> > )
> > ,...)
> >
> > @bad4a@
> > identifier r.i;
> > type T;
> > T *e;
> > identifier f;
> > position p;
> > @@
> >
> > f@p(...,
> > (
> >   (<+...i...+>)
> > &
> >   e
> > )
> > ,...)
> >
> > @ok5@
> > expression *e;
> > identifier r.i;
> > position p;
> > @@
> > e =@p i
> >
> > @bad5@
> > expression *e;
> > identifier r.i;
> > position p != ok5.p;
> > @@
> > e =@p (<+...i...+>)
> >
> > @rr depends on used && !bad1 && !bad2 && !bad3 && !bad4 && !bad4a && !bad5@
> > identifier s,r.i;
> > position r.p;
> > @@
> >
> > static
> > +const
> >  struct s i@p = { ... };
> >
> > @depends on used && !bad1 && !bad2 && !bad3 && !bad4 && !bad4a && !bad5
> >  disable optional_qualifier@
> > identifier rr.s,r.i;
> > @@
> >
> > static
> > +const
> >  struct s i;
> > // 
> >
> > ---
> >
> >  drivers/acpi/acpi_apd.c  |8 +++---
> >  drivers/char/tpm/tpm-interface.c |   10 
> >  drivers/char/tpm/tpm-sysfs.c |2 -
> >  drivers/cpufreq/intel_pstate.c   |8 +++---
> >  drivers/infiniband/hw/i40iw/i40iw_uk.c   |6 ++---
> >  drivers/media/i2c/tvp514x.c  |2 -
> >  drivers/media/pci/ddbridge/ddbridge-core.c   |   18 +++
> >  drivers/media/pci/ngene/ngene-cards.c|   14 ++--
> >  drivers/media/pci/smipcie/smipcie-main.c |8 +++---
> >  drivers/misc/sgi-xp/xpc_uv.c |2 -
> >  drivers/net/arcnet/com20020-pci.c|   10 
> >  drivers/net/can/c_can/c_can_pci.c|4 +--
> >  drivers/net/can/sja1000/plx_pci.c|   20 
> > -
> >  drivers/net/ethernet/mellanox/mlx4/main.c|4 +--
> >  drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c |2 -
> >  drivers/net/ethernet/renesas/sh_eth.c|   14 ++--
> >  drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c |2 -
> > 

Re: [PATCH 00/26] constify local structures

2016-09-11 Thread Julia Lawall

On Sun, 11 Sep 2016, Joe Perches wrote:

> On Sun, 2016-09-11 at 15:05 +0200, Julia Lawall wrote:
> > Constify local structures.
>
> Thanks Julia.
>
> A few suggestions & questions:
>
> Perhaps the script should go into scripts/coccinelle/
> so that future cases could be caught by the robot
> and commit message referenced by the patch instances.

OK.

> Can you please compile the files modified using the
> appropriate defconfig/allyesconfig and show the

I currently send patches for this issue only for files that compile using
the x86 allyesconfig.

> movement from data to const by using
>   $ size .new/old
> and include that in the changelogs (maybe next time)?

OK, thanks for the suggestion.

> Is it possible for a rule to trace the instances where
> an address of a struct or struct member is taken by
> locally defined and declared function call where the
> callee does not modify any dereferenced object?
>
> ie:
>
> struct foo {
>   int bar;
>   char *baz;
> };
>
> struct foo qux[] = {
>   { 1, "description 1" },
>   { 2, "dewcription 2" },
>   [ n, "etc" ]...,
> };
>
> void message(struct foo *msg)
> {
>   printk("%d %s\n", msg->bar, msg->baz);
> }
>
> where some code uses
>
>   message(qux[index]);
>
> So could a coccinelle script change:
>
> struct foo qux[] = { to const struct foo quz[] = {
>
> and
>
> void message(struct foo *msg) to void message(const struct foo *msg)

Yes, this could be possible too.

Thanks for the feedback.

julia


[PATCH 06/26] ath: constify local structures

2016-09-11 Thread Julia Lawall
For structure types defined in the same file or local header files, find
top-level static structure declarations that have the following
properties:
1. Never reassigned.
2. Address never taken
3. Not passed to a top-level macro call
4. No pointer or array-typed field passed to a function or stored in a
variable.
Declare structures having all of these properties as const.

Done using Coccinelle.
Based on a suggestion by Joe Perches <j...@perches.com>.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
The semantic patch seems too long for a commit log, but is in the cover
letter.

 drivers/net/wireless/ath/dfs_pattern_detector.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/dfs_pattern_detector.c 
b/drivers/net/wireless/ath/dfs_pattern_detector.c
index 2f8136d..4100ffd 100644
--- a/drivers/net/wireless/ath/dfs_pattern_detector.c
+++ b/drivers/net/wireless/ath/dfs_pattern_detector.c
@@ -338,7 +338,7 @@ static bool dpd_set_domain(struct dfs_pattern_detector *dpd,
return true;
 }
 
-static struct dfs_pattern_detector default_dpd = {
+static const struct dfs_pattern_detector default_dpd = {
.exit   = dpd_exit,
.set_dfs_domain = dpd_set_domain,
.add_pulse  = dpd_add_pulse,



[PATCH 08/26] iwlegacy: constify local structures

2016-09-11 Thread Julia Lawall
For structure types defined in the same file or local header files, find
top-level static structure declarations that have the following
properties:
1. Never reassigned.
2. Address never taken
3. Not passed to a top-level macro call
4. No pointer or array-typed field passed to a function or stored in a
variable.
Declare structures having all of these properties as const.

Done using Coccinelle.
Based on a suggestion by Joe Perches <j...@perches.com>.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
The semantic patch seems too long for a commit log, but is in the cover
letter.

 drivers/net/wireless/intel/iwlegacy/3945.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/3945.c 
b/drivers/net/wireless/intel/iwlegacy/3945.c
index 209dc99..4db327a 100644
--- a/drivers/net/wireless/intel/iwlegacy/3945.c
+++ b/drivers/net/wireless/intel/iwlegacy/3945.c
@@ -2671,7 +2671,7 @@ const struct il_ops il3945_ops = {
.send_led_cmd = il3945_send_led_cmd,
 };
 
-static struct il_cfg il3945_bg_cfg = {
+static const struct il_cfg il3945_bg_cfg = {
.name = "3945BG",
.fw_name_pre = IL3945_FW_PRE,
.ucode_api_max = IL3945_UCODE_API_MAX,
@@ -2700,7 +2700,7 @@ static struct il_cfg il3945_bg_cfg = {
},
 };
 
-static struct il_cfg il3945_abg_cfg = {
+static const struct il_cfg il3945_abg_cfg = {
.name = "3945ABG",
.fw_name_pre = IL3945_FW_PRE,
.ucode_api_max = IL3945_UCODE_API_MAX,



[PATCH 00/26] constify local structures

2016-09-11 Thread Julia Lawall
Constify local structures.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// 
// The first rule ignores some cases that posed problems
@r disable optional_qualifier@
identifier s != {peri_clk_data,threshold_attr,tracer_flags,tracer};
identifier i != {s5k5baf_cis_rect,smtcfb_fix};
position p;
@@
static struct s i@p = { ... };

@lstruct@
identifier r.s;
@@
struct s { ... };

@used depends on lstruct@
identifier r.i;
@@
i

@bad1@
expression e;
identifier r.i;
assignment operator a;
@@
 (<+...i...+>) a e

@bad2@
identifier r.i;
@@
 &(<+...i...+>)

@bad3@
identifier r.i;
declarer d;
@@
 d(...,<+...i...+>,...);

@bad4@
identifier r.i;
type T;
T[] e;
identifier f;
position p;
@@

f@p(...,
(
  (<+...i...+>)
&
  e
)
,...)

@bad4a@
identifier r.i;
type T;
T *e;
identifier f;
position p;
@@

f@p(...,
(
  (<+...i...+>)
&
  e
)
,...)

@ok5@
expression *e;
identifier r.i;
position p;
@@
e =@p i

@bad5@
expression *e;
identifier r.i;
position p != ok5.p;
@@
e =@p (<+...i...+>)

@rr depends on used && !bad1 && !bad2 && !bad3 && !bad4 && !bad4a && !bad5@
identifier s,r.i;
position r.p;
@@

static
+const
 struct s i@p = { ... };

@depends on used && !bad1 && !bad2 && !bad3 && !bad4 && !bad4a && !bad5
 disable optional_qualifier@
identifier rr.s,r.i;
@@

static
+const
 struct s i;
// 

---

 drivers/acpi/acpi_apd.c  |8 +++---
 drivers/char/tpm/tpm-interface.c |   10 
 drivers/char/tpm/tpm-sysfs.c |2 -
 drivers/cpufreq/intel_pstate.c   |8 +++---
 drivers/infiniband/hw/i40iw/i40iw_uk.c   |6 ++---
 drivers/media/i2c/tvp514x.c  |2 -
 drivers/media/pci/ddbridge/ddbridge-core.c   |   18 +++
 drivers/media/pci/ngene/ngene-cards.c|   14 ++--
 drivers/media/pci/smipcie/smipcie-main.c |8 +++---
 drivers/misc/sgi-xp/xpc_uv.c |2 -
 drivers/net/arcnet/com20020-pci.c|   10 
 drivers/net/can/c_can/c_can_pci.c|4 +--
 drivers/net/can/sja1000/plx_pci.c|   20 -
 drivers/net/ethernet/mellanox/mlx4/main.c|4 +--
 drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c |2 -
 drivers/net/ethernet/renesas/sh_eth.c|   14 ++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c |2 -
 drivers/net/wireless/ath/dfs_pattern_detector.c  |2 -
 drivers/net/wireless/intel/iwlegacy/3945.c   |4 +--
 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c  |2 -
 drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c  |2 -
 drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c  |2 -
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c  |2 -
 drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c  |2 -
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c  |2 -
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c  |2 -
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c  |2 -
 drivers/platform/chrome/chromeos_laptop.c|   22 +--
 drivers/platform/x86/intel_scu_ipc.c |6 ++---
 drivers/platform/x86/intel_telemetry_debugfs.c   |2 -
 drivers/scsi/esas2r/esas2r_flash.c   |2 -
 drivers/scsi/hptiop.c|6 ++---
 drivers/spi/spi-dw-pci.c |4 +--
 drivers/staging/rtl8192e/rtl8192e/rtl_core.c |2 -
 drivers/usb/misc/ezusb.c |2 -
 drivers/video/fbdev/matrox/matroxfb_g450.c   |2 -
 lib/crc64_ecma.c |2 -
 sound/pci/ctxfi/ctatc.c  |2 -
 sound/pci/hda/patch_ca0132.c |   10 
 sound/pci/riptide/riptide.c  |2 -
 40 files changed, 110 insertions(+), 110 deletions(-)


[PATCH 21/26] rtlwifi: rtl818x: constify local structures

2016-09-11 Thread Julia Lawall
For structure types defined in the same file or local header files, find
top-level static structure declarations that have the following
properties:
1. Never reassigned.
2. Address never taken
3. Not passed to a top-level macro call
4. No pointer or array-typed field passed to a function or stored in a
variable.
Declare structures having all of these properties as const.

Done using Coccinelle.
Based on a suggestion by Joe Perches <j...@perches.com>.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
The semantic patch seems too long for a commit log, but is in the cover
letter.

 drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c |2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c |2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c |2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c |2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c |2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c |2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c |2 +-
 drivers/net/wireless/realtek/rtlwifi/rtl8821ae/sw.c |2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
index 47e32cb..e7b11b4 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/sw.c
@@ -280,7 +280,7 @@ static struct rtl_mod_params rtl88ee_mod_params = {
.debug = DBG_EMERG,
 };
 
-static struct rtl_hal_cfg rtl88ee_hal_cfg = {
+static const struct rtl_hal_cfg rtl88ee_hal_cfg = {
.bar_id = 2,
.write_readback = true,
.name = "rtl88e_pci",
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
index 4780bdc..87aa209 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ce/sw.c
@@ -258,7 +258,7 @@ static struct rtl_mod_params rtl92ce_mod_params = {
.debug = DBG_EMERG,
 };
 
-static struct rtl_hal_cfg rtl92ce_hal_cfg = {
+static const struct rtl_hal_cfg rtl92ce_hal_cfg = {
.bar_id = 2,
.write_readback = true,
.name = "rtl92c_pci",
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
index c6e09a1..0538a4d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192de/sw.c
@@ -262,7 +262,7 @@ static struct rtl_mod_params rtl92de_mod_params = {
.debug = DBG_EMERG,
 };
 
-static struct rtl_hal_cfg rtl92de_hal_cfg = {
+static const struct rtl_hal_cfg rtl92de_hal_cfg = {
.bar_id = 2,
.write_readback = true,
.name = "rtl8192de",
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
index c31c6bf..ac299cb 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/sw.c
@@ -262,7 +262,7 @@ static struct rtl_mod_params rtl92ee_mod_params = {
.debug = DBG_EMERG,
 };
 
-static struct rtl_hal_cfg rtl92ee_hal_cfg = {
+static const struct rtl_hal_cfg rtl92ee_hal_cfg = {
.bar_id = 2,
.write_readback = true,
.name = "rtl92ee_pci",
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
index 31baca41..5e8e02d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192se/sw.c
@@ -306,7 +306,7 @@ static struct rtl_mod_params rtl92se_mod_params = {
 
 /* Because memory R/W bursting will cause system hang/crash
  * for 92se, so we don't read back after every write action */
-static struct rtl_hal_cfg rtl92se_hal_cfg = {
+static const struct rtl_hal_cfg rtl92se_hal_cfg = {
.bar_id = 1,
.write_readback = false,
.name = "rtl92s_pci",
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
index ff49a8c..89c828a 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723ae/sw.c
@@ -276,7 +276,7 @@ static struct rtl_mod_params rtl8723e_mod_params = {
.disable_watchdog = false,
 };
 
-static struct rtl_hal_cfg rtl8723e_hal_cfg = {
+static const struct rtl_hal_cfg rtl8723e_hal_cfg = {
.bar_id = 2,
.write_readback = true,
.name = "rtl8723e_pci",
diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c 
b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
index 2101793..20b53f0 100644
--- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
+++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/sw.c
@@ -276,7 +276,7 @@ static struct rtl_mod_params rtl8723be_mod_params = {

Re: checkpatch: See if modified files are marked obsolete in MAINTAINERS

2016-08-23 Thread Julia Lawall


On Tue, 23 Aug 2016, SF Markus Elfring wrote:

> > Use get_maintainer to check the status of individual files.
> > If "obsolete", suggest leaving the files alone.
>
> Will another software system like the "kbuild test robot"
> need any more fine-tuning for this change?

It only works on files in which there have been commits, thus by
definition not obsolete.

julia


>
> Regards,
> Markus
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


[PATCH] NFC: nfcmrvl: constify nfcmrvl_if_ops structures

2016-08-09 Thread Julia Lawall
The nfcmrvl_if_ops structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/nfc/nfcmrvl/i2c.c |2 +-
 drivers/nfc/nfcmrvl/main.c|2 +-
 drivers/nfc/nfcmrvl/nfcmrvl.h |4 ++--
 drivers/nfc/nfcmrvl/spi.c |2 +-
 drivers/nfc/nfcmrvl/uart.c|2 +-
 drivers/nfc/nfcmrvl/usb.c |2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/nfc/nfcmrvl/i2c.c b/drivers/nfc/nfcmrvl/i2c.c
index 78b7aa8..91d1e67 100644
--- a/drivers/nfc/nfcmrvl/i2c.c
+++ b/drivers/nfc/nfcmrvl/i2c.c
@@ -162,7 +162,7 @@ static void nfcmrvl_i2c_nci_update_config(struct 
nfcmrvl_private *priv,
 {
 }
 
-static struct nfcmrvl_if_ops i2c_ops = {
+static const struct nfcmrvl_if_ops i2c_ops = {
.nci_open = nfcmrvl_i2c_nci_open,
.nci_close = nfcmrvl_i2c_nci_close,
.nci_send = nfcmrvl_i2c_nci_send,
diff --git a/drivers/nfc/nfcmrvl/main.c b/drivers/nfc/nfcmrvl/main.c
index 51c8240..8e3f26a 100644
--- a/drivers/nfc/nfcmrvl/main.c
+++ b/drivers/nfc/nfcmrvl/main.c
@@ -102,7 +102,7 @@ static struct nci_ops nfcmrvl_nci_ops = {
 
 struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
void *drv_data,
-   struct nfcmrvl_if_ops *ops,
+   const struct nfcmrvl_if_ops *ops,
struct device *dev,
struct nfcmrvl_platform_data *pdata)
 {
diff --git a/drivers/nfc/nfcmrvl/nfcmrvl.h b/drivers/nfc/nfcmrvl/nfcmrvl.h
index de68ff4..d9c2af3 100644
--- a/drivers/nfc/nfcmrvl/nfcmrvl.h
+++ b/drivers/nfc/nfcmrvl/nfcmrvl.h
@@ -88,7 +88,7 @@ struct nfcmrvl_private {
/* PHY type */
enum nfcmrvl_phy phy;
/* Low level driver ops */
-   struct nfcmrvl_if_ops *if_ops;
+   const struct nfcmrvl_if_ops *if_ops;
 };
 
 struct nfcmrvl_if_ops {
@@ -103,7 +103,7 @@ void nfcmrvl_nci_unregister_dev(struct nfcmrvl_private 
*priv);
 int nfcmrvl_nci_recv_frame(struct nfcmrvl_private *priv, struct sk_buff *skb);
 struct nfcmrvl_private *nfcmrvl_nci_register_dev(enum nfcmrvl_phy phy,
void *drv_data,
-   struct nfcmrvl_if_ops *ops,
+   const struct nfcmrvl_if_ops *ops,
struct device *dev,
struct nfcmrvl_platform_data *pdata);
 
diff --git a/drivers/nfc/nfcmrvl/spi.c b/drivers/nfc/nfcmrvl/spi.c
index a7faa0b..f974b45 100644
--- a/drivers/nfc/nfcmrvl/spi.c
+++ b/drivers/nfc/nfcmrvl/spi.c
@@ -112,7 +112,7 @@ static void nfcmrvl_spi_nci_update_config(struct 
nfcmrvl_private *priv,
drv_data->nci_spi->xfer_speed_hz = config->clk;
 }
 
-static struct nfcmrvl_if_ops spi_ops = {
+static const struct nfcmrvl_if_ops spi_ops = {
.nci_open = nfcmrvl_spi_nci_open,
.nci_close = nfcmrvl_spi_nci_close,
.nci_send = nfcmrvl_spi_nci_send,
diff --git a/drivers/nfc/nfcmrvl/uart.c b/drivers/nfc/nfcmrvl/uart.c
index 83a99e3..ad7540e 100644
--- a/drivers/nfc/nfcmrvl/uart.c
+++ b/drivers/nfc/nfcmrvl/uart.c
@@ -60,7 +60,7 @@ static void nfcmrvl_uart_nci_update_config(struct 
nfcmrvl_private *priv,
config->flow_control);
 }
 
-static struct nfcmrvl_if_ops uart_ops = {
+static const struct nfcmrvl_if_ops uart_ops = {
.nci_open = nfcmrvl_uart_nci_open,
.nci_close = nfcmrvl_uart_nci_close,
.nci_send = nfcmrvl_uart_nci_send,
diff --git a/drivers/nfc/nfcmrvl/usb.c b/drivers/nfc/nfcmrvl/usb.c
index 585a0f2..ac3796d 100644
--- a/drivers/nfc/nfcmrvl/usb.c
+++ b/drivers/nfc/nfcmrvl/usb.c
@@ -273,7 +273,7 @@ done:
return err;
 }
 
-static struct nfcmrvl_if_ops usb_ops = {
+static const struct nfcmrvl_if_ops usb_ops = {
.nci_open = nfcmrvl_usb_nci_open,
.nci_close = nfcmrvl_usb_nci_close,
.nci_send = nfcmrvl_usb_nci_send,

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] NFC: pn533: constify pn533_phy_ops structures

2016-08-09 Thread Julia Lawall
The pn533_phy_ops are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/nfc/pn533/i2c.c   |2 +-
 drivers/nfc/pn533/pn533.c |2 +-
 drivers/nfc/pn533/pn533.h |4 ++--
 drivers/nfc/pn533/usb.c   |2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/nfc/pn533/i2c.c b/drivers/nfc/pn533/i2c.c
index 1dc8924..8a7c17e 100644
--- a/drivers/nfc/pn533/i2c.c
+++ b/drivers/nfc/pn533/i2c.c
@@ -176,7 +176,7 @@ static irqreturn_t pn533_i2c_irq_thread_fn(int irq, void 
*data)
return IRQ_HANDLED;
 }
 
-static struct pn533_phy_ops i2c_phy_ops = {
+static const struct pn533_phy_ops i2c_phy_ops = {
.send_frame = pn533_i2c_send_frame,
.send_ack = pn533_i2c_send_ack,
.abort_cmd = pn533_i2c_abort_cmd,
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index d9c5583..2f817b3 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -2560,7 +2560,7 @@ struct pn533 *pn533_register_device(u32 device_type,
u32 protocols,
enum pn533_protocol_type protocol_type,
void *phy,
-   struct pn533_phy_ops *phy_ops,
+   const struct pn533_phy_ops *phy_ops,
struct pn533_frame_ops *fops,
struct device *dev,
struct device *parent)
diff --git a/drivers/nfc/pn533/pn533.h b/drivers/nfc/pn533/pn533.h
index 553c7d1..e26d634 100644
--- a/drivers/nfc/pn533/pn533.h
+++ b/drivers/nfc/pn533/pn533.h
@@ -179,7 +179,7 @@ struct pn533 {
 
struct device *dev;
void *phy;
-   struct pn533_phy_ops *phy_ops;
+   const struct pn533_phy_ops *phy_ops;
 };
 
 typedef int (*pn533_send_async_complete_t) (struct pn533 *dev, void *arg,
@@ -226,7 +226,7 @@ struct pn533 *pn533_register_device(u32 device_type,
u32 protocols,
enum pn533_protocol_type protocol_type,
void *phy,
-   struct pn533_phy_ops *phy_ops,
+   const struct pn533_phy_ops *phy_ops,
struct pn533_frame_ops *fops,
struct device *dev,
struct device *parent);
diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index 33ed78b..bcf3f54 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -434,7 +434,7 @@ static void pn533_send_complete(struct urb *urb)
}
 }
 
-static struct pn533_phy_ops usb_phy_ops = {
+static const struct pn533_phy_ops usb_phy_ops = {
.send_frame = pn533_usb_send_frame,
.send_ack = pn533_usb_send_ack,
.abort_cmd = pn533_usb_abort_cmd,

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/7] fix typo

2016-05-17 Thread Julia Lawall


On Tue, 17 May 2016, Kalle Valo wrote:

> Julia Lawall <julia.law...@lip6.fr> writes:
>
> > firmare -> firmware
> >
> > ---
> >
> >  drivers/media/dvb-frontends/mn88473.c   |2 +-
> >  drivers/net/wireless/ath/ath6kl/core.h  |2 +-
> >  drivers/net/wireless/marvell/mwifiex/pcie.c |2 +-
>
> It would be good to know in advance what tree you are planning to submit
> these for. For example, should I take ath6kl and mwifiex patches or
> someone else?

I have no preference.  They are all independent in any case.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] ath6kl: fix typo

2016-05-17 Thread Julia Lawall
firmare -> firmware

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/net/wireless/ath/ath6kl/core.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.h 
b/drivers/net/wireless/ath/ath6kl/core.h
index 713a571..ebc40f6 100644
--- a/drivers/net/wireless/ath/ath6kl/core.h
+++ b/drivers/net/wireless/ath/ath6kl/core.h
@@ -148,7 +148,7 @@ enum ath6kl_fw_capability {
/* ratetable is the 2 stream version (max MCS15) */
ATH6KL_FW_CAPABILITY_RATETABLE_MCS15,
 
-   /* firmare doesn't support IP checksumming */
+   /* firmware doesn't support IP checksumming */
ATH6KL_FW_CAPABILITY_NO_IP_CHECKSUM,
 
/* this needs to be last */

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/7] fix typo

2016-05-17 Thread Julia Lawall
firmare -> firmware

---

 drivers/media/dvb-frontends/mn88473.c   |2 +-
 drivers/net/wireless/ath/ath6kl/core.h  |2 +-
 drivers/net/wireless/marvell/mwifiex/pcie.c |2 +-
 drivers/scsi/pm8001/pm8001_init.c   |2 +-
 drivers/scsi/snic/snic_fwint.h  |2 +-
 drivers/staging/media/mn88472/mn88472.c |2 +-
 drivers/staging/wilc1000/linux_wlan.c   |2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/7] staging: wilc1000: fix typo

2016-05-17 Thread Julia Lawall
firmare -> firmware

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/staging/wilc1000/linux_wlan.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wilc1000/linux_wlan.c 
b/drivers/staging/wilc1000/linux_wlan.c
index 4f93c11..274c390 100644
--- a/drivers/staging/wilc1000/linux_wlan.c
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -362,7 +362,7 @@ int wilc_wlan_get_firmware(struct net_device *dev)
goto _fail_;
 
if (request_firmware(_firmware, firmware, wilc->dev) != 0) {
-   netdev_err(dev, "%s - firmare not available\n", firmware);
+   netdev_err(dev, "%s - firmware not available\n", firmware);
ret = -1;
goto _fail_;
}

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] mwifiex: fix typo

2016-05-17 Thread Julia Lawall
firmare -> firmware

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/net/wireless/marvell/mwifiex/pcie.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c 
b/drivers/net/wireless/marvell/mwifiex/pcie.c
index 0c7937e..9246ce8 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -2804,7 +2804,7 @@ static int mwifiex_pcie_request_irq(struct 
mwifiex_adapter *adapter)
 }
 
 /*
- * This function get firmare name for downloading by revision id
+ * This function gets the firmware name for downloading by revision id
  *
  * Read revision id register to get revision id
  */

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] rtlwifi: rtl818x: constify rtl_intf_ops structures

2016-05-01 Thread Julia Lawall
The rtl_intf_ops structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/net/wireless/realtek/rtlwifi/pci.c  |2 +-
 drivers/net/wireless/realtek/rtlwifi/pci.h  |2 +-
 drivers/net/wireless/realtek/rtlwifi/usb.c  |2 +-
 drivers/net/wireless/realtek/rtlwifi/wifi.h |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c 
b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 1ac41b8..66030ea 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -2456,7 +2456,7 @@ int rtl_pci_resume(struct device *dev)
 EXPORT_SYMBOL(rtl_pci_resume);
 #endif /* CONFIG_PM_SLEEP */
 
-struct rtl_intf_ops rtl_pci_ops = {
+const struct rtl_intf_ops rtl_pci_ops = {
.read_efuse_byte = read_efuse_byte,
.adapter_start = rtl_pci_start,
.adapter_stop = rtl_pci_stop,
diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.h 
b/drivers/net/wireless/realtek/rtlwifi/pci.h
index 5da6703..b951eba 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.h
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.h
@@ -286,7 +286,7 @@ struct rtl_pci_priv {
 
 int rtl_pci_reset_trx_ring(struct ieee80211_hw *hw);
 
-extern struct rtl_intf_ops rtl_pci_ops;
+extern const struct rtl_intf_ops rtl_pci_ops;
 
 int rtl_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *id);
diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c 
b/drivers/net/wireless/realtek/rtlwifi/usb.c
index aac1ed3..41617b7 100644
--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
+++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
@@ -1049,7 +1049,7 @@ static void rtl_fill_h2c_cmd_work_callback(struct 
work_struct *work)
rtlpriv->cfg->ops->fill_h2c_cmd(hw, H2C_RA_MASK, 5, rtlpriv->rate_mask);
 }
 
-static struct rtl_intf_ops rtl_usb_ops = {
+static const struct rtl_intf_ops rtl_usb_ops = {
.adapter_start = rtl_usb_start,
.adapter_stop = rtl_usb_stop,
.adapter_tx = rtl_usb_tx,
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h 
b/drivers/net/wireless/realtek/rtlwifi/wifi.h
index 11d9c23..4e0ab4d 100644
--- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
+++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
@@ -2593,7 +2593,7 @@ struct rtl_priv {
 *intf_ops : for diff interrface usb/pcie
 */
struct rtl_hal_cfg *cfg;
-   struct rtl_intf_ops *intf_ops;
+   const struct rtl_intf_ops *intf_ops;
 
/*this var will be set by set_bit,
   and was used to indicate status of

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] net/mac80211/agg-rx.c: fix use of uninitialised values

2016-01-28 Thread Julia Lawall


On Thu, 28 Jan 2016, Julian Calaby wrote:

> Hi Johannes,
>
> On Thu, Jan 28, 2016 at 8:48 PM, Johannes Berg
>  wrote:
> > On Thu, 2016-01-28 at 10:27 +1100, Julian Calaby wrote:
> >> I'd prefer to just set ->removed to false right after we set
> >> ->auto_seq as that should be faster, however I don't know if
> >> __ieee80211_start_rx_ba_session() is a fast path so I don't know if
> >> this is saving anything.
> >
> > It's not supposed to be called frequently, no.
>
> Then most of my commentary is moot.
>
> I guess the argument comes down to do we zero everything or initialise
> everything, and if speed isn't an issue, the former is better.
>
> >> On another note, this is an error that should be pretty easy to spot.
> >> Could any of the automated tools find cases where a struct containing
> >> a bool variable is kmalloc'd and returned without assigning all the
> >> bools?
> >
> > I think you'd quickly drown in false positives, since "return" isn't
> > necessarily something that means it needs to have been fully
> > initialized.
>
> True.
>
> Either way, I'm guessing that UBSAN will pick up a lot of similar bugs
> and the output of that is probably a much smaller haystack to dig
> through than just "every" kmalloc() call.

It could be possible to find the cases where most of the fields are
initialized, but one is left out.  This could be done for all the fields of
a given type, or in general.

julia

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()

2016-01-02 Thread Julia Lawall


On Sat, 2 Jan 2016, SF Markus Elfring wrote:

> >> Move the jump label directly before the desired log statement
> >> so that the variable "err" will not be checked once more
> >> after it was determined that a function call failed.
> >> Use the identifier "report_failure" instead of the label "err".
> > 
> >Why?
> 
> I suggest to reconsider the places with which such a jump label
> is connected.
> 
> 
> > The code was smart enough
> 
> Which action should really be performed after a failure was detected
> and handled a bit already?
> 
> * Another condition check
> 
> * Just additional error logging
> 
> 
> > and you're making it uglier that it needs to be.
> 
> I assume that a software development taste can evolve, can't it?

So far, you have gotten several down votes for this kind of change, and no 
enthusiasm.

Admittedly, this is a trivial case, because there are no local variables, 
but do you actually know the semantics in C of a jump into a block?  And 
if you do know, do you think that this semantics is common knowledge?  And 
do you really think that introducing poorly understandable code is really 
worth saving an if test of a single variable on a non-critical path?

Most of the kernel code is not performance critical at the level of a 
single if test.  So the goal should be for the code to be easy to 
understand and robust to change.  The code that is performance critical, 
you should probably not touch, ever.  The people who wrote it knew what 
was important and what was not.

julia
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()

2016-01-01 Thread Julia Lawall


On Fri, 1 Jan 2016, SF Markus Elfring wrote:

> From: Markus Elfring 
> Date: Fri, 1 Jan 2016 22:27:20 +0100
> 
> This issue was detected by using the Coccinelle software.
> 
> Move the jump label directly before the desired log statement
> so that the variable "err" will not be checked once more
> after it was determined that a function call failed.

Putting a label inside an if is ugly.

julia

> Use the identifier "report_failure" instead of the label "err".
> 
> Signed-off-by: Markus Elfring 
> ---
>  drivers/net/wireless/marvell/libertas/if_spi.c | 11 ++-
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/libertas/if_spi.c 
> b/drivers/net/wireless/marvell/libertas/if_spi.c
> index 82c0796..c9ae27e 100644
> --- a/drivers/net/wireless/marvell/libertas/if_spi.c
> +++ b/drivers/net/wireless/marvell/libertas/if_spi.c
> @@ -880,18 +880,18 @@ static void if_spi_host_to_card_worker(struct 
> work_struct *work)
>   );
>   if (err) {
>   netdev_err(priv->dev, "I/O error\n");
> - goto err;
> + goto report_failure;
>   }
>  
>   if (hiStatus & IF_SPI_HIST_CMD_UPLOAD_RDY) {
>   err = if_spi_c2h_cmd(card);
>   if (err)
> - goto err;
> + goto report_failure;
>   }
>   if (hiStatus & IF_SPI_HIST_RX_UPLOAD_RDY) {
>   err = if_spi_c2h_data(card);
>   if (err)
> - goto err;
> + goto report_failure;
>   }
>  
>   /*
> @@ -940,9 +940,10 @@ static void if_spi_host_to_card_worker(struct 
> work_struct *work)
>   if (hiStatus & IF_SPI_HIST_CARD_EVENT)
>   if_spi_e2h(card);
>  
> -err:
> - if (err)
> + if (err) {
> +report_failure:
>   netdev_err(priv->dev, "%s: got error %d\n", __func__, err);
> + }
>  
>   lbs_deb_leave(LBS_DEB_SPI);
>  }
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] iwlegacy: 4965-mac: constify il_sensitivity_ranges structure

2015-12-30 Thread Julia Lawall
The il_sensitivity_ranges is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/net/wireless/intel/iwlegacy/4965-mac.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/4965-mac.c 
b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
index 6656215..fd38aa0 100644
--- a/drivers/net/wireless/intel/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/intel/iwlegacy/4965-mac.c
@@ -6416,7 +6416,7 @@ il4965_hw_detect(struct il_priv *il)
D_INFO("HW Revision ID = 0x%X\n", il->rev_id);
 }
 
-static struct il_sensitivity_ranges il4965_sensitivity = {
+static const struct il_sensitivity_ranges il4965_sensitivity = {
.min_nrg_cck = 97,
.max_nrg_cck = 0,   /* not used, set to 0 */
 

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch -next] ath9k: fix ath9k_hw_nvram_check_version()

2015-12-20 Thread Julia Lawall
On Sun, 20 Dec 2015, Joe Perches wrote:

> On Sat, 2015-12-19 at 13:59 +0300, Dan Carpenter wrote:
> > There is a type bug so it always returns success.
> 
> How many false positives do you have to sift
> through to find this sort of error?

The return type is thoughtfully bool, so it should be easy in this case.  
The function has a return -EINVAL and a return true, so even without the 
return type it would be locally apparent that there is an inconsistency.

julia

> 
> > +++ b/drivers/net/wireless/ath/ath9k/eeprom.c
> > @@ -206,7 +206,7 @@ bool ath9k_hw_nvram_check_version(struct ath_hw *ah, 
> > int version, int minrev)
> >     ath_err(common, "Bad EEPROM VER 0x%04x or REV 0x%04x\n",
> >     ah->eep_ops->get_eeprom_ver(ah),
> >     ah->eep_ops->get_eeprom_rev(ah));
> > -   return -EINVAL;
> > +   return false;
> >     }
> >  
> >     return true;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

[PATCH] prism54: fix compare_const_fl.cocci warnings (fwd)

2015-12-07 Thread Julia Lawall
Move constants to the right of binary operators.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

It looks a little nicer to me because n is the thing we care about.

 oid_mgt.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/drivers/net/wireless/intersil/prism54/oid_mgt.c
+++ b/drivers/net/wireless/intersil/prism54/oid_mgt.c
@@ -424,7 +424,7 @@ mgt_set_request(islpci_private *priv, en
void *cache, *_data = data;
u32 oid;

-   BUG_ON(OID_NUM_LAST <= n);
+   BUG_ON(n >= OID_NUM_LAST);
BUG_ON(extra > isl_oid[n].range);

if (!priv->mib)
@@ -485,7 +485,7 @@ mgt_set_varlen(islpci_private *priv, enu
int dlen;
u32 oid;

-   BUG_ON(OID_NUM_LAST <= n);
+   BUG_ON(n >= OID_NUM_LAST);

dlen = isl_oid[n].size;
oid = isl_oid[n].oid;
@@ -524,7 +524,7 @@ mgt_get_request(islpci_private *priv, en
void *cache, *_res = NULL;
u32 oid;

-   BUG_ON(OID_NUM_LAST <= n);
+   BUG_ON(n >= OID_NUM_LAST);
BUG_ON(extra > isl_oid[n].range);

res->ptr = NULL;
@@ -626,7 +626,7 @@ mgt_commit_list(islpci_private *priv, en
 void
 mgt_set(islpci_private *priv, enum oid_num_t n, void *data)
 {
-   BUG_ON(OID_NUM_LAST <= n);
+   BUG_ON(n >= OID_NUM_LAST);
BUG_ON(priv->mib[n] == NULL);

memcpy(priv->mib[n], data, isl_oid[n].size);
@@ -636,7 +636,7 @@ mgt_set(islpci_private *priv, enum oid_n
 void
 mgt_get(islpci_private *priv, enum oid_num_t n, void *res)
 {
-   BUG_ON(OID_NUM_LAST <= n);
+   BUG_ON(n >= OID_NUM_LAST);
BUG_ON(priv->mib[n] == NULL);
BUG_ON(res == NULL);

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] mwifiex: fix semicolon.cocci warnings

2015-12-06 Thread Julia Lawall
Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

 init.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/wireless/marvell/mwifiex/init.c
+++ b/drivers/net/wireless/marvell/mwifiex/init.c
@@ -95,7 +95,7 @@ int mwifiex_init_priv(struct mwifiex_pri
priv->curr_pkt_filter = HostCmd_ACT_MAC_RX_ON | HostCmd_ACT_MAC_TX_ON |
HostCmd_ACT_MAC_ETHERNETII_ENABLE;
 
-   priv->beacon_period = 100; /* beacon interval */ ;
+   priv->beacon_period = 100; /* beacon interval */
priv->attempted_bss_desc = NULL;
memset(>curr_bss_params, 0, sizeof(priv->curr_bss_params));
priv->listen_interval = MWIFIEX_DEFAULT_LISTEN_INTERVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] brcm80211: fix compare_const_fl.cocci warnings

2015-12-05 Thread Julia Lawall
Move constants to the right of binary operators.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

Minor point.  But in my opinion, it would look a little nicer to have the 
thing acted on (code[...]) come first.

 channel.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/channel.c
@@ -177,8 +177,8 @@ static bool brcms_c_country_valid(const
 * only allow ascii alpha uppercase for the first 2
 * chars.
 */
-   if (!((0x80 & ccode[0]) == 0 && ccode[0] >= 0x41 && ccode[0] <= 0x5A &&
- (0x80 & ccode[1]) == 0 && ccode[1] >= 0x41 && ccode[1] <= 0x5A))
+   if (!((ccode[0] & 0x80) == 0 && ccode[0] >= 0x41 && ccode[0] <= 0x5A &&
+ (ccode[1] & 0x80) == 0 && ccode[1] >= 0x41 && ccode[1] <= 0x5A))
return false;
 
/*
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] iwlwifi: fix compare_const_fl.cocci warnings

2015-11-27 Thread Julia Lawall
Move constants to the right of binary operators.

Generated by: scripts/coccinelle/misc/compare_const_fl.cocci

Signed-off-by: Fengguang Wu <fengguang...@intel.com>
Signed-off-by: Julia Lawall <julia.law...@lip6.fr>
---

This looks a bit nicer around the other way, in my opinion.

 calib.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/wireless/intel/iwlwifi/dvm/calib.c
+++ b/drivers/net/wireless/intel/iwlwifi/dvm/calib.c
@@ -311,7 +311,7 @@ static int iwl_sens_energy_cck(struct iw
/* If previous beacon had too many false alarms,
 *   give it some extra margin by reducing sensitivity again
 *   (but don't go below measured energy of desired Rx) */
-   if (IWL_FA_TOO_MANY == data->nrg_prev_state) {
+   if (data->nrg_prev_state == IWL_FA_TOO_MANY) {
IWL_DEBUG_CALIB(priv, "... increasing margin\n");
if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN))
data->nrg_th_cck -= NRG_MARGIN;
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] brcmfmac: constify brcmf_bus_ops structures

2015-11-14 Thread Julia Lawall
The brcmf_bus_ops structures are never modified, so declare them as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/net/wireless/brcm80211/brcmfmac/bus.h  |2 +-
 drivers/net/wireless/brcm80211/brcmfmac/pcie.c |2 +-
 drivers/net/wireless/brcm80211/brcmfmac/sdio.c |2 +-
 drivers/net/wireless/brcm80211/brcmfmac/usb.c  |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bus.h 
b/drivers/net/wireless/brcm80211/brcmfmac/bus.h
index 230cad7..36093f9 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bus.h
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bus.h
@@ -137,7 +137,7 @@ struct brcmf_bus {
bool always_use_fws_queue;
bool wowl_supported;
 
-   struct brcmf_bus_ops *ops;
+   const struct brcmf_bus_ops *ops;
struct brcmf_bus_msgbuf *msgbuf;
 };
 
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/pcie.c 
b/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
index 83d8042..65ae3b0 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
@@ -1419,7 +1419,7 @@ static int brcmf_pcie_get_memdump(struct device *dev, 
void *data, size_t len)
 }
 
 
-static struct brcmf_bus_ops brcmf_pcie_bus_ops = {
+static const struct brcmf_bus_ops brcmf_pcie_bus_ops = {
.txdata = brcmf_pcie_tx,
.stop = brcmf_pcie_down,
.txctl = brcmf_pcie_tx_ctlpkt,
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio.c 
b/drivers/net/wireless/brcm80211/brcmfmac/sdio.c
index 7e74ac3..01f359e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio.c
@@ -4025,7 +4025,7 @@ brcmf_sdio_watchdog(unsigned long data)
}
 }
 
-static struct brcmf_bus_ops brcmf_sdio_bus_ops = {
+static const struct brcmf_bus_ops brcmf_sdio_bus_ops = {
.stop = brcmf_sdio_bus_stop,
.preinit = brcmf_sdio_bus_preinit,
.txdata = brcmf_sdio_bus_txdata,
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c 
b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
index 689e64d..4bdd3b3 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c
@@ -1163,7 +1163,7 @@ static void brcmf_usb_wowl_config(struct device *dev, 
bool enabled)
device_set_wakeup_enable(devinfo->dev, false);
 }
 
-static struct brcmf_bus_ops brcmf_usb_bus_ops = {
+static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
.txdata = brcmf_usb_tx,
.stop = brcmf_usb_down,
.txctl = brcmf_usb_tx_ctlpkt,

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] nfc: s3fwrn5: constify s3fwrn5_phy_ops structures

2015-11-13 Thread Julia Lawall
The s3fwrn5_phy_ops structure is never modified, so declare it as const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/nfc/s3fwrn5/core.c|2 +-
 drivers/nfc/s3fwrn5/i2c.c |2 +-
 drivers/nfc/s3fwrn5/s3fwrn5.h |4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/s3fwrn5/core.c b/drivers/nfc/s3fwrn5/core.c
index 0d866ca..9d9c8d5 100644
--- a/drivers/nfc/s3fwrn5/core.c
+++ b/drivers/nfc/s3fwrn5/core.c
@@ -147,7 +147,7 @@ static struct nci_ops s3fwrn5_nci_ops = {
 };
 
 int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
-   struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload)
+   const struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload)
 {
struct s3fwrn5_info *info;
int ret;
diff --git a/drivers/nfc/s3fwrn5/i2c.c b/drivers/nfc/s3fwrn5/i2c.c
index c61d8a3..3ed0adf 100644
--- a/drivers/nfc/s3fwrn5/i2c.c
+++ b/drivers/nfc/s3fwrn5/i2c.c
@@ -125,7 +125,7 @@ static int s3fwrn5_i2c_write(void *phy_id, struct sk_buff 
*skb)
return 0;
 }
 
-static struct s3fwrn5_phy_ops i2c_phy_ops = {
+static const struct s3fwrn5_phy_ops i2c_phy_ops = {
.set_wake = s3fwrn5_i2c_set_wake,
.set_mode = s3fwrn5_i2c_set_mode,
.get_mode = s3fwrn5_i2c_get_mode,
diff --git a/drivers/nfc/s3fwrn5/s3fwrn5.h b/drivers/nfc/s3fwrn5/s3fwrn5.h
index 89210d4..7d5e516 100644
--- a/drivers/nfc/s3fwrn5/s3fwrn5.h
+++ b/drivers/nfc/s3fwrn5/s3fwrn5.h
@@ -44,7 +44,7 @@ struct s3fwrn5_info {
void *phy_id;
struct device *pdev;
 
-   struct s3fwrn5_phy_ops *phy_ops;
+   const struct s3fwrn5_phy_ops *phy_ops;
unsigned int max_payload;
 
struct s3fwrn5_fw_info fw_info;
@@ -90,7 +90,7 @@ static inline int s3fwrn5_write(struct s3fwrn5_info *info, 
struct sk_buff *skb)
 }
 
 int s3fwrn5_probe(struct nci_dev **ndev, void *phy_id, struct device *pdev,
-   struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload);
+   const struct s3fwrn5_phy_ops *phy_ops, unsigned int max_payload);
 void s3fwrn5_remove(struct nci_dev *ndev);
 
 int s3fwrn5_recv_frame(struct nci_dev *ndev, struct sk_buff *skb,

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/8] add missing of_node_put

2015-10-25 Thread Julia Lawall
The various for_each device_node iterators performs an of_node_get on each
iteration, so a break out of the loop requires an of_node_put.

The complete semantic patch that fixes this problem is
(http://coccinelle.lip6.fr):

// 
@r@
local idexpression n;
expression e1,e2;
iterator name for_each_node_by_name, for_each_node_by_type,
for_each_compatible_node, for_each_matching_node,
for_each_matching_node_and_match, for_each_child_of_node,
for_each_available_child_of_node, for_each_node_with_property;
iterator i;
statement S;
expression list [n1] es;
@@

(
(
for_each_node_by_name(n,e1) S
|
for_each_node_by_type(n,e1) S
|
for_each_compatible_node(n,e1,e2) S
|
for_each_matching_node(n,e1) S
|
for_each_matching_node_and_match(n,e1,e2) S
|
for_each_child_of_node(e1,n) S
|
for_each_available_child_of_node(e1,n) S
|
for_each_node_with_property(n,e1) S
)
&
i(es,n,...) S
)

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
   return n;
|
+  of_node_put(n);
?  return ...;
)
   ...
 }

@@
local idexpression r.n;
iterator r.i;
expression e;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n

@@
local idexpression r.n;
iterator r.i;
expression e;
identifier l;
expression list [r.n1] es;
@@

 i(es,n,...) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  goto l;
)
   ...
 }
...
l: ... when != n// 

---

 drivers/media/platform/xilinx/xilinx-tpg.c|2 ++
 drivers/media/platform/xilinx/xilinx-vipp.c   |4 +++-
 drivers/net/ethernet/cavium/thunder/thunder_bgx.c |4 +++-
 drivers/net/ethernet/marvell/mv643xx_eth.c|4 +++-
 drivers/net/ethernet/ti/netcp_ethss.c |8 ++--
 drivers/net/phy/mdio-mux-mmioreg.c|2 ++
 drivers/net/phy/mdio-mux.c|1 +
 drivers/net/wireless/ath/ath6kl/init.c|1 +
 8 files changed, 21 insertions(+), 5 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/8] ath6kl: add missing of_node_put

2015-10-25 Thread Julia Lawall
for_each_compatible_node performs an of_node_get on each iteration, so
a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// 
@@
expression e;
local idexpression n;
@@

 for_each_compatible_node(n,...) {
   ... when != of_node_put(n)
   when != e = n
(
   return n;
|
+  of_node_put(n);
?  return ...;
)
   ...
 }
// 

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/net/wireless/ath/ath6kl/init.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/ath/ath6kl/init.c 
b/drivers/net/wireless/ath/ath6kl/init.c
index 6e473fa..12241b1 100644
--- a/drivers/net/wireless/ath/ath6kl/init.c
+++ b/drivers/net/wireless/ath/ath6kl/init.c
@@ -715,6 +715,7 @@ static bool check_device_tree(struct ath6kl *ar)
   board_filename, ret);
continue;
}
+   of_node_put(node);
return true;
}
return false;

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] NFC: delete null dereference

2015-10-17 Thread Julia Lawall
The exit label performs device_unlock(>dev);, which will fail when dev
is NULL, and nfc_put_device(dev);, which is not useful when dev is NULL, so
just exit the function immediately.

Problem found using scripts/coccinelle/null/deref_null.cocci

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 net/nfc/netlink.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
index 853172c..f040532 100644
--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -1109,10 +1109,8 @@ static int nfc_genl_llc_sdreq(struct sk_buff *skb, 
struct genl_info *info)
idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
 
dev = nfc_get_device(idx);
-   if (!dev) {
-   rc = -ENODEV;
-   goto exit;
-   }
+   if (!dev)
+   return -ENODEV;
 
device_lock(>dev);
 

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] delete null dereference

2015-10-17 Thread Julia Lawall
These patches delete NULL dereferences, as detected by
scripts/coccinelle/null/deref_null.cocci.

---

 drivers/media/pci/netup_unidvb/netup_unidvb_spi.c |6 ++
 net/nfc/netlink.c |6 ++
 2 files changed, 4 insertions(+), 8 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] NFC: nxp-nci: constify nxp_nci_phy_ops structure

2015-10-11 Thread Julia Lawall
The only instance of a nxp_nci_phy_ops structure is never modified.  Thus
the declaration of the structure and all references to the structure type
can be made const.

Done with the help of Coccinelle.

Signed-off-by: Julia Lawall <julia.law...@lip6.fr>

---
 drivers/nfc/nxp-nci/core.c|3 ++-
 drivers/nfc/nxp-nci/i2c.c |2 +-
 drivers/nfc/nxp-nci/nxp-nci.h |5 +++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index fac80c6..df4333c 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -106,7 +106,7 @@ static int nxp_nci_i2c_write(void *phy_id, struct sk_buff 
*skb)
return r;
 }
 
-static struct nxp_nci_phy_ops i2c_phy_ops = {
+static const struct nxp_nci_phy_ops i2c_phy_ops = {
.set_mode = nxp_nci_i2c_set_mode,
.write = nxp_nci_i2c_write,
 };
diff --git a/drivers/nfc/nxp-nci/nxp-nci.h b/drivers/nfc/nxp-nci/nxp-nci.h
index f1fecc4..20408cb 100644
--- a/drivers/nfc/nxp-nci/nxp-nci.h
+++ b/drivers/nfc/nxp-nci/nxp-nci.h
@@ -68,7 +68,7 @@ struct nxp_nci_info {
 
enum nxp_nci_mode mode;
 
-   struct nxp_nci_phy_ops *phy_ops;
+   const struct nxp_nci_phy_ops *phy_ops;
unsigned int max_payload;
 
struct mutex info_lock;
@@ -82,7 +82,8 @@ void nxp_nci_fw_recv_frame(struct nci_dev *ndev, struct 
sk_buff *skb);
 void nxp_nci_fw_work_complete(struct nxp_nci_info *info, int result);
 
 int nxp_nci_probe(void *phy_id, struct device *pdev,
- struct nxp_nci_phy_ops *phy_ops, unsigned int max_payload,
+ const struct nxp_nci_phy_ops *phy_ops,
+ unsigned int max_payload,
  struct nci_dev **ndev);
 void nxp_nci_remove(struct nci_dev *ndev);
 
diff --git a/drivers/nfc/nxp-nci/core.c b/drivers/nfc/nxp-nci/core.c
index 8979636..2e4b004 100644
--- a/drivers/nfc/nxp-nci/core.c
+++ b/drivers/nfc/nxp-nci/core.c
@@ -109,7 +109,8 @@ static struct nci_ops nxp_nci_ops = {
 };
 
 int nxp_nci_probe(void *phy_id, struct device *pdev,
- struct nxp_nci_phy_ops *phy_ops, unsigned int max_payload,
+ const struct nxp_nci_phy_ops *phy_ops,
+ unsigned int max_payload,
  struct nci_dev **ndev)
 {
struct nxp_nci_info *info;

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection

2015-06-27 Thread Julia Lawall


On Sat, 27 Jun 2015, SF Markus Elfring wrote:

 From: Markus Elfring elfr...@users.sourceforge.net
 Date: Sat, 27 Jun 2015 16:00:59 +0200

 The kfree() function was called in two cases by the mac_ioctl() function
 during error handling even if the passed variable did not contain a pointer
 for a valid data item.

 * This implementation detail could be improved by the introduction
   of another jump label.

 * Drop an unnecessary initialisation for the variable buff then.

 Signed-off-by: Markus Elfring elfr...@users.sourceforge.net
 ---
  drivers/staging/wilc1000/linux_wlan.c | 10 --
  1 file changed, 4 insertions(+), 6 deletions(-)

 diff --git a/drivers/staging/wilc1000/linux_wlan.c 
 b/drivers/staging/wilc1000/linux_wlan.c
 index 2aa8d9b..f492310 100644
 --- a/drivers/staging/wilc1000/linux_wlan.c
 +++ b/drivers/staging/wilc1000/linux_wlan.c
 @@ -2351,16 +2351,13 @@ int mac_close(struct net_device *ndev)

  int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
  {
 -
 - u8 *buff = NULL;
 + u8 *buff;
   s8 rssi;
   u32 size = 0, length = 0;
   perInterface_wlan_t *nic;
   struct WILC_WFI_priv *priv;
   s32 s32Error = WILC_SUCCESS;

 -
 -

Removing these blank lines seems to have nothing to do with the topic of
the patch.

julia

   /* struct iwreq *wrq = (struct iwreq *) req;// tony moved to case 
 SIOCSIWPRIV */
   #ifdef USE_WIRELESS
   nic = netdev_priv(ndev);
 @@ -2405,7 +2402,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq 
 *req, int cmd)
   if (copy_to_user(wrq-u.data.pointer, buff, 
 size)) {
   PRINT_ER(%s: failed to copy data to 
 user buffer\n, __func__);
   s32Error = -EFAULT;
 - goto done;
 + goto free_buffer;
   }
   }
   }
 @@ -2420,8 +2417,9 @@ int mac_ioctl(struct net_device *ndev, struct ifreq 
 *req, int cmd)
   }
   }

 -done:
 +free_buffer:
   kfree(buff);
 +done:
   return s32Error;
  }

 --
 2.4.4

 --
 To unsubscribe from this list: send the line unsubscribe kernel-janitors in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1 linux-next] ath5k: use swap() in ath5k_hw_get_median_noise_floor()

2015-06-10 Thread Julia Lawall


On Wed, 10 Jun 2015, Fabian Frederick wrote:

 
 
  On 10 June 2015 at 21:52 Joe Perches j...@perches.com wrote:
 
 
  On Wed, 2015-06-10 at 18:33 +0200, Fabian Frederick wrote:
   Use kernel.h macro definition.
  
   Thanks to Julia Lawall for Coccinelle scripting support.
  []
   diff --git a/drivers/net/wireless/ath/ath5k/phy.c
   b/drivers/net/wireless/ath/ath5k/phy.c
  []
   @@ -1566,17 +1566,13 @@ static s16
    ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah)
    {
       s16 sort[ATH5K_NF_CAL_HIST_MAX];
   -   s16 tmp;
       int i, j;
   
       memcpy(sort, ah-ah_nfcal_hist.nfval, sizeof(sort));
       for (i = 0; i  ATH5K_NF_CAL_HIST_MAX - 1; i++) {
               for (j = 1; j  ATH5K_NF_CAL_HIST_MAX - i; j++) {
   -                   if (sort[j]  sort[j - 1]) {
   -                           tmp = sort[j];
   -                           sort[j] = sort[j - 1];
   -                           sort[j - 1] = tmp;
   -                   }
   +                   if (sort[j]  sort[j - 1])
   +                           swap(sort[j], sort[j]);
 
  swap(a, a) doesn't look useful.
 Thanks a lot Joe, I'll fix this one :)

How did it come out like that?

julia

 
 Regards,
 Fabian
 
 
 

[PATCH 5/9] wl1251: drop unneeded goto

2015-05-28 Thread Julia Lawall
From: Julia Lawall julia.law...@lip6.fr

Delete jump to a label on the next line, when that label is not
used elsewhere.

A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@r@
identifier l;
@@

-if (...) goto l;
-l:
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/ti/wl1251/acx.c |3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/wireless/ti/wl1251/acx.c 
b/drivers/net/wireless/ti/wl1251/acx.c
index 5695628..d6fbdda 100644
--- a/drivers/net/wireless/ti/wl1251/acx.c
+++ b/drivers/net/wireless/ti/wl1251/acx.c
@@ -53,10 +53,7 @@ int wl1251_acx_station_id(struct wl1251 *wl)
mac-mac[i] = wl-mac_addr[ETH_ALEN - 1 - i];
 
ret = wl1251_cmd_configure(wl, DOT11_STATION_ID, mac, sizeof(*mac));
-   if (ret  0)
-   goto out;
 
-out:
kfree(mac);
return ret;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/9] drop unneeded goto

2015-05-28 Thread Julia Lawall
These patches drop gotos that jump to a label that is at the next
instruction, in the case that the label is not used elsewhere in the
function.  The complete semantic patch that performs this transformation is
as follows:

// smpl
@r@
position p;
identifier l;
@@

if (...) goto l@p;
l:

@script:ocaml s@
p  r.p;
nm;
@@

nm := (List.hd p).current_element

@ok exists@
identifier s.nm,l;
position p != r.p;
@@

nm(...) {
+... goto l@p; ...+
}

@depends on !ok@
identifier s.nm;
position r.p;
identifier l;
@@

nm(...) {
...
- if(...) goto l@p; l:
...
}
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] rtlwifi: misspelled code and comments corrected.

2015-04-12 Thread Julia Lawall


On Sun, 12 Apr 2015, Cheolhyun Park wrote:

 Signed-off-by: Cheolhyun Park pch851...@gmail.com
 ---
  drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 2 +-
  drivers/net/wireless/rtlwifi/rtl8192de/dm.c   | 2 +-
  drivers/net/wireless/rtlwifi/rtl8821ae/dm.c   | 2 +-
  3 files changed, 3 insertions(+), 3 deletions(-)

 diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c 
 b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
 index f5ee67c..1273997 100644
 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
 +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c
 @@ -312,7 +312,7 @@ static void rtl92c_dm_ctrl_initgain_by_rssi(struct 
 ieee80211_hw *hw)
   struct dig_t *digtable = rtlpriv-dm_digtable;
   u32 isbt;

 - /* modify DIG lower bound, deal with abnorally large false alarm */
 + /* modify DIG lower bound, deal with abnormally arge false alarm */

You have converted large to arge.

julia

   if (rtlpriv-falsealm_cnt.cnt_all  1) {
   digtable-large_fa_hit++;
   if (digtable-forbidden_igi  digtable-cur_igvalue) {
 diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c 
 b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
 index a1be5a6..f209cda 100644
 --- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
 +++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c
 @@ -420,7 +420,7 @@ static void rtl92d_dm_dig(struct ieee80211_hw *hw)
dm_DIG() Before: Recover_cnt=%d, rx_gain_min=%x\n,
de_digtable-recover_cnt, de_digtable-rx_gain_min);

 - /* deal with abnorally large false alarm */
 + /* deal with abnormally large false alarm */
   if (falsealm_cnt-cnt_all  1) {
   RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
dm_DIG(): Abnormally false alarm case\n);
 diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c 
 b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
 index 0b2082d..342678d 100644
 --- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
 +++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
 @@ -873,7 +873,7 @@ static void rtl8821ae_dm_dig(struct ieee80211_hw *hw)

   if (rtlpriv-falsealm_cnt.cnt_all  1) {
   RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
 -  Abnornally false alarm case.\n);
 +  Abnormally false alarm case.\n);

   if (dm_digtable-large_fa_hit != 3)
   dm_digtable-large_fa_hit++;
 --
 1.9.1


--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/16] NFC: pn533: fix error return code

2015-04-05 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/nfc/pn533.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
index d46a700..732e607 100644
--- a/drivers/nfc/pn533.c
+++ b/drivers/nfc/pn533.c
@@ -2554,8 +2554,10 @@ static int pn533_data_exchange_complete(struct pn533 
*dev, void *_arg,
}
 
skb = pn533_build_response(dev);
-   if (!skb)
+   if (!skb) {
+   rc = -ENOMEM;
goto error;
+   }
 
arg-cb(arg-cb_context, skb, 0);
kfree(arg);

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] staging: rtl8723au: Remove unnecessary OOM message

2015-03-06 Thread Julia Lawall


On Fri, 6 Mar 2015, Jes Sorensen wrote:

 Quentin Lambert lambert.quen...@gmail.com writes:
  This patch reduces the kernel size by removing error messages that duplicate
  the normal OOM message.
 
  A simplified version of the semantic patch that finds this problem is as
  follows: (http://coccinelle.lip6.fr)

 This patch removes useful warnings about what allocation failed. The
 messages removed are NOT duplicate!

Is it really the case that the information can't be reconstructed from the
information generated by kmalloc on failure?  To my understanding there is
a stack trace, and from scanning through the changes I see only one change
per function, so perhaps the stack trace already makes it clear where the
problem occurred?

julia


 NACK

 Jes

 
  @@
  identifier f,print,l;
  expression e;
  constant char[] c;
  @@
 
  e = \(kzalloc\|kmalloc\|devm_kzalloc\|devm_kmalloc\)(...);
  if (e == NULL) {
+...
  -  print(...,c,...);
... when any
  (
goto l;
  |
return ...;
  )
...+ }
 
  Signed-off-by: Quentin Lambert lambert.quen...@gmail.com
  ---
   drivers/staging/rtl8723au/hal/rtl8723a_cmd.c  | 8 ++--
   drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 8 ++--
   drivers/staging/rtl8723au/hal/usb_ops_linux.c | 6 +-
   drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 5 -
   4 files changed, 5 insertions(+), 22 deletions(-)
 
  diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c 
  b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
  index 7b56411..38f5b7f 100644
  --- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
  +++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
  @@ -462,10 +462,8 @@ static void SetFwRsvdPagePkt(struct rtw_adapter 
  *padapter, bool bDLFinished)
  DBG_8723A(%s\n, __func__);
 
  ReservedPagePacket = kzalloc(1000, GFP_KERNEL);
  -   if (ReservedPagePacket == NULL) {
  -   DBG_8723A(%s: alloc ReservedPagePacket fail!\n, __func__);
  +   if (ReservedPagePacket == NULL)
  return;
  -   }
 
  pHalData = GET_HAL_DATA(padapter);
  pxmitpriv = padapter-xmitpriv;
  @@ -669,10 +667,8 @@ static void SetFwRsvdPagePkt_BTCoex(struct rtw_adapter 
  *padapter)
  DBG_8723A(+%s\n, __func__);
 
  ReservedPagePacket = kzalloc(1024, GFP_KERNEL);
  -   if (ReservedPagePacket == NULL) {
  -   DBG_8723A(%s: alloc ReservedPagePacket fail!\n, __func__);
  +   if (ReservedPagePacket == NULL)
  return;
  -   }
 
  pHalData = GET_HAL_DATA(padapter);
  pxmitpriv = padapter-xmitpriv;
  diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c 
  b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
  index a5eadd4..6d50b09 100644
  --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
  +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
  @@ -401,10 +401,8 @@ hal_ReadEFuse_WiFi(struct rtw_adapter *padapter,
  }
 
  efuseTbl = kmalloc(EFUSE_MAP_LEN_8723A, GFP_KERNEL);
  -   if (efuseTbl == NULL) {
  -   DBG_8723A(%s: alloc efuseTbl fail!\n, __func__);
  +   if (efuseTbl == NULL)
  return;
  -   }
  /*  0xff will be efuse default value instead of 0x00. */
  memset(efuseTbl, 0xFF, EFUSE_MAP_LEN_8723A);
 
  @@ -494,10 +492,8 @@ hal_ReadEFuse_BT(struct rtw_adapter *padapter,
  }
 
  efuseTbl = kmalloc(EFUSE_BT_MAP_LEN, GFP_KERNEL);
  -   if (efuseTbl == NULL) {
  -   DBG_8723A(%s: efuseTbl malloc fail!\n, __func__);
  +   if (efuseTbl == NULL)
  return;
  -   }
  /*  0xff will be efuse default value instead of 0x00. */
  memset(efuseTbl, 0xFF, EFUSE_BT_MAP_LEN);
 
  diff --git a/drivers/staging/rtl8723au/hal/usb_ops_linux.c 
  b/drivers/staging/rtl8723au/hal/usb_ops_linux.c
  index a6d16ad..f1e9202 100644
  --- a/drivers/staging/rtl8723au/hal/usb_ops_linux.c
  +++ b/drivers/staging/rtl8723au/hal/usb_ops_linux.c
  @@ -256,12 +256,8 @@ static void usb_read_interrupt_complete(struct urb 
  *purb)
  c2w = kmalloc(sizeof(struct evt_work),
  GFP_ATOMIC);
 
  -   if (!c2w) {
  -   printk(KERN_WARNING %s: unable to 
  -  allocate work buffer\n,
  -  __func__);
  +   if (!c2w)
  goto urb_submit;
  -   }
 
  c2w-adapter = padapter;
  INIT_WORK(c2w-work, rtw_evt_work);
  diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c 
  b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
  index 537bd82..40bdf4b 100644
  --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
  +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
  @@ -1327,8 +1327,6 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct 
  rtw_adapter *padapter,
  pmlmepriv-wps_probe_req_ie = 

Re: [PATCH] brcm80211: brcmsmac: dma: Remove some unused functions

2015-01-06 Thread Julia Lawall


On Wed, 7 Jan 2015, Rickard Strandqvist wrote:

 2015-01-05 12:06 GMT+01:00 Arend van Spriel ar...@broadcom.com:
  On 01/05/15 11:49, Kalle Valo wrote:
 
  Rickard Strandqvistrickard_strandqv...@spectrumdigital.se  writes:
 
  As I hope you can see I have made some changes regarding the
  subject-line. Thought it was an advantage to be able to see which file
  I actually removed something from. There seems to be a big focus on
  getting right on subject-line right in recent weeks.
 
  I wonder why there is a script that takes a file name, and respond
  with an appropriate subject line?
 
 
  Is there a script for this? Anyway, I would say driver name is enough.
  Enough about the subject line ;-) I would like to give some general remarks
  as you seem to touch a lot of kernel code. First off, I think it is good to
  remove unused stuff. However, I would like some more explanation on your
  methodology apart from partially found by using a static code analysis
  program. So a cover-letter explaining that would have been nice (maybe
  still is). Things like Kconfig option can affect whether function are used
  or not so how did you cover that.
 
  Regards,
  Arend
 
 
  I don't think you can really automate this as some drivers do this a bit
  differently. You always need to manually check the commit log.
 
  But ok, I change my script accordingly. Should I submit the patch again?
 
 
  Yes, please resubmit.
 
 
 
 Hi Arend
 
 Yes, a script that had been excellent, I think!
 I have one as part of my git send-email script, until a week ago, it
 was enough that I removed the drivers/ and changed all / to : 
 I have now been expanded my sed pipe a lot (tell me if anyone is interested)
 But now I've seen everything from uppercase and [DIR], etc.
 So I can not understand how anyone should be able to get the right
 name without a good help.
 
 Sure i like to share how I use cppcheck, but is very hesitant to write
 this with each patch mails I send though!
 
 I run:
 cppcheck --force --quiet --enable=all .
 
 Or a specific file instead of .
 
 This will include, among other things get a lot of error message such,
 +4000 for the kernel.
 (style) The function 'xxx' is never used
 
 For these I made a script that searched through all the files after
 the function name (cppcheck missed a few). And save the rest so I go
 through them and possibly send patches.

I think that the question was about what methodology is cppcheck using to 
find the given issue.  But probably cppcheck is a black box that does 
whatever it does, so the user doesn't know what the rationale is.  
However, I think you mentioned that cppcheck found only some of the 
issues.  You could thus describe what was the methodology for finding the 
other ones.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] adm8211: fix error return code

2014-12-29 Thread Julia Lawall
Return a negative error code on failure.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
identifier ret; expression e1,e2;
@@
(
if (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret = 0
)
... when != ret = e1
when != ret
*if(...)
{
  ... when != ret = e2
  when forall
 return ret;
}
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/adm8211.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index 17fcaab..f07a618 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -1837,6 +1837,7 @@ static int adm8211_probe(struct pci_dev *pdev,
if (!priv-map) {
printk(KERN_ERR %s (adm8211): Cannot map device memory\n,
   pci_name(pdev));
+   err = -ENOMEM;
goto err_free_dev;
}
 

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/8] fix error return code

2014-12-29 Thread Julia Lawall
The complate semantic patch that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// smpl
@ok exists@
identifier f,ret,i;
expression e;
constant c;
@@

// identify a function that returns a negative return value at least once.
f(...) {
... when any
(
return -c@i;
|
ret = -c@i;
... when != ret = e
return ret;
|
if (ret  0) { ... return ret; }
)
... when any
}

@r exists@
identifier ret,ok.f,fn;
expression e1,e2,e3,e4,e5,e6,x;
statement S,S1;
position p1,p2,p3;
@@

// identify a case where the return variable is set to a non-negative value
// and then returned in error-handling code
f(...) {
... when any
(
if@p1 (\(ret  0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != ret
when any
(
 if (+... ret = e5 ...+) S1
|
 if (+... ret ...+) S1
|
if@p2(+...x = fn(...)...+)
 {
  ... when != ret = e6
  when forall
 return@p3 ret;
}
|
break;
|
x = fn(...)
... when != \(ret = e4\|ret++\|ret--\|ret+=e4\|ret-=e4\)
when != ret
(
 if (+... ret = e3 ...+) S
|
 if (+... ret ...+) S
|
if@p2(+...\(x != 0\|x  0\|x == NULL\|IS_ERR(x)\)...+)
 {
  ... when != ret = e2
  when forall
 return@p3 ret;
}
)
)
... when any
}

@printer depends on r@
position p;
identifier ok.f,pr;
constant char [] c;
@@

f(...) { ...pr@p(...,c,...)... }

@bad0 exists@
identifier r.ret,ok.f,g != {ERR_PTR,IS_ERR};
position p != printer.p;
@@

f(...) { ... when any
g@p(...,ret,...)
... when any
 }

@bad depends on !bad0 exists@
position r.p1,r.p2;
statement S1,S2;
identifier r.ret;
expression e1;
@@

// ignore the above if there is some path where the variable is set to
// something else
(
if@p1 (\(ret  0\|ret != 0\)) S1
|
ret@p1 = 0
)
... when any
 \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\|ret\)
... when any
if@p2(...) S2

@bad1 depends on !bad0  !bad exists@
position r.p2;
statement S2;
identifier r.ret;
expression e1;
constant c;
@@

ret = -c
... when != \(ret = e1\|ret++\|ret--\|ret+=e1\|ret-=e1\)
when != ret
when any
if@p2(...) S2

@bad2 depends on !bad0  !bad  !bad1 exists@
position r.p1,r.p2;
identifier r.ret;
expression e1;
statement S2;
constant c;
@@

// likewise ignore it if there has been an intervening return
ret@p1 = 0
... when != if (...) { ... ret = e1 ... return ret; }
when != if (...) { ... return -c; }
when any
if@p2(...) S2


@script:python depends on !bad0  !bad  !bad1  !bad2@
p1  r.p1;
p2  r.p2;
p3  r.p3;
@@

cocci.print_main(,p1)
cocci.print_secs(,p2)
cocci.print_secs(,p3)
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/27] mwifiex: main: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.function = f;
-t.data = d;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/mwifiex/main.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/main.c 
b/drivers/net/wireless/mwifiex/main.c
index d4d2223..53f4202 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -83,9 +83,8 @@ static int mwifiex_register(void *card, struct mwifiex_if_ops 
*if_ops,
}
mwifiex_init_lock_list(adapter);
 
-   init_timer(adapter-cmd_timer);
-   adapter-cmd_timer.function = mwifiex_cmd_timeout_func;
-   adapter-cmd_timer.data = (unsigned long) adapter;
+   setup_timer(adapter-cmd_timer, mwifiex_cmd_timeout_func,
+   (unsigned long)adapter);
 
return 0;
 

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/27] mwifiex: tdls: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.function = f;
-t.data = d;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/mwifiex/tdls.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/tdls.c 
b/drivers/net/wireless/mwifiex/tdls.c
index 22884b4..5a64681 100644
--- a/drivers/net/wireless/mwifiex/tdls.c
+++ b/drivers/net/wireless/mwifiex/tdls.c
@@ -1367,9 +1367,8 @@ void mwifiex_check_auto_tdls(unsigned long context)
 
 void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv)
 {
-   init_timer(priv-auto_tdls_timer);
-   priv-auto_tdls_timer.function = mwifiex_check_auto_tdls;
-   priv-auto_tdls_timer.data = (unsigned long)priv;
+   setup_timer(priv-auto_tdls_timer, mwifiex_check_auto_tdls,
+   (unsigned long)priv);
priv-auto_tdls_timer_active = true;
mod_timer(priv-auto_tdls_timer,
  jiffies + msecs_to_jiffies(MWIFIEX_TIMER_10S));

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/27] iwl3945: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/iwlegacy/3945-mac.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c 
b/drivers/net/wireless/iwlegacy/3945-mac.c
index dc1d20c..e566580 100644
--- a/drivers/net/wireless/iwlegacy/3945-mac.c
+++ b/drivers/net/wireless/iwlegacy/3945-mac.c
@@ -3429,9 +3429,7 @@ il3945_setup_deferred_work(struct il_priv *il)
 
il3945_hw_setup_deferred_work(il);
 
-   init_timer(il-watchdog);
-   il-watchdog.data = (unsigned long)il;
-   il-watchdog.function = il_bg_watchdog;
+   setup_timer(il-watchdog, il_bg_watchdog, (unsigned long)il);
 
tasklet_init(il-irq_tasklet,
 (void (*)(unsigned long))il3945_irq_tasklet,

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/27] mwifiex: 11n_rxreorder: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.function = f;
-t.data = d;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/mwifiex/11n_rxreorder.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mwifiex/11n_rxreorder.c 
b/drivers/net/wireless/mwifiex/11n_rxreorder.c
index d73fda3..f33dc81 100644
--- a/drivers/net/wireless/mwifiex/11n_rxreorder.c
+++ b/drivers/net/wireless/mwifiex/11n_rxreorder.c
@@ -391,10 +391,8 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private 
*priv, u8 *ta,
new_node-timer_context.priv = priv;
new_node-timer_context.timer_is_set = false;
 
-   init_timer(new_node-timer_context.timer);
-   new_node-timer_context.timer.function = mwifiex_flush_data;
-   new_node-timer_context.timer.data =
-   (unsigned long) new_node-timer_context;
+   setup_timer(new_node-timer_context.timer, mwifiex_flush_data,
+   (unsigned long)new_node-timer_context);
 
for (i = 0; i  win_size; ++i)
new_node-rx_reorder_ptr[i] = NULL;

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/27] iwlwifi: dvm: tt: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/iwlwifi/dvm/tt.c |   13 -
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/dvm/tt.c 
b/drivers/net/wireless/iwlwifi/dvm/tt.c
index acb981a..c4736c8 100644
--- a/drivers/net/wireless/iwlwifi/dvm/tt.c
+++ b/drivers/net/wireless/iwlwifi/dvm/tt.c
@@ -612,15 +612,10 @@ void iwl_tt_initialize(struct iwl_priv *priv)
memset(tt, 0, sizeof(struct iwl_tt_mgmt));
 
tt-state = IWL_TI_0;
-   init_timer(priv-thermal_throttle.ct_kill_exit_tm);
-   priv-thermal_throttle.ct_kill_exit_tm.data = (unsigned long)priv;
-   priv-thermal_throttle.ct_kill_exit_tm.function =
-   iwl_tt_check_exit_ct_kill;
-   init_timer(priv-thermal_throttle.ct_kill_waiting_tm);
-   priv-thermal_throttle.ct_kill_waiting_tm.data =
-   (unsigned long)priv;
-   priv-thermal_throttle.ct_kill_waiting_tm.function =
-   iwl_tt_ready_for_ct_kill;
+   setup_timer(priv-thermal_throttle.ct_kill_exit_tm,
+   iwl_tt_check_exit_ct_kill, (unsigned long)priv);
+   setup_timer(priv-thermal_throttle.ct_kill_waiting_tm,
+   iwl_tt_ready_for_ct_kill, (unsigned long)priv);
/* setup deferred ct kill work */
INIT_WORK(priv-tt_work, iwl_bg_tt_work);
INIT_WORK(priv-ct_enter, iwl_bg_ct_enter);

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/27] iwlwifi: dvm: main: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/iwlwifi/dvm/main.c |   10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c 
b/drivers/net/wireless/iwlwifi/dvm/main.c
index 0b7f46f..75ec691 100644
--- a/drivers/net/wireless/iwlwifi/dvm/main.c
+++ b/drivers/net/wireless/iwlwifi/dvm/main.c
@@ -1011,13 +1011,11 @@ static void iwl_setup_deferred_work(struct iwl_priv 
*priv)
if (priv-lib-bt_params)
iwlagn_bt_setup_deferred_work(priv);
 
-   init_timer(priv-statistics_periodic);
-   priv-statistics_periodic.data = (unsigned long)priv;
-   priv-statistics_periodic.function = iwl_bg_statistics_periodic;
+   setup_timer(priv-statistics_periodic, iwl_bg_statistics_periodic,
+   (unsigned long)priv);
 
-   init_timer(priv-ucode_trace);
-   priv-ucode_trace.data = (unsigned long)priv;
-   priv-ucode_trace.function = iwl_bg_ucode_trace;
+   setup_timer(priv-ucode_trace, iwl_bg_ucode_trace,
+   (unsigned long)priv);
 }
 
 void iwl_cancel_deferred_work(struct iwl_priv *priv)

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/27] cw1200: main: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/cw1200/main.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/cw1200/main.c 
b/drivers/net/wireless/cw1200/main.c
index 3e78cc3..fa965ee 100644
--- a/drivers/net/wireless/cw1200/main.c
+++ b/drivers/net/wireless/cw1200/main.c
@@ -374,9 +374,8 @@ static struct ieee80211_hw *cw1200_init_common(const u8 
*macaddr,
INIT_WORK(priv-update_filtering_work, cw1200_update_filtering_work);
INIT_WORK(priv-set_beacon_wakeup_period_work,
  cw1200_set_beacon_wakeup_period_work);
-   init_timer(priv-mcast_timeout);
-   priv-mcast_timeout.data = (unsigned long)priv;
-   priv-mcast_timeout.function = cw1200_mcast_timeout;
+   setup_timer(priv-mcast_timeout, cw1200_mcast_timeout,
+   (unsigned long)priv);
 
if (cw1200_queue_stats_init(priv-tx_queue_stats,
CW1200_LINK_ID_MAX,

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/27] ath6kl: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.function = f;
-t.data = d;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/ath/ath6kl/txrx.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/txrx.c 
b/drivers/net/wireless/ath/ath6kl/txrx.c
index 40432fe..3bc3aa7 100644
--- a/drivers/net/wireless/ath/ath6kl/txrx.c
+++ b/drivers/net/wireless/ath/ath6kl/txrx.c
@@ -1757,9 +1757,7 @@ void aggr_conn_init(struct ath6kl_vif *vif, struct 
aggr_info *aggr_info,
 
aggr_conn-aggr_sz = AGGR_SZ_DEFAULT;
aggr_conn-dev = vif-ndev;
-   init_timer(aggr_conn-timer);
-   aggr_conn-timer.function = aggr_timeout;
-   aggr_conn-timer.data = (unsigned long) aggr_conn;
+   setup_timer(aggr_conn-timer, aggr_timeout, (unsigned long)aggr_conn);
aggr_conn-aggr_info = aggr_info;
 
aggr_conn-timer_scheduled = false;

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/27] cw1200: queue: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/cw1200/queue.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/wireless/cw1200/queue.c 
b/drivers/net/wireless/cw1200/queue.c
index 9c3925f..0ba5ef9 100644
--- a/drivers/net/wireless/cw1200/queue.c
+++ b/drivers/net/wireless/cw1200/queue.c
@@ -179,9 +179,7 @@ int cw1200_queue_init(struct cw1200_queue *queue,
INIT_LIST_HEAD(queue-pending);
INIT_LIST_HEAD(queue-free_pool);
spin_lock_init(queue-lock);
-   init_timer(queue-gc);
-   queue-gc.data = (unsigned long)queue;
-   queue-gc.function = cw1200_queue_gc;
+   setup_timer(queue-gc, cw1200_queue_gc, (unsigned long)queue);
 
queue-pool = kzalloc(sizeof(struct cw1200_queue_item) * capacity,
GFP_KERNEL);

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 8/27] wireless: cw1200: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/cw1200/pm.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/cw1200/pm.c b/drivers/net/wireless/cw1200/pm.c
index 6907c8f..d2202ae 100644
--- a/drivers/net/wireless/cw1200/pm.c
+++ b/drivers/net/wireless/cw1200/pm.c
@@ -101,9 +101,8 @@ int cw1200_pm_init(struct cw1200_pm_state *pm,
 {
spin_lock_init(pm-lock);
 
-   init_timer(pm-stay_awake);
-   pm-stay_awake.data = (unsigned long)pm;
-   pm-stay_awake.function = cw1200_pm_stay_awake_tmo;
+   setup_timer(pm-stay_awake, cw1200_pm_stay_awake_tmo,
+   (unsigned long)pm);
 
return 0;
 }

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/27] iwl4965: Use setup_timer

2014-12-26 Thread Julia Lawall
Convert a call to init_timer and accompanying intializations of
the timer's data and function fields to a call to setup_timer.

A simplified version of the semantic match that fixes this problem is as
follows: (http://coccinelle.lip6.fr/)

// smpl
@@
expression t,f,d;
@@

-init_timer(t);
+setup_timer(t,f,d);
-t.data = d;
-t.function = f;
// /smpl

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
 drivers/net/wireless/iwlegacy/4965-mac.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c 
b/drivers/net/wireless/iwlegacy/4965-mac.c
index 2748fde..976f65f 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -6247,13 +6247,10 @@ il4965_setup_deferred_work(struct il_priv *il)
 
INIT_WORK(il-txpower_work, il4965_bg_txpower_work);
 
-   init_timer(il-stats_periodic);
-   il-stats_periodic.data = (unsigned long)il;
-   il-stats_periodic.function = il4965_bg_stats_periodic;
+   setup_timer(il-stats_periodic, il4965_bg_stats_periodic,
+   (unsigned long)il);
 
-   init_timer(il-watchdog);
-   il-watchdog.data = (unsigned long)il;
-   il-watchdog.function = il_bg_watchdog;
+   setup_timer(il-watchdog, il_bg_watchdog, (unsigned long)il);
 
tasklet_init(il-irq_tasklet,
 (void (*)(unsigned long))il4965_irq_tasklet,

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/27] Use setup_timer

2014-12-26 Thread Julia Lawall
These patches group a call to init_timer and initialization of the function
and data fields into a call to setup_timer.  Is there is no initialization
of the data field before add_timer is called, the the data value is set to
0UL.  If the data value has a cast to something other than unsigned long,
it is changes to a cast to unsigned long, which is the type of the data
field.

The semantic patch that performs this change is shown below
(http://coccinelle.lip6.fr/).  This semantic patch is fairly restrictive on
what appears between the init_timer call and the two field initializations,
to ensure that the there is no code that the initializations depend on.

// smpl
@@
expression t,d,f,e1,e2;
identifier x1,x2;
statement S1,S2;
@@

(
-t.data = d;
|
-t.function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S1
t.x1 = e1;
...
(
-t.data = d;
|
-t.function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S2
t.x2 = e2;
...
(
-t.data = d;
|
-t.function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)

// --

@@
expression t,d,f,e1,e2;
identifier x1,x2;
statement S1,S2;
@@

(
-t-data = d;
|
-t-function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S1
t-x1 = e1;
...
(
-t-data = d;
|
-t-function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)
... when != S2
t-x2 = e2;
...
(
-t-data = d;
|
-t-function = f;
|
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,d);
)

// -
// no initialization of data field

@@
expression t,d1,d2,f;
@@

(
-init_timer(t);
+setup_timer(t,f,0UL);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t.data = d1;
-t.function = f;
... when != t.data = d2;
add_timer(t);

@@
expression t,d,f,fn;
type T;
@@

-t.function = f;
... when != t.data
when != fn(...,(T)t,...)
(
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t.data = d;
add_timer(t);

// --

@@
expression t,d1,d2,f;
@@

(
-init_timer(t);
+setup_timer(t,f,0UL);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t-data = d1;
-t-function = f;
... when != t-data = d2;
add_timer(t);

@@
expression t,d,f,fn;
type T;
@@

-t-function = f;
... when != t.data
when != fn(...,(T)t,...)
(
-init_timer(t);
+setup_timer(t,f,d);
|
-init_timer_on_stack(t);
+setup_timer_on_stack(t,f,0UL);
)
... when != t-data = d;
add_timer(t);

// -
// change data field type

@@
expression d;
type T;
@@

(
setup_timer
|
setup_timer_on_stack
)
 (...,
(
  (unsigned long)d
|
- (T)
+ (unsigned long)
  d
)
 )
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/20] rtlwifi: rtl8821ae: fix misspelling of current function in string

2014-12-07 Thread Julia Lawall
Replace a misspelled function name by %s and then __func__.

8821 was written as 8812.

This was done using Coccinelle, including the use of Levenshtein distance,
as proposed by Rasmus Villemoes.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
The semantic patch is difficult to summarize, but is available in the cover
letter of this patch series.

 drivers/net/wireless/rtlwifi/rtl8821ae/dm.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c 
b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
index 9be1061..ba30b0d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
+++ b/drivers/net/wireless/rtlwifi/rtl8821ae/dm.c
@@ -2078,8 +2078,7 @@ void rtl8821ae_dm_txpwr_track_set_pwr(struct ieee80211_hw 
*hw,
if (rtldm-tx_rate != 0xFF)
tx_rate = rtl8821ae_hw_rate_to_mrate(hw, rtldm-tx_rate);
 
-   RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
-===rtl8812ae_dm_txpwr_track_set_pwr\n);
+   RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ===%s\n, __func__);
 
if (tx_rate != 0xFF) { /* Mimic Modify High Rate BBSwing Limit.*/
/*CCK*/
@@ -2128,7 +2127,7 @@ void rtl8821ae_dm_txpwr_track_set_pwr(struct ieee80211_hw 
*hw,
 
if (method == BBSWING) {
RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
-===rtl8812ae_dm_txpwr_track_set_pwr\n);
+===%s\n, __func__);
if (rf_path == RF90_PATH_A) {
final_swing_idx[RF90_PATH_A] =
(rtldm-ofdm_index[RF90_PATH_A] 
@@ -2260,7 +2259,8 @@ void rtl8821ae_dm_txpower_tracking_callback_thermalmeter(
rtldm-txpower_trackinginit = true;
 
RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
-===rtl8812ae_dm_txpower_tracking_callback_thermalmeter,\n 
pDM_Odm-BbSwingIdxCckBase: %d,pDM_Odm-BbSwingIdxOfdmBase[A]:%d, 
pDM_Odm-DefaultOfdmIndex: %d\n,
+===%s,\n pDM_Odm-BbSwingIdxCckBase: 
%d,pDM_Odm-BbSwingIdxOfdmBase[A]:%d, pDM_Odm-DefaultOfdmIndex: %d\n,
+__func__,
 rtldm-swing_idx_cck_base,
 rtldm-swing_idx_ofdm_base[RF90_PATH_A],
 rtldm-default_ofdm_index);
@@ -2539,8 +2539,7 @@ void rtl8821ae_dm_txpower_tracking_callback_thermalmeter(
}
}
 
-   RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
-===rtl8812ae_dm_txpower_tracking_callback_thermalmeter\n);
+   RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ===%s\n, __func__);
 }
 
 void rtl8821ae_dm_check_txpower_tracking_thermalmeter(struct ieee80211_hw *hw)
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/20] hostap_cs: fix misspelling of current function in string

2014-12-07 Thread Julia Lawall
Replace a misspelled function name by %s and then __func__.

This was done using Coccinelle, including the use of Levenshtein distance,
as proposed by Rasmus Villemoes.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
The semantic patch is difficult to summarize, but is available in the cover
letter of this patch series.

 drivers/net/wireless/hostap/hostap_cs.c |   15 +--
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/hostap/hostap_cs.c 
b/drivers/net/wireless/hostap/hostap_cs.c
index b6ec519..50033aa 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -381,18 +381,15 @@ static void prism2_pccard_genesis_reset(local_info_t 
*local, int hcr)
 
res = pcmcia_read_config_byte(hw_priv-link, CISREG_COR, old_cor);
if (res != 0) {
-   printk(KERN_DEBUG prism2_pccard_genesis_sreset failed 1 
-  (%d)\n, res);
+   printk(KERN_DEBUG %s failed 1 (%d)\n, __func__, res);
return;
}
-   printk(KERN_DEBUG prism2_pccard_genesis_sreset: original COR %02x\n,
-   old_cor);
+   printk(KERN_DEBUG %s: original COR %02x\n, __func__, old_cor);
 
res = pcmcia_write_config_byte(hw_priv-link, CISREG_COR,
old_cor | COR_SOFT_RESET);
if (res != 0) {
-   printk(KERN_DEBUG prism2_pccard_genesis_sreset failed 2 
-  (%d)\n, res);
+   printk(KERN_DEBUG %s failed 2 (%d)\n, __func__, res);
return;
}
 
@@ -401,8 +398,7 @@ static void prism2_pccard_genesis_reset(local_info_t 
*local, int hcr)
/* Setup Genesis mode */
res = pcmcia_write_config_byte(hw_priv-link, CISREG_CCSR, hcr);
if (res != 0) {
-   printk(KERN_DEBUG prism2_pccard_genesis_sreset failed 3 
-  (%d)\n, res);
+   printk(KERN_DEBUG %s failed 3 (%d)\n, __func__, res);
return;
}
mdelay(10);
@@ -410,8 +406,7 @@ static void prism2_pccard_genesis_reset(local_info_t 
*local, int hcr)
res = pcmcia_write_config_byte(hw_priv-link, CISREG_COR,
old_cor  ~COR_SOFT_RESET);
if (res != 0) {
-   printk(KERN_DEBUG prism2_pccard_genesis_sreset failed 4 
-  (%d)\n, res);
+   printk(KERN_DEBUG %s failed 4 (%d)\n, __func__, res);
return;
}
 

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/20] zd1211rw: fix misspelling of current function in string

2014-12-07 Thread Julia Lawall
Replace a misspelled function name by %s and then __func__.

This was done using Coccinelle, including the use of Levenshtein distance,
as proposed by Rasmus Villemoes.

Signed-off-by: Julia Lawall julia.law...@lip6.fr

---
The semantic patch is difficult to summarize, but is available in the cover
letter of this patch series.

 drivers/net/wireless/zd1211rw/zd_chip.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c 
b/drivers/net/wireless/zd1211rw/zd_chip.c
index 73a49b8..07b94ed 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -129,7 +129,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, 
const zd_addr_t *addr
r = zd_ioread16v_locked(chip, v16, a16, count16);
if (r) {
dev_dbg_f(zd_chip_dev(chip),
- error: zd_ioread16v_locked. Error number %d\n, r);
+ error: %s. Error number %d\n, __func__, r);
return r;
}
 
@@ -256,8 +256,8 @@ int zd_iowrite32a_locked(struct zd_chip *chip,
if (r) {
zd_usb_iowrite16v_async_end(chip-usb, 0);
dev_dbg_f(zd_chip_dev(chip),
-   error _zd_iowrite32v_locked.
-Error number %d\n, r);
+   error _%s. Error number %d\n, __func__,
+   r);
return r;
}
}

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/20] fix misspelling of current function in string

2014-12-07 Thread Julia Lawall
These patches replace what appears to be a reference to the name of the
current function but is misspelled in some way by either the name of the
function itself, or by %s and then __func__ in an argument list.

// smpl
// sudo apt-get install python-pip
// sudo pip install python-Levenshtein
// spatch requires the argument --in-place

virtual after_start

@initialize:ocaml@
@@

let extensible_functions = ref ([] : string list)
let restarted = ref false

let restart _ =
  restarted := true;
  let it = new iteration() in
  it#add_virtual_rule After_start;
  Printf.eprintf restarting\n;
  it#register()

@initialize:python@
@@
import re
from Levenshtein import distance
mindist = 1 // 1 to find only misspellings
maxdist = 2
ignore_leading = True

// -

@r0@
constant char [] c;
identifier f;
@@

f(...,c,...)

@script:ocaml@
c  r0.c;
f  r0.f;
@@

(if not !restarted then restart());
match Str.split_delim (Str.regexp %) c with
  _::_::_ -
if not (List.mem f !extensible_functions)
then extensible_functions := f :: !extensible_functions
| _ - ()

// -

@r depends on after_start@
constant char [] c;
position p;
identifier f;
@@

f(...,c@p,...)

@script:python flt@
c  r.c;
p  r.p;
matched;
@@

func = p[0].current_element
wpattern = [a-zA-Z_][a-zA-Z0-9_]*
if ignore_leading:
   func = func.strip(_)
   wpattern = [a-zA-Z][a-zA-Z0-9_]*
lf = len(func)
cocci.include_match(False)
// ignore extremely short function names
if lf  3:
   words = [w for w in re.findall(wpattern, c) if abs(len(w) - lf) = maxdist]
   for w in words:
   d = distance(w, func) 
   if mindist = d and d = maxdist:
  coccinelle.matched = w
  cocci.include_match(True)
  //print %s:%d:%s():%d: %s % (p[0].file, int(p[0].line), func, d, c)
  break

@script:ocaml r2@
c  r.c;
f  r.f;
matched  flt.matched;
fixed;
@@

let pieces = Str.split_delim (Str.regexp_string matched) c in
match pieces with
  [before;after] -
let preceeding =
  List.length(Str.split (Str.regexp_string %) before)  1 in
if preceeding
then Coccilib.include_match false
else
  if List.mem f !extensible_functions
  then fixed := before ^ %s ^ after
  else Coccilib.include_match false
| _ - Coccilib.include_match false

@changed1@
constant char [] r.c;
identifier r2.fixed;
position r.p;
identifier r.f;
@@

f(...,
-c@p
+fixed,__func__
 ,...)

// ---

@s depends on after_start@
constant char [] c;
position p;
identifier f;
@@

f(...,c@p,...)

@script:python flt2@
c  s.c;
p  s.p;
matched;
@@

func = p[0].current_element
wpattern = [a-zA-Z_][a-zA-Z0-9_]*
if ignore_leading:
   func = func.strip(_)
   wpattern = [a-zA-Z][a-zA-Z0-9_]*
lf = len(func)
cocci.include_match(False)
// ignore extremely short function names
if lf  3:
   words = [w for w in re.findall(wpattern, c) if abs(len(w) - lf) = maxdist]
   for w in words:
   d = distance(w, func) 
   if mindist = d and d = maxdist:
  coccinelle.matched = w
  cocci.include_match(True)
  //print %s:%d:%s():%d: %s % (p[0].file, int(p[0].line), func, d, c)
  break

@script:ocaml s2@
c  s.c;
f  s.f;
p  s.p;
matched  flt2.matched;
fixed;
@@

let ce = (List.hd p).current_element in
let pieces = Str.split_delim (Str.regexp_string matched) c in
match pieces with
  [before;after] -
let preceeding =
  List.length(Str.split (Str.regexp_string %) before)  1 in
if preceeding
then Coccilib.include_match false
else
  if List.mem f !extensible_functions
  then Coccilib.include_match false
  else fixed := before ^ ce ^ after
| _ - Coccilib.include_match false

@changed2@
constant char [] s.c;
identifier s2.fixed;
position s.p;
identifier s.f;
@@

f(...,
-c@p
+fixed
 ,...)
// /smpl

--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 0/20] fix misspelling of current function in string

2014-12-07 Thread Julia Lawall
On Mon, 8 Dec 2014, Julian Calaby wrote:

 Hi Julia,
 
 On Mon, Dec 8, 2014 at 6:20 AM, Julia Lawall julia.law...@lip6.fr wrote:
  These patches replace what appears to be a reference to the name of the
  current function but is misspelled in some way by either the name of the
  function itself, or by %s and then __func__ in an argument list.
 
 Would there be any value in doing this for _all_ cases where the
 function name is written in a format string?

Probably.  But there are a lot of them.  Even for the misspellings, I have 
only don about 1/3 of the cases.

On the other hand, the misspelling have to be checked carefully, because a 
misspelling of one thing could be the correct spelling of the thing thst 
was actually intended.

Joe, however, points out that a lot of these prints are just for function 
tracing, and could be removed.  I worked on another semantic patch that 
tries to do that.  It might be better to remove those prints completely, 
rather than sending one patch to transform them and then one patch to 
remove them after that.  That is why for this series I did only the ones 
where there was actually a problem.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch] staging: rtl8723au: incorrect use of ether_addr_copy()

2014-10-08 Thread Julia Lawall


On Wed, 8 Oct 2014, Dan Carpenter wrote:

 On Wed, Oct 08, 2014 at 05:26:11AM -0700, Joe Perches wrote:
  On Wed, 2014-10-08 at 13:40 +0300, Dan Carpenter wrote:
   The return from myid() isn't aligned correctly for ether_addr_copy().
 
  Hey Dan.
 
  Actual evidence showing ether_addr_copy conversions
  may not always be wise.
 
  How did you find them?

 I was just trying to see how common these kinds of bugs are.  It didn't
 take long to find, but my impression is that they are rare and I got
 lucky.  These kinds of bugs are tricky to find and we don't have any
 tools for it.

Couldn't you just use your favorite matching tool, collect the file names,
compile them, run pahole, and process the output in some way?  It doesn't
give a complete analysis (you don't find all problems), but if you find a
problem it is a real problem.

julia
--
To unsubscribe from this list: send the line unsubscribe linux-wireless in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html