[PATCH][next] staging: rtl8188eu: Replace one-element array with flexible-array in struct ndis_802_11_var_ie

2021-03-03 Thread Gustavo A. R. Silva
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].

Use flexible-array member in struct ndis_802_11_var_ie, instead of
one-element array.

Also, this helps with the ongoing efforts to enable -Warray-bounds by
fixing the following warning:

drivers/staging/rtl8188eu/core/rtw_wlan_util.c: In function ‘HT_caps_handler’:
drivers/staging/rtl8188eu/core/rtw_wlan_util.c:665:65: warning: array subscript 
2 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} [-Warray-bounds]
  665 |if ((pmlmeinfo->HT_caps.ampdu_params_info & 0x3) > (pIE->data[i] & 
0x3))
  |~^~~

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] 
https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8188eu/include/wlan_bssdef.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h 
b/drivers/staging/rtl8188eu/include/wlan_bssdef.h
index 2c184ce8746b..350bbf9057b8 100644
--- a/drivers/staging/rtl8188eu/include/wlan_bssdef.h
+++ b/drivers/staging/rtl8188eu/include/wlan_bssdef.h
@@ -64,7 +64,7 @@ struct ndis_802_11_fixed_ie {
 struct ndis_802_11_var_ie {
u8  ElementID;
u8  Length;
-   u8  data[1];
+   u8  data[];
 };
 
 /*
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/2] staging: rtl8192e: Pass array value to memcpy instead of struct pointer

2021-02-20 Thread Gustavo A. R. Silva



On 2/20/21 12:21, Atul Gopinathan wrote:
> The variable "info_element" is of the following type:
> struct rtllib_info_element *info_element
> 
> rtllib_info_element is a struct containing the following fields as
> defined in drivers/staging/rtl8192e/rtllib.h:
> 
> struct rtllib_info_element {
> u8 id;
> u8 len;
> u8 data[];
> } __packed;
> 
> The following code of interest (to which this patch applies) is
> supposed to check if the "info_element->len" is greater than 4 and
> equal to 6, if this is satisfied then, the last two bytes (the
> 4th and 5th index of u8 "data" array) are copied into
> "network->CcxRmState".
> 
> Currently the code uses "memcpy()" with the source as
> "_element[4]" which would copy in wrong and unintended
> information.
> 
> This patch rectifies this error by using "_element->data[4]" which
> rightly copies the last two bytes as the required state information.

You should include a 'Fixes' tag for this.

Also, is this code in -stable? If so, then tag this patch for stable, please.

Thanks
--
Gustavo

> 
> Signed-off-by: Atul Gopinathan 
> ---
>  drivers/staging/rtl8192e/rtllib_rx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib_rx.c 
> b/drivers/staging/rtl8192e/rtllib_rx.c
> index 66c135321da4..15bbb63ca130 100644
> --- a/drivers/staging/rtl8192e/rtllib_rx.c
> +++ b/drivers/staging/rtl8192e/rtllib_rx.c
> @@ -1963,15 +1963,15 @@ static void rtllib_parse_mife_generic(struct 
> rtllib_device *ieee,
>  
>   if (info_element->len > 4 &&
>   info_element->data[0] == 0x00 &&
>   info_element->data[1] == 0x40 &&
>   info_element->data[2] == 0x96 &&
>   info_element->data[3] == 0x01) {
>   if (info_element->len == 6) {
> - memcpy(network->CcxRmState, _element[4], 2);
> + memcpy(network->CcxRmState, _element->data[4], 2);
>   if (network->CcxRmState[0] != 0)
>   network->bCcxRmEnable = true;
>   else
>   network->bCcxRmEnable = false;
>   network->MBssidMask = network->CcxRmState[1] & 0x07;
>   if (network->MBssidMask != 0) {
>   network->bMBssidValid = true;
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH][next] staging: rtl8723bs: Replace one-element array with flexible-array member in struct ndis_80211_var_ie

2021-02-11 Thread Gustavo A. R. Silva


On 2/11/21 05:06, Dan Carpenter wrote:
> On Wed, Feb 10, 2021 at 04:49:37PM -0600, Gustavo A. R. Silva wrote:
>> There is a regular need in the kernel to provide a way to declare having
>> a dynamically sized set of trailing elements in a structure. Kernel code
>> should always use “flexible array members”[1] for these cases. The older
>> style of one-element or zero-length arrays should no longer be used[2].
>>
>> Refactor the code according to the use of a flexible-array member in
>> struct ndis_80211_var_ie, instead of a one-element array.
>>
>> Also, this helps with the ongoing efforts to enable -Warray-bounds and
>> fix the following warnings:
>>
>>   CC [M]  drivers/staging/rtl8723bs/core/rtw_wlan_util.o
>> In file included from ./drivers/staging/rtl8723bs/include/drv_types.h:20,
>>  from drivers/staging/rtl8723bs/core/rtw_wlan_util.c:9:
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c: In function 
>> ‘HT_caps_handler’:
>> ./drivers/staging/rtl8723bs/include/basic_types.h:108:11: warning: array 
>> subscript 1 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
>> [-Warray-bounds]
>>   108 |  (EF1BYTE(*((u8 *)(__pstart
>>   |   ^
>> ./drivers/staging/rtl8723bs/include/basic_types.h:42:8: note: in definition 
>> of macro ‘EF1BYTE’
>>42 |  ((u8)(_val))
>>   |^~~~
>> ./drivers/staging/rtl8723bs/include/basic_types.h:127:4: note: in expansion 
>> of macro ‘LE_P1BYTE_TO_HOST_1BYTE’
>>   127 |   (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \
>>   |^~~
>> ./drivers/staging/rtl8723bs/include/rtw_ht.h:97:55: note: in expansion of 
>> macro ‘LE_BITS_TO_1BYTE’
>>97 | #define GET_HT_CAPABILITY_ELE_RX_STBC(_pEleStart) 
>> LE_BITS_TO_1BYTE((_pEleStart)+1, 0, 2)
>>   |   
>> ^~~~
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1104:58: note: in expansion 
>> of macro ‘GET_HT_CAPABILITY_ELE_RX_STBC’
>>  1104 |   if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && 
>> GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data)) {
>>   |  
>> ^
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1051:75: warning: array 
>> subscript 2 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
>> [-Warray-bounds]
>>  1051 |if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > 
>> (pIE->data[i] & 0x3))
>>   |  
>> ~^~~
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c: In function ‘check_assoc_AP’:
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1606:19: warning: array 
>> subscript 4 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
>> [-Warray-bounds]
>>  1606 |  if (pIE->data[4] == 1)
>>   |  ~^~~
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1609:20: warning: array 
>> subscript 5 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
>> [-Warray-bounds]
>>  1609 |   if (pIE->data[5] & RT_HT_CAP_USE_92SE)
>>   |   ~^~~
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1613:19: warning: array 
>> subscript 5 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
>> [-Warray-bounds]
>>  1613 |  if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP)
>>   |  ~^~~
>> drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1617:20: warning: array 
>> subscript 6 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
>> [-Warray-bounds]
>>  1617 |   if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) {
>>   |   ~^~~
>>
>> [1] https://en.wikipedia.org/wiki/Flexible_array_member
>> [2] 
>> https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays
>>
>> Link: https://github.com/KSPP/linux/issues/79
>> Link: https://github.com/KSPP/linux/issues/109
>> Build-tested-by: kernel test robot 
>> Link: https://lore.kernel.org/lkml/602434b8.jc5doxj0bmhoxgil%25...@intel.com/
>> Signed-off-by: Gustavo A. R. Silva 
> 
> Looks okay to me.  I looked for potential issues with changing the
> sizeof the struct but couldn't find any.

Great. Yeah; that's one of the first things I look at when I make
these changes. Thanks for double checking. :)

> Reviewed-by: Dan Carpenter 

Thanks!
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: rtl8723bs: Replace one-element array with flexible-array member in struct ndis_80211_var_ie

2021-02-10 Thread Gustavo A. R. Silva
There is a regular need in the kernel to provide a way to declare having
a dynamically sized set of trailing elements in a structure. Kernel code
should always use “flexible array members”[1] for these cases. The older
style of one-element or zero-length arrays should no longer be used[2].

Refactor the code according to the use of a flexible-array member in
struct ndis_80211_var_ie, instead of a one-element array.

Also, this helps with the ongoing efforts to enable -Warray-bounds and
fix the following warnings:

  CC [M]  drivers/staging/rtl8723bs/core/rtw_wlan_util.o
In file included from ./drivers/staging/rtl8723bs/include/drv_types.h:20,
 from drivers/staging/rtl8723bs/core/rtw_wlan_util.c:9:
drivers/staging/rtl8723bs/core/rtw_wlan_util.c: In function ‘HT_caps_handler’:
./drivers/staging/rtl8723bs/include/basic_types.h:108:11: warning: array 
subscript 1 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
[-Warray-bounds]
  108 |  (EF1BYTE(*((u8 *)(__pstart
  |   ^
./drivers/staging/rtl8723bs/include/basic_types.h:42:8: note: in definition of 
macro ‘EF1BYTE’
   42 |  ((u8)(_val))
  |^~~~
./drivers/staging/rtl8723bs/include/basic_types.h:127:4: note: in expansion of 
macro ‘LE_P1BYTE_TO_HOST_1BYTE’
  127 |   (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \
  |^~~
./drivers/staging/rtl8723bs/include/rtw_ht.h:97:55: note: in expansion of macro 
‘LE_BITS_TO_1BYTE’
   97 | #define GET_HT_CAPABILITY_ELE_RX_STBC(_pEleStart) 
LE_BITS_TO_1BYTE((_pEleStart)+1, 0, 2)
  |   ^~~~
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1104:58: note: in expansion of 
macro ‘GET_HT_CAPABILITY_ELE_RX_STBC’
 1104 |   if (TEST_FLAG(phtpriv->stbc_cap, STBC_HT_ENABLE_TX) && 
GET_HT_CAPABILITY_ELE_RX_STBC(pIE->data)) {
  |  
^
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1051:75: warning: array 
subscript 2 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
[-Warray-bounds]
 1051 |if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > 
(pIE->data[i] & 0x3))
  |  
~^~~
drivers/staging/rtl8723bs/core/rtw_wlan_util.c: In function ‘check_assoc_AP’:
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1606:19: warning: array 
subscript 4 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
[-Warray-bounds]
 1606 |  if (pIE->data[4] == 1)
  |  ~^~~
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1609:20: warning: array 
subscript 5 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
[-Warray-bounds]
 1609 |   if (pIE->data[5] & RT_HT_CAP_USE_92SE)
  |   ~^~~
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1613:19: warning: array 
subscript 5 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
[-Warray-bounds]
 1613 |  if (pIE->data[5] & RT_HT_CAP_USE_SOFTAP)
  |  ~^~~
drivers/staging/rtl8723bs/core/rtw_wlan_util.c:1617:20: warning: array 
subscript 6 is above array bounds of ‘u8[1]’ {aka ‘unsigned char[1]’} 
[-Warray-bounds]
 1617 |   if (pIE->data[6] & RT_HT_CAP_USE_JAGUAR_BCUT) {
  |   ~^~~

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] 
https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays

Link: https://github.com/KSPP/linux/issues/79
Link: https://github.com/KSPP/linux/issues/109
Build-tested-by: kernel test robot 
Link: https://lore.kernel.org/lkml/602434b8.jc5doxj0bmhoxgil%25...@intel.com/
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8723bs/include/wlan_bssdef.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h 
b/drivers/staging/rtl8723bs/include/wlan_bssdef.h
index ea370b2bb8db..27cd2c5d90af 100644
--- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h
+++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h
@@ -68,7 +68,7 @@ struct ndis_802_11_fix_ie {
 struct ndis_80211_var_ie {
u8  ElementID;
u8  Length;
-   u8  data[1];
+   u8  data[];
 };
 
 /* Length is the 4 bytes multiples of the sum of
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-12-01 Thread Gustavo A. R. Silva
On Tue, Dec 01, 2020 at 12:52:27AM -0500, Martin K. Petersen wrote:
> 
> Gustavo,
> 
> > This series aims to fix almost all remaining fall-through warnings in
> > order to enable -Wimplicit-fallthrough for Clang.
> 
> Applied 20-22,54,120-124 to 5.11/scsi-staging, thanks.

Awesome! :)

Thanks, Martin.
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-24 Thread Gustavo A. R. Silva
On Mon, Nov 23, 2020 at 08:38:46PM +, Mark Brown wrote:
> On Fri, 20 Nov 2020 12:21:39 -0600, Gustavo A. R. Silva wrote:
> > This series aims to fix almost all remaining fall-through warnings in
> > order to enable -Wimplicit-fallthrough for Clang.
> > 
> > In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
> > add multiple break/goto/return/fallthrough statements instead of just
> > letting the code fall through to the next case.
> > 
> > [...]
> 
> Applied to
> 
>https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 
> for-next
> 
> Thanks!
> 
> [1/1] regulator: as3722: Fix fall-through warnings for Clang
>   commit: b52b417ccac4fae5b1f2ec4f1d46eb91e4493dc5

Thank you, Mark.
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-24 Thread Gustavo A. R. Silva
On Mon, Nov 23, 2020 at 04:03:45PM -0400, Jason Gunthorpe wrote:
> On Fri, Nov 20, 2020 at 12:21:39PM -0600, Gustavo A. R. Silva wrote:
> 
> >   IB/hfi1: Fix fall-through warnings for Clang
> >   IB/mlx4: Fix fall-through warnings for Clang
> >   IB/qedr: Fix fall-through warnings for Clang
> >   RDMA/mlx5: Fix fall-through warnings for Clang
> 
> I picked these four to the rdma tree, thanks

Awesome. :)

Thank you, Jason.
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva


Hi,

On 11/20/20 12:53, Jakub Kicinski wrote:
> On Fri, 20 Nov 2020 12:21:39 -0600 Gustavo A. R. Silva wrote:
>> This series aims to fix almost all remaining fall-through warnings in
>> order to enable -Wimplicit-fallthrough for Clang.
>>
>> In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
>> add multiple break/goto/return/fallthrough statements instead of just
>> letting the code fall through to the next case.
>>
>> Notice that in order to enable -Wimplicit-fallthrough for Clang, this
>> change[1] is meant to be reverted at some point. So, this patch helps
>> to move in that direction.
>>
>> Something important to mention is that there is currently a discrepancy
>> between GCC and Clang when dealing with switch fall-through to empty case
>> statements or to cases that only contain a break/continue/return
>> statement[2][3][4].
> 
> Are we sure we want to make this change? Was it discussed before?
> 
> Are there any bugs Clangs puritanical definition of fallthrough helped
> find?
> 
> IMVHO compiler warnings are supposed to warn about issues that could
> be bugs. Falling through to default: break; can hardly be a bug?!

The justification for this is explained in this same changelog text:

Now that the -Wimplicit-fallthrough option has been globally enabled[5],
any compiler should really warn on missing either a fallthrough annotation
or any of the other case-terminating statements (break/continue/return/
goto) when falling through to the next case statement. Making exceptions
to this introduces variation in case handling which may continue to lead
to bugs, misunderstandings, and a general lack of robustness. The point
of enabling options like -Wimplicit-fallthrough is to prevent human error
and aid developers in spotting bugs before their code is even built/
submitted/committed, therefore eliminating classes of bugs. So, in order
to really accomplish this, we should, and can, move in the direction of
addressing any error-prone scenarios and get rid of the unintentional
fallthrough bug-class in the kernel, entirely, even if there is some minor
redundancy. Better to have explicit case-ending statements than continue to
have exceptions where one must guess as to the right result. The compiler
will eliminate any actual redundancy.

Note that there is already a patch in mainline that addresses almost
40,000 of these issues[6].

[1] commit e2079e93f562c ("kbuild: Do not enable -Wimplicit-fallthrough for 
clang for now")
[2] ClangBuiltLinux#636
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432
[4] https://godbolt.org/z/xgkvIh
[5] commit a035d552a93b ("Makefile: Globally enable fall-through warning")
[6] commit 4169e889e588 ("include: jhash/signal: Fix fall-through warnings for 
Clang")

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva



On 11/20/20 12:28, Joe Perches wrote:
> On Fri, 2020-11-20 at 12:21 -0600, Gustavo A. R. Silva wrote:
>> Hi all,
>>
>> This series aims to fix almost all remaining fall-through warnings in
>> order to enable -Wimplicit-fallthrough for Clang.
>>
>> In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
>> add multiple break/goto/return/fallthrough statements instead of just
>> letting the code fall through to the next case.
>>
>> Notice that in order to enable -Wimplicit-fallthrough for Clang, this
>> change[1] is meant to be reverted at some point. So, this patch helps
>> to move in that direction.
> 
> This was a bit hard to parse for a second or three.
> 
> Thanks Gustavo.
> 
> How was this change done?

I audited case by case in order to determine the best fit for each
situation. Depending on the surrounding logic, sometimes it makes
more sense a goto or a fallthrough rather than merely a break.

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 128/141] staging: vt6656: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/vt6656/main_usb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/vt6656/main_usb.c 
b/drivers/staging/vt6656/main_usb.c
index 8bf851c53f4e..b90d3dab28b1 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -914,6 +914,7 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
 
vnt_mac_disable_keyentry(priv, key->hw_key_idx);
}
+   break;
 
default:
break;
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 127/141] staging: qlge: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/qlge/qlge_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c
index 27da386f9d87..c41b1373dcf8 100644
--- a/drivers/staging/qlge/qlge_main.c
+++ b/drivers/staging/qlge/qlge_main.c
@@ -1385,6 +1385,7 @@ static void ql_categorize_rx_err(struct ql_adapter *qdev, 
u8 rx_err,
break;
case IB_MAC_IOCB_RSP_ERR_CRC:
stats->rx_crc_err++;
+   break;
default:
break;
}
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 094/141] media: atomisp: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning
by explicitly adding a break statement instead of letting the code fall
through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/media/atomisp/pci/runtime/isys/src/rx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/media/atomisp/pci/runtime/isys/src/rx.c 
b/drivers/staging/media/atomisp/pci/runtime/isys/src/rx.c
index b4813cd50daa..4a18da6bf0c1 100644
--- a/drivers/staging/media/atomisp/pci/runtime/isys/src/rx.c
+++ b/drivers/staging/media/atomisp/pci/runtime/isys/src/rx.c
@@ -368,6 +368,7 @@ static mipi_predictor_t 
sh_css_csi2_compression_type_2_mipi_predictor(
break;
case IA_CSS_CSI2_COMPRESSION_TYPE_2:
predictor = MIPI_PREDICTOR_TYPE2 - 1;
+   break;
default:
break;
}
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 024/141] staging: vt6655: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding multiple break statements instead of just
letting the code fall through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/vt6655/device_main.c | 1 +
 drivers/staging/vt6655/rxtx.c| 2 ++
 2 files changed, 3 insertions(+)

diff --git a/drivers/staging/vt6655/device_main.c 
b/drivers/staging/vt6655/device_main.c
index 09ab6d6f2429..0adbd2b67df0 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -1579,6 +1579,7 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum 
set_key_cmd cmd,
case DISABLE_KEY:
if (test_bit(key->hw_key_idx, >key_entry_inuse))
clear_bit(key->hw_key_idx, >key_entry_inuse);
+   break;
default:
break;
}
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 477d19314634..1a64152de189 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -1004,6 +1004,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned 
char byPktType,
switch (info->control.hw_key->cipher) {
case WLAN_CIPHER_SUITE_CCMP:
cbMICHDR = sizeof(struct vnt_mic_hdr);
+   break;
default:
break;
}
@@ -1318,6 +1319,7 @@ int vnt_generate_fifo_header(struct vnt_private *priv, 
u32 dma_idx,
break;
case WLAN_CIPHER_SUITE_CCMP:
tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES);
+   break;
default:
break;
}
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 023/141] staging: rtl8723bs: core: Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
warnings by explicitly adding multiple break statements instead of just
letting the code fall through to the next case.

Link: https://github.com/KSPP/linux/issues/115
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8723bs/core/rtw_cmd.c   | 1 +
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c  | 1 +
 drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c 
b/drivers/staging/rtl8723bs/core/rtw_cmd.c
index 2abe205e3453..232661e6a5c9 100644
--- a/drivers/staging/rtl8723bs/core/rtw_cmd.c
+++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c
@@ -1487,6 +1487,7 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 
lps_ctrl_type)
break;
case LPS_CTRL_TRAFFIC_BUSY:
LPS_Leave(padapter, "LPS_CTRL_TRAFFIC_BUSY");
+   break;
default:
break;
}
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index b912ad2f4b72..ea44d653a591 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1708,6 +1708,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union 
recv_frame *precv_frame)
 
case _ERPINFO_IE_:
ERP_IE_handler(padapter, pIE);
+   break;
 
default:
break;
diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c 
b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
index 372ce17c3569..2b13c683ba5c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
+++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c
@@ -1505,6 +1505,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter)
case _RSN_IE_2_:
if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 
4))
return true;
+   break;
 
default:
break;
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 000/141] Fix fall-through warnings for Clang

2020-11-20 Thread Gustavo A. R. Silva
Hi all,

This series aims to fix almost all remaining fall-through warnings in
order to enable -Wimplicit-fallthrough for Clang.

In preparation to enable -Wimplicit-fallthrough for Clang, explicitly
add multiple break/goto/return/fallthrough statements instead of just
letting the code fall through to the next case.

Notice that in order to enable -Wimplicit-fallthrough for Clang, this
change[1] is meant to be reverted at some point. So, this patch helps
to move in that direction.

Something important to mention is that there is currently a discrepancy
between GCC and Clang when dealing with switch fall-through to empty case
statements or to cases that only contain a break/continue/return
statement[2][3][4].

Now that the -Wimplicit-fallthrough option has been globally enabled[5],
any compiler should really warn on missing either a fallthrough annotation
or any of the other case-terminating statements (break/continue/return/
goto) when falling through to the next case statement. Making exceptions
to this introduces variation in case handling which may continue to lead
to bugs, misunderstandings, and a general lack of robustness. The point
of enabling options like -Wimplicit-fallthrough is to prevent human error
and aid developers in spotting bugs before their code is even built/
submitted/committed, therefore eliminating classes of bugs. So, in order
to really accomplish this, we should, and can, move in the direction of
addressing any error-prone scenarios and get rid of the unintentional
fallthrough bug-class in the kernel, entirely, even if there is some minor
redundancy. Better to have explicit case-ending statements than continue to
have exceptions where one must guess as to the right result. The compiler
will eliminate any actual redundancy.

Note that there is already a patch in mainline that addresses almost
40,000 of these issues[6].

I'm happy to carry this whole series in my own tree if people are OK
with it. :)

[1] commit e2079e93f562c ("kbuild: Do not enable -Wimplicit-fallthrough for 
clang for now")
[2] ClangBuiltLinux#636
[3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91432
[4] https://godbolt.org/z/xgkvIh
[5] commit a035d552a93b ("Makefile: Globally enable fall-through warning")
[6] commit 4169e889e588 ("include: jhash/signal: Fix fall-through warnings for 
Clang")

Thanks!

Gustavo A. R. Silva (141):
  afs: Fix fall-through warnings for Clang
  ASoC: codecs: Fix fall-through warnings for Clang
  cifs: Fix fall-through warnings for Clang
  drm/amdgpu: Fix fall-through warnings for Clang
  drm/radeon: Fix fall-through warnings for Clang
  gfs2: Fix fall-through warnings for Clang
  gpio: Fix fall-through warnings for Clang
  IB/hfi1: Fix fall-through warnings for Clang
  igb: Fix fall-through warnings for Clang
  ima: Fix fall-through warnings for Clang
  ipv4: Fix fall-through warnings for Clang
  ixgbe: Fix fall-through warnings for Clang
  media: dvb-frontends: Fix fall-through warnings for Clang
  media: usb: dvb-usb-v2: Fix fall-through warnings for Clang
  netfilter: Fix fall-through warnings for Clang
  nfsd: Fix fall-through warnings for Clang
  nfs: Fix fall-through warnings for Clang
  qed: Fix fall-through warnings for Clang
  qlcnic: Fix fall-through warnings for Clang
  scsi: aic7xxx: Fix fall-through warnings for Clang
  scsi: aic94xx: Fix fall-through warnings for Clang
  scsi: bfa: Fix fall-through warnings for Clang
  staging: rtl8723bs: core: Fix fall-through warnings for Clang
  staging: vt6655: Fix fall-through warnings for Clang
  bnxt_en: Fix fall-through warnings for Clang
  ceph: Fix fall-through warnings for Clang
  drbd: Fix fall-through warnings for Clang
  drm/amd/display: Fix fall-through warnings for Clang
  e1000: Fix fall-through warnings for Clang
  ext2: Fix fall-through warnings for Clang
  ext4: Fix fall-through warnings for Clang
  floppy: Fix fall-through warnings for Clang
  fm10k: Fix fall-through warnings for Clang
  IB/mlx4: Fix fall-through warnings for Clang
  IB/qedr: Fix fall-through warnings for Clang
  ice: Fix fall-through warnings for Clang
  Input: pcspkr - Fix fall-through warnings for Clang
  isofs: Fix fall-through warnings for Clang
  ixgbevf: Fix fall-through warnings for Clang
  kprobes/x86: Fix fall-through warnings for Clang
  mm: Fix fall-through warnings for Clang
  net: 3c509: Fix fall-through warnings for Clang
  net: cassini: Fix fall-through warnings for Clang
  net/mlx4: Fix fall-through warnings for Clang
  net: mscc: ocelot: Fix fall-through warnings for Clang
  netxen_nic: Fix fall-through warnings for Clang
  nfp: Fix fall-through warnings for Clang
  perf/x86: Fix fall-through warnings for Clang
  pinctrl: Fix fall-through warnings for Clang
  RDMA/mlx5: Fix fall-through warnings for Clang
  reiserfs: Fix fall-through warnings for Clang
  security: keys: Fix fall-through warnings for Clang
  selinux: Fix fall-through warnings for Clang
  target: Fix fall-through warnings for Clang
 

Re: [PATCH v2] staging: atomisp: Remove unnecessary 'fallthrough'

2020-08-31 Thread Gustavo A. R. Silva
On Mon, Aug 31, 2020 at 04:51:04PM +0300, Cengiz Can wrote:
> commit df561f6688fe ("treewide: Use fallthrough pseudo-keyword") from
> Gustavo A. R. Silva replaced and standardized /* fallthrough */ comments
> with 'fallthrough' pseudo-keyword.
> 
> However, in one of the switch-case statements, Coverity Static Analyzer
> throws a warning that 'fallthrough' is unreachable due to the adjacent
> 'return false' statement. (Coverity ID CID 1466511)
> 
> In order to fix the unreachable code warning, remove unnecessary
> fallthrough keyword.
> 
> Signed-off-by: Cengiz Can 

Reviewed-by: Gustavo A. R. Silva 

Thanks
--
Gustavo

> ---
>  drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c 
> b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> index 1b2b2c68025b..feb26c221e96 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
> @@ -711,7 +711,6 @@ static bool is_pipe_valid_to_current_run_mode(struct 
> atomisp_sub_device *asd,
>   return true;
>  
>   return false;
> - fallthrough;
>   case ATOMISP_RUN_MODE_VIDEO:
>   if (!asd->continuous_mode->val) {
>   if (pipe_id == IA_CSS_PIPE_ID_VIDEO ||
> -- 
> 2.28.0
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: wfx: Use flex_array_size() helper in memcpy()

2020-07-29 Thread Gustavo A. R. Silva
Make use of the flex_array_size() helper to calculate the size of a
flexible array member within an enclosing structure.

This helper offers defense-in-depth against potential integer
overflows, while at the same time makes it explicitly clear that
we are dealing with a flexible array member.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/wfx/hif_tx_mib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wfx/hif_tx_mib.c b/drivers/staging/wfx/hif_tx_mib.c
index 1689cb42acc0..05f1e1e98af9 100644
--- a/drivers/staging/wfx/hif_tx_mib.c
+++ b/drivers/staging/wfx/hif_tx_mib.c
@@ -113,7 +113,7 @@ int hif_set_beacon_filter_table(struct wfx_vif *wvif, int 
tbl_len,
if (!val)
return -ENOMEM;
val->num_of_info_elmts = cpu_to_le32(tbl_len);
-   memcpy(val->ie_table, tbl, tbl_len * sizeof(*tbl));
+   memcpy(val->ie_table, tbl, flex_array_size(val, ie_table, tbl_len));
ret = hif_write_mib(wvif->wdev, wvif->id,
HIF_MIB_ID_BEACON_FILTER_TABLE, val, buf_len);
kfree(val);
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: rtl8192e: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8192e/rtllib_wx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_wx.c 
b/drivers/staging/rtl8192e/rtllib_wx.c
index 7e7df50164fb..aa26b2fd2774 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -680,7 +680,7 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee,
switch (mlme->cmd) {
case IW_MLME_DEAUTH:
deauth = true;
-   /* fall through */
+   fallthrough;
case IW_MLME_DISASSOC:
if (deauth)
netdev_info(ieee->dev, "disauth packet !\n");
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: gdm724x: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/gdm724x/gdm_lte.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/gdm724x/gdm_lte.c 
b/drivers/staging/gdm724x/gdm_lte.c
index eb309190f5be..571f47d39484 100644
--- a/drivers/staging/gdm724x/gdm_lte.c
+++ b/drivers/staging/gdm724x/gdm_lte.c
@@ -784,7 +784,7 @@ static int gdm_lte_receive_pkt(struct phy_dev *phy_dev, 
char *buf, int len)
return index;
dev = phy_dev->dev[index];
gdm_lte_pdn_table(dev, buf, len);
-   /* Fall through */
+   fallthrough;
default:
ret = gdm_lte_event_send(dev, buf, len);
break;
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: rtl8723bs: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index d6d7198dfe45..6db637701063 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -568,7 +568,7 @@ void mgt_dispatcher(struct adapter *padapter, union 
recv_frame *precv_frame)
ptable->func = 
else
ptable->func = 
-   /* fall through */
+   fallthrough;
case WIFI_ASSOCREQ:
case WIFI_REASSOCREQ:
_mgt_dispatcher(padapter, ptable, precv_frame);
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: ks7010: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/ks7010/ks_wlan_net.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 334ae1ded684..dc09cc6e1c47 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -426,16 +426,16 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[3] =
TX_RATE_11M;
i++;
-   /* fall through */
+   fallthrough;
case 550:
priv->reg.rate_set.body[2] = TX_RATE_5M;
i++;
-   /* fall through */
+   fallthrough;
case 200:
priv->reg.rate_set.body[1] =
TX_RATE_2M | BASIC_RATE;
i++;
-   /* fall through */
+   fallthrough;
case 100:
priv->reg.rate_set.body[0] =
TX_RATE_1M | BASIC_RATE;
@@ -491,17 +491,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[11] =
TX_RATE_54M;
i++;
-   /* fall through */
+   fallthrough;
case 4800:
priv->reg.rate_set.body[10] =
TX_RATE_48M;
i++;
-   /* fall through */
+   fallthrough;
case 3600:
priv->reg.rate_set.body[9] =
TX_RATE_36M;
i++;
-   /* fall through */
+   fallthrough;
case 2400:
case 1800:
case 1200:
@@ -578,17 +578,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
TX_RATE_6M | BASIC_RATE;
i++;
}
-   /* fall through */
+   fallthrough;
case 550:
priv->reg.rate_set.body[2] =
TX_RATE_5M | BASIC_RATE;
i++;
-   /* fall through */
+   fallthrough;
case 200:
priv->reg.rate_set.body[1] =
TX_RATE_2M | BASIC_RATE;
i++;
-   /* fall through */
+   fallthrough;
case 100:
priv->reg.rate_set.body[0] =
TX_RATE_1M | BASIC_RATE;
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: rtl8712: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8712/usb_ops_linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/usb_ops_linux.c 
b/drivers/staging/rtl8712/usb_ops_linux.c
index 0045da3bb69a..9a04a752af13 100644
--- a/drivers/staging/rtl8712/usb_ops_linux.c
+++ b/drivers/staging/rtl8712/usb_ops_linux.c
@@ -225,7 +225,7 @@ static void r8712_usb_read_port_complete(struct urb *purb)
padapter->driver_stopped = true;
break;
}
-   /* Fall through. */
+   fallthrough;
case -EPROTO:
r8712_read_port(padapter, precvpriv->ff_hwaddr, 0,
  (unsigned char *)precvbuf);
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: comedi: s526: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/comedi/drivers/s526.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/s526.c 
b/drivers/staging/comedi/drivers/s526.c
index ba485f106c1e..085cf5b449e5 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -400,7 +400,7 @@ static int s526_gpct_winsn(struct comedi_device *dev,
if ((data[1] <= data[0]) || !data[0])
return -EINVAL;
/* to write the PULSE_WIDTH */
-   /* fall through */
+   fallthrough;
case INSN_CONFIG_GPCT_QUADRATURE_ENCODER:
case INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR:
s526_gpct_write(dev, chan, data[0]);
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: qlge: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/qlge/qlge_mpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c
index 94d504af84ff..e85c6ab538df 100644
--- a/drivers/staging/qlge/qlge_mpi.c
+++ b/drivers/staging/qlge/qlge_mpi.c
@@ -1174,7 +1174,7 @@ void ql_mpi_idc_work(struct work_struct *work)
case MB_CMD_PORT_RESET:
case MB_CMD_STOP_FW:
ql_link_off(qdev);
-   /* Fall through */
+   fallthrough;
case MB_CMD_SET_PORT_CFG:
/* Signal the resulting link up AEN
 * that the frame routing and mac addr
@@ -1207,7 +1207,7 @@ void ql_mpi_idc_work(struct work_struct *work)
 */
ql_link_off(qdev);
set_bit(QL_CAM_RT_SET, >flags);
-   /* Fall through. */
+   fallthrough;
case MB_CMD_IOP_DVR_START:
case MB_CMD_IOP_FLASH_ACC:
case MB_CMD_IOP_CORE_DUMP_MPI:
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: vc04_services: Use fallthrough pseudo-keyword

2020-07-27 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1].

[1] 
https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index af64cde82d36..5a361e8e7c6c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -2710,7 +2710,7 @@ vchiq_close_service_internal(struct vchiq_service 
*service, int close_recvd)
 
case VCHIQ_SRVSTATE_OPENSYNC:
mutex_lock(>sync_mutex);
-   /* fall through */
+   fallthrough;
case VCHIQ_SRVSTATE_OPEN:
if (close_recvd) {
if (!do_abort_bulks(service))
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8723bs: core: Using comparison to true is error prone

2020-07-10 Thread Gustavo A. R. Silva



On 7/10/20 15:16, John Oldman wrote:
> clear below issues reported by checkpatch.pl:
> 
> CHECK: Using comparison to true is error prone
> 
> Signed-off-by: John Oldman 
> ---
>  drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c 
> b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> index ca98274ae390..d9bdd4fb9dc3 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c
> @@ -363,8 +363,9 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv)
>   }
>  
>   /* HT Cap. */
> - if (((pregistrypriv->wireless_mode_11_5N) || 
> (pregistrypriv->wireless_mode_11_24N))
> - && (pregistrypriv->ht_enable == true)) {
> + if (((pregistrypriv->wireless_mode & WIRELESS_11_5N)
> +   || (pregistrypriv->wireless_mode & WIRELESS_11_24N))
> +   && (pregistrypriv->ht_enable)) {
 ^^
The enclosing parentheses are unnecessary.

Also, if you run checkpatch.pl on your patch, you'll see
the following:

CHECK: Logical continuations should be on the previous line
#12: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:367:
+   if (((pregistrypriv->wireless_mode & WIRELESS_11_5N)
+ || (pregistrypriv->wireless_mode & WIRELESS_11_24N))

CHECK: Logical continuations should be on the previous line
#13: FILE: drivers/staging/rtl8723bs/core/rtw_ieee80211.c:368:
+ || (pregistrypriv->wireless_mode & WIRELESS_11_24N))
+ && (pregistrypriv->ht_enable)) {


It'd be nice to fix the above, too. :)

--
Gustavo

>   /* todo: */
>   }
>  
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rts5208: Assign array_size() to a variable

2020-07-10 Thread Gustavo A. R. Silva
Assign array_size() to variable _size_ and use it in multiple places.

This issue was found with the help of Coccinelle and, audited and fixed
manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rts5208/rtsx_chip.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rts5208/rtsx_chip.c 
b/drivers/staging/rts5208/rtsx_chip.c
index c6f9375468eb..ee9ddc4eb94d 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -1440,6 +1440,7 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, 
u16 addr, u8 *buf,
u16 aligned_addr = addr - offset;
int dw_len, i, j;
int retval;
+   size_t size;
 
if (!buf)
return STATUS_NOMEM;
@@ -1451,11 +1452,12 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, 
u16 addr, u8 *buf,
 
dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
 
-   data = vzalloc(array_size(dw_len, 4));
+   size = array_size(dw_len, 4);
+   data = vzalloc(size);
if (!data)
return STATUS_NOMEM;
 
-   mask = vzalloc(array_size(dw_len, 4));
+   mask = vzalloc(size);
if (!mask) {
vfree(data);
return STATUS_NOMEM;
@@ -1471,10 +1473,8 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, 
u16 addr, u8 *buf,
}
}
 
-   print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, mask,
-dw_len * 4);
-   print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, data,
-dw_len * 4);
+   print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, mask, size);
+   print_hex_dump_bytes(KBUILD_MODNAME ": ", DUMP_PREFIX_NONE, data, size);
 
for (i = 0; i < dw_len; i++) {
retval = rtsx_write_cfg_dw(chip, func, aligned_addr + i * 4,
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6655: Use fallthrough pseudo-keyword

2020-07-07 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] 
https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/vt6655/channel.c |2 +-
 drivers/staging/vt6655/key.c |6 +++---
 drivers/staging/vt6656/channel.c |2 +-
 drivers/staging/vt6656/key.c |2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c
index 62a85c1ca6c4..889fc22f19bd 100644
--- a/drivers/staging/vt6655/channel.c
+++ b/drivers/staging/vt6655/channel.c
@@ -133,7 +133,7 @@ void vnt_init_bands(struct vnt_private *priv)
 
priv->hw->wiphy->bands[NL80211_BAND_5GHZ] =
_supported_5ghz_band;
-   /* fallthrough */
+   fallthrough;
case RF_RFMD2959:
case RF_AIROHA:
case RF_AL2230S:
diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c
index 4d6b48fd119d..94665ddc36a5 100644
--- a/drivers/staging/vt6655/key.c
+++ b/drivers/staging/vt6655/key.c
@@ -51,15 +51,15 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
/* default key last entry */
entry = MAX_KEY_TABLE - 1;
key->hw_key_idx = entry;
-   /* fall through */
+   fallthrough;
case VNT_KEY_ALLGROUP:
key_mode |= VNT_KEY_ALLGROUP;
if (onfly_latch)
key_mode |= VNT_KEY_ONFLY_ALL;
-   /* fall through */
+   fallthrough;
case VNT_KEY_GROUP_ADDRESS:
key_mode |= mode;
-   /* fall through */
+   fallthrough;
case VNT_KEY_GROUP:
key_mode |= (mode << 4);
key_mode |= VNT_KEY_GROUP;
diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c
index 5d57d34577f5..7855689af7cb 100644
--- a/drivers/staging/vt6656/channel.c
+++ b/drivers/staging/vt6656/channel.c
@@ -145,7 +145,7 @@ void vnt_init_bands(struct vnt_private *priv)
 
priv->hw->wiphy->bands[NL80211_BAND_5GHZ] =
_supported_5ghz_band;
-   /* fallthrough */
+   fallthrough;
case RF_AL2230:
case RF_AL2230S:
case RF_VT3226:
diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index c66cb53cfc09..70f75c5760ce 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -67,7 +67,7 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
/* default key last entry */
entry = MAX_KEY_TABLE - 1;
key->hw_key_idx = entry;
-   /* fall through */
+   fallthrough;
case VNT_KEY_GROUP_ADDRESS:
key_mode = mode | (mode << 4);
break;

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8188eu: Use fallthrough pseudo-keyword

2020-07-07 Thread Gustavo A. R. Silva
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] 
https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c|2 +-
 drivers/staging/rtl8188eu/hal/usb_halinit.c  |2 +-
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c |2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index 8d035f67ef61..414f1834657a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -4133,7 +4133,7 @@ void mgt_dispatcher(struct adapter *padapter, struct 
recv_frame *precv_frame)
ptable->func = 
else
ptable->func = 
-   /* fall through */
+   fallthrough;
case WIFI_ASSOCREQ:
case WIFI_REASSOCREQ:
case WIFI_PROBEREQ:
diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c 
b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index 16a57b31a439..114638f6f719 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -1728,7 +1728,7 @@ void rtw_hal_get_hwreg(struct adapter *Adapter, u8 
variable, u8 *val)
switch (variable) {
case HW_VAR_BASIC_RATE:
*((u16 *)(val)) = Adapter->HalData->BasicRateSet;
-   /* fall through */
+   fallthrough;
case HW_VAR_TXPAUSE:
val[0] = usb_read8(Adapter, REG_TXPAUSE);
break;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c 
b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index 3cd6da1f843d..a80c7f3b86d1 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -400,7 +400,7 @@ static void usb_read_port_complete(struct urb *purb, struct 
pt_regs *regs)
case -ENODEV:
case -ESHUTDOWN:
adapt->bSurpriseRemoved = true;
-   /* fall through */
+   fallthrough;
case -ENOENT:
adapt->bDriverStopped = true;
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2][next] staging: rts5208: Use array_size() helper in vmalloc() and memset()

2020-06-16 Thread Gustavo A. R. Silva
The vmalloc() function has no 2-factor argument form, so multiplication
factors need to be wrapped in array_size(). Also, while there, use
array_size() in memset().

This issue was found with the help of Coccinelle and, audited and fixed
manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by: Gustavo A. R. Silva 
---
Changes in v2:
 - Fix subject line and commit message. Previously, part of the subject
   line, unintentionally, sneaked into the commit message.

 drivers/staging/rts5208/ms.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c
index d53dd138a356..9001570a8c94 100644
--- a/drivers/staging/rts5208/ms.c
+++ b/drivers/staging/rts5208/ms.c
@@ -2306,14 +2306,14 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int 
seg_no)
if (!segment->l2p_table)
goto BUILD_FAIL;
}
-   memset((u8 *)(segment->l2p_table), 0xff, table_size * 2);
+   memset((u8 *)(segment->l2p_table), 0xff, array_size(table_size, 2));
 
if (!segment->free_table) {
-   segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2);
+   segment->free_table = vmalloc(array_size(MS_FREE_TABLE_CNT, 2));
if (!segment->free_table)
goto BUILD_FAIL;
}
-   memset((u8 *)(segment->free_table), 0xff, MS_FREE_TABLE_CNT * 2);
+   memset((u8 *)(segment->free_table), 0xff, array_size(MS_FREE_TABLE_CNT, 
2));
 
start = (u16)seg_no << 9;
end = (u16)(seg_no + 1) << 9;
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH][next] staging: rts5208: Use array_size() helper in vmalloc()

2020-06-16 Thread Gustavo A. R. Silva
On Tue, Jun 16, 2020 at 01:13:12PM +0300, Dan Carpenter wrote:
> On Mon, Jun 15, 2020 at 06:08:11PM -0500, Gustavo A. R. Silva wrote:
> > and memset()
> 
> Please don't start the commit message in the middle of a sentence.  It's
> 

That was, certainly, unintentional. Thanks for letting me know.

--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH][next] staging: rts5208: Use array_size() helper in vmalloc()

2020-06-15 Thread Gustavo A. R. Silva
and memset()

The vmalloc() function has no 2-factor argument form, so multiplication
factors need to be wrapped in array_size(). Also, while there, use
array_size() in memset().

This issue was found with the help of Coccinelle and, audited and fixed
manually.

Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rts5208/ms.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c
index d53dd138a356..9001570a8c94 100644
--- a/drivers/staging/rts5208/ms.c
+++ b/drivers/staging/rts5208/ms.c
@@ -2306,14 +2306,14 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int 
seg_no)
if (!segment->l2p_table)
goto BUILD_FAIL;
}
-   memset((u8 *)(segment->l2p_table), 0xff, table_size * 2);
+   memset((u8 *)(segment->l2p_table), 0xff, array_size(table_size, 2));
 
if (!segment->free_table) {
-   segment->free_table = vmalloc(MS_FREE_TABLE_CNT * 2);
+   segment->free_table = vmalloc(array_size(MS_FREE_TABLE_CNT, 2));
if (!segment->free_table)
goto BUILD_FAIL;
}
-   memset((u8 *)(segment->free_table), 0xff, MS_FREE_TABLE_CNT * 2);
+   memset((u8 *)(segment->free_table), 0xff, array_size(MS_FREE_TABLE_CNT, 
2));
 
start = (u16)seg_no << 9;
end = (u16)(seg_no + 1) << 9;
-- 
2.27.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: qlge: add braces on all arms of if-else

2020-02-21 Thread Gustavo A. R. Silva



On 2/21/20 14:29, Kaaira Gupta wrote:
> fix all checkpatch.pl warnings of 'braces {} should be used on all arms
> of this statement' in the file qlge_ethtool.c by adding the braces.
> 
> Signed-off-by: Kaaira Gupta 

Acked-by: Gustavo A. R. Silva 

Thanks for you patch.
--
Gustavo

> ---
>  drivers/staging/qlge/qlge_ethtool.c | 18 --
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/qlge/qlge_ethtool.c 
> b/drivers/staging/qlge/qlge_ethtool.c
> index 790997aff995..592ca7edfc44 100644
> --- a/drivers/staging/qlge/qlge_ethtool.c
> +++ b/drivers/staging/qlge/qlge_ethtool.c
> @@ -259,8 +259,9 @@ static void ql_update_stats(struct ql_adapter *qdev)
> "Error reading status register 0x%.04x.\n",
> i);
>   goto end;
> - } else
> + } else {
>   *iter = data;
> + }
>   iter++;
>   }
>  
> @@ -273,8 +274,9 @@ static void ql_update_stats(struct ql_adapter *qdev)
> "Error reading status register 0x%.04x.\n",
> i);
>   goto end;
> - } else
> + } else {
>   *iter = data;
> + }
>   iter++;
>   }
>  
> @@ -290,8 +292,9 @@ static void ql_update_stats(struct ql_adapter *qdev)
> "Error reading status register 0x%.04x.\n",
> i);
>   goto end;
> - } else
> + } else {
>   *iter = data;
> + }
>   iter++;
>   }
>  
> @@ -304,8 +307,9 @@ static void ql_update_stats(struct ql_adapter *qdev)
> "Error reading status register 0x%.04x.\n",
> i);
>   goto end;
> - } else
> + } else {
>   *iter = data;
> + }
>   iter++;
>   }
>  
> @@ -316,8 +320,9 @@ static void ql_update_stats(struct ql_adapter *qdev)
>   netif_err(qdev, drv, qdev->ndev,
> "Error reading status register 0x%.04x.\n", i);
>   goto end;
> - } else
> + } else {
>   *iter = data;
> + }
>  end:
>   ql_sem_unlock(qdev, qdev->xg_sem_mask);
>  quit:
> @@ -488,8 +493,9 @@ static int ql_start_loopback(struct ql_adapter *qdev)
>   if (netif_carrier_ok(qdev->ndev)) {
>   set_bit(QL_LB_LINK_UP, >flags);
>   netif_carrier_off(qdev->ndev);
> - } else
> + } else {
>   clear_bit(QL_LB_LINK_UP, >flags);
> + }
>   qdev->link_config |= CFG_LOOPBACK_PCS;
>   return ql_mb_set_port_cfg(qdev);
>  }
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: Replace zero-length array with flexible-array member

2020-02-20 Thread Gustavo A. R. Silva
Hi,

On 2/20/20 13:04, adham.aboza...@microchip.com wrote:
> Hi Gustavo
> 
> On 2/20/20 6:29 AM, Gustavo A. R. Silva wrote:
>> The current codebase makes use of the zero-length array language
>> extension to the C90 standard, but the preferred mechanism to declare
>> variable-length types such as these ones is a flexible array member[1][2],
>> introduced in C99:
>>
>> struct foo {
>> int stuff;
>> struct boo array[];
>> };
>>
>> By making use of the mechanism above, we will get a compiler warning
>> in case the flexible array does not occur last in the structure, which
>> will help us prevent some kind of undefined behavior bugs from being
>> inadvertently introduced[3] to the codebase from now on.
>>
>> Also, notice that, dynamic memory allocations won't be affected by
>> this change:
>>
>> "Flexible array members have incomplete type, and so the sizeof operator
>> may not be applied. As a quirk of the original implementation of
>> zero-length arrays, sizeof evaluates to zero."[1]
>>
>> This issue was found with the help of Coccinelle.
>>
>> [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
>> [2] https://github.com/KSPP/linux/issues/21
>> [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
>>
>> Signed-off-by: Gustavo A. R. Silva 
>>
>>  static void cfg_scan_result(enum scan_event scan_event,
>> diff --git a/drivers/staging/wilc1000/spi.c b/drivers/staging/wilc1000/spi.c
>> index 44f7d48851b5..11653ac118cd 100644
>> --- a/drivers/staging/wilc1000/spi.c
>> +++ b/drivers/staging/wilc1000/spi.c
>> @@ -139,7 +139,7 @@ struct wilc_spi_read_rsp_data {
>> u8 status;
>> u8 resp_header;
>> u8 resp_data[4];
>> -   u8 crc[0];
>> +   u8 crc[];
>>  } __packed;
> more zero-length arrays in wilc1000, spi.c, struct wilc_spi_cmd, and in fw.h
> 

Oh wow, I hadn't thought about cases like this:

struct wilc_spi_cmd {
u8 cmd_type;
union {
struct {
u8 addr[3];
u8 crc[0];
} __packed simple_cmd;
struct {
u8 addr[3];
u8 size[2];
u8 crc[0];
} __packed dma_cmd;
struct {
u8 addr[3];
u8 size[3];
u8 crc[0];
} __packed dma_cmd_ext;
struct {
u8 addr[2];
__be32 data;
u8 crc[0];
} __packed internal_w_cmd;
struct {
u8 addr[3];
__be32 data;
u8 crc[0];
} __packed w_cmd;
} u;
} __packed;

Thanks for the feedback.
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: Replace zero-length array with flexible-array member

2020-02-20 Thread Gustavo A. R. Silva
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
int stuff;
struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/gdm724x/gdm_mux.h |  2 +-
 drivers/staging/gdm724x/hci_packet.h  |  6 ++--
 drivers/staging/greybus/audio_apbridgea.h |  2 +-
 drivers/staging/ks7010/ks_hostif.h|  4 +--
 .../staging/media/allegro-dvt/allegro-core.c  |  2 +-
 drivers/staging/octeon-usb/octeon-hcd.c   |  2 +-
 drivers/staging/rtl8192e/rtllib.h | 30 +--
 .../staging/rtl8192u/ieee80211/ieee80211.h| 28 -
 drivers/staging/rtl8712/ieee80211.h   |  4 +--
 drivers/staging/rtl8712/rtl871x_mp_ioctl.h|  4 +--
 drivers/staging/wilc1000/cfg80211.c   | 10 +++
 drivers/staging/wilc1000/spi.c|  2 +-
 drivers/staging/wlan-ng/hfa384x.h |  4 +--
 drivers/staging/wlan-ng/p80211types.h |  4 +--
 14 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/drivers/staging/gdm724x/gdm_mux.h 
b/drivers/staging/gdm724x/gdm_mux.h
index 51c22e3d8aeb..87b8d921fdc8 100644
--- a/drivers/staging/gdm724x/gdm_mux.h
+++ b/drivers/staging/gdm724x/gdm_mux.h
@@ -29,7 +29,7 @@ struct mux_pkt_header {
__le32 seq_num;
__le32 payload_size;
__le16 packet_type;
-   unsigned char data[0];
+   unsigned char data[];
 };
 
 struct mux_tx {
diff --git a/drivers/staging/gdm724x/hci_packet.h 
b/drivers/staging/gdm724x/hci_packet.h
index 6dea3694afdd..faecdfbc664f 100644
--- a/drivers/staging/gdm724x/hci_packet.h
+++ b/drivers/staging/gdm724x/hci_packet.h
@@ -28,7 +28,7 @@
 struct hci_packet {
__dev16 cmd_evt;
__dev16 len;
-   u8 data[0];
+   u8 data[];
 } __packed;
 
 struct tlv {
@@ -51,7 +51,7 @@ struct sdu {
__dev32 dft_eps_ID;
__dev32 bearer_ID;
__dev32 nic_type;
-   u8 data[0];
+   u8 data[];
 } __packed;
 
 struct multi_sdu {
@@ -59,7 +59,7 @@ struct multi_sdu {
__dev16 len;
__dev16 num_packet;
__dev16 reserved;
-   u8 data[0];
+   u8 data[];
 } __packed;
 
 struct hci_pdn_table_ind {
diff --git a/drivers/staging/greybus/audio_apbridgea.h 
b/drivers/staging/greybus/audio_apbridgea.h
index 3f1f4dd2c61a..efec0f815efd 100644
--- a/drivers/staging/greybus/audio_apbridgea.h
+++ b/drivers/staging/greybus/audio_apbridgea.h
@@ -65,7 +65,7 @@
 struct audio_apbridgea_hdr {
__u8type;
__le16  i2s_port;
-   __u8data[0];
+   __u8data[];
 } __packed;
 
 struct audio_apbridgea_set_config_request {
diff --git a/drivers/staging/ks7010/ks_hostif.h 
b/drivers/staging/ks7010/ks_hostif.h
index ca7dc8f5166c..39138191a556 100644
--- a/drivers/staging/ks7010/ks_hostif.h
+++ b/drivers/staging/ks7010/ks_hostif.h
@@ -70,7 +70,7 @@ struct hostif_data_request {
 #define TYPE_DATA 0x
 #define TYPE_AUTH 0x0001
__le16 reserved;
-   u8 data[0];
+   u8 data[];
 } __packed;
 
 #define TYPE_PMK1 0x0001
@@ -194,7 +194,7 @@ enum mib_data_type {
 struct hostif_mib_value {
__le16 size;
__le16 type;
-   u8 body[0];
+   u8 body[];
 } __packed;
 
 struct hostif_mib_get_confirm_t {
diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c 
b/drivers/staging/media/allegro-dvt/allegro-core.c
index 3be41698df4c..0a09b3622e78 100644
--- a/drivers/staging/media/allegro-dvt/allegro-core.c
+++ b/drivers/staging/media/allegro-dvt/allegro-core.c
@@ -434,7 +434,7 @@ struct mcu_msg_push_buffers_internal_buffer {
 struct mcu_msg_push_buffers_internal {
struct mcu_msg_header header;
u32 channel_id;
-   struct mcu_msg_push_buffers_internal_buffer buffer[0];
+   struct mcu_msg_push_buffers_internal_buffer buffer[];
 } __attribute__ ((__packed__));
 
 struct mcu_msg_put_stream_buffer {
diff --git a/drivers/staging/octeon-usb/octeon-hcd.c 
b/drivers/staging/octeon-usb/octeon-hcd.c
index 582c9187559d..61471a19d4e6 100644
--- a/drivers/staging/octeon-usb/octeon-hcd.c
+

Re: [greybus-dev] [PATCH] staging: greybus: Replace zero-length array with flexible-array member

2020-02-11 Thread Gustavo A. R. Silva



On 2/11/20 16:15, Alex Elder wrote:
> On 2/11/20 3:12 PM, Gustavo A. R. Silva wrote:
>> The current codebase makes use of the zero-length array language
>> extension to the C90 standard, but the preferred mechanism to declare
>> variable-length types such as these ones is a flexible array member[1][2],
>> introduced in C99:
>>
>> struct foo {
>> int stuff;
>> struct boo array[];
>> };
>>
>> By making use of the mechanism above, we will get a compiler warning
>> in case the flexible array does not occur last in the structure, which
>> will help us prevent some kind of undefined behavior bugs from being
>> inadvertenly introduced[3] to the codebase from now on.
>>
>> This issue was found with the help of Coccinelle.
>>
>> [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
>> [2] https://github.com/KSPP/linux/issues/21
>> [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")
>>
>> Signed-off-by: Gustavo A. R. Silva 
>> ---
>>  drivers/staging/greybus/raw.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c
>> index 838acbe84ca0..2b301b2aa107 100644
>> --- a/drivers/staging/greybus/raw.c
>> +++ b/drivers/staging/greybus/raw.c
>> @@ -30,7 +30,7 @@ struct gb_raw {
>>  struct raw_data {
>>  struct list_head entry;
>>  u32 len;
>> -u8 data[0];
>> +u8 data[];
>>  };
>>  
>>  static struct class *raw_class;
>>
> 
> Does the kamlloc() call in receive_data() have any problems
> with the sizeof(*raw_data) passed as its argument?
> 

Not in this case. It'd be different with a one-element array (u8 data[1]),
though.

> I'm not entirely sure what sizeof(struct-with-flexible-array-member)
> produces.
> 

The same as sizeof(struct-with-zero-length-array):

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: unisys: visorinput: Replace zero-length array with flexible-array member

2020-02-11 Thread Gustavo A. R. Silva
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
int stuff;
struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertenly introduced[3] to the codebase from now on.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/unisys/visorinput/visorinput.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/unisys/visorinput/visorinput.c 
b/drivers/staging/unisys/visorinput/visorinput.c
index 9693fb559052..6d202cba8575 100644
--- a/drivers/staging/unisys/visorinput/visorinput.c
+++ b/drivers/staging/unisys/visorinput/visorinput.c
@@ -111,7 +111,7 @@ struct visorinput_devdata {
/* size of following array */
unsigned int keycode_table_bytes;
/* for keyboard devices: visorkbd_keycode[] + visorkbd_ext_keycode[] */
-   unsigned char keycode_table[0];
+   unsigned char keycode_table[];
 };
 
 static const guid_t visor_keyboard_channel_guid = VISOR_KEYBOARD_CHANNEL_GUID;
-- 
2.25.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: greybus: Replace zero-length array with flexible-array member

2020-02-11 Thread Gustavo A. R. Silva
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
int stuff;
struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertenly introduced[3] to the codebase from now on.

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/greybus/raw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c
index 838acbe84ca0..2b301b2aa107 100644
--- a/drivers/staging/greybus/raw.c
+++ b/drivers/staging/greybus/raw.c
@@ -30,7 +30,7 @@ struct gb_raw {
 struct raw_data {
struct list_head entry;
u32 len;
-   u8 data[0];
+   u8 data[];
 };
 
 static struct class *raw_class;
-- 
2.25.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 2/2] staging: rtl8192u: ieee80211: Fix spelling mistake

2019-04-26 Thread Gustavo A. R. Silva
Hi Vatsala,

On 4/26/19 3:43 AM, Vatsala Narang wrote:
> Replace explicitely with explicitly to get rid of checkpatch warning.
> 
> Signed-off-by: Vatsala Narang 
> ---
> Changes in v2:
> -added this patch to patchset to fix spelling mistake.
> 

When you create a series, it is a good thing to include a cover letter,
in particular in cases like this, in which there is no v1 of this
patch.  Notice that you have just created a v2 of a previously
non-existent series. This can create confusion for maintainers
were you addressing a more complex task.

I might be a bit picky here, but be sure that any extra time you
invest in the first stages as a kernel contributor will pay off
in the future. :)

Anyway, here is my

Acked-by: Gustavo A. R. Silva 

for both patches.

Thanks and keep contributing.
--
Gustavo

>  drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c 
> b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> index 2044ae27b973..9631331b79d5 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> @@ -396,7 +396,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
>  (*crypt)->priv);
>   sec.flags |= BIT(key);
>   /* This ensures a key will be activated if no key is
> -  * explicitely set */
> +  * explicitly set
> +  */
>   if (key == sec.active_key)
>   sec.flags |= SEC_ACTIVE_KEY;
>   ieee->tx_keyidx = key;
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtl8192u: ieee80211: Replace bit shifting with BIT macro

2019-04-25 Thread Gustavo A. R. Silva
Hi Vatsala,

On 4/25/19 1:33 PM, Vatsala Narang wrote:
> Challenge suggested by coccinelle.
> 

I think you mean *change*.

See more comments below...


> Replace bit shifting on 1 with the BIT(x) macro.
> Coccinelle script:
> 
> @@
> expression c;
> @@
> 
> -(1 << c)
> +BIT(c)
> 
> Signed-off-by: Vatsala Narang 
> ---
>  drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c 
> b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> index fa59c712c74b..c44662f03a6b 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
> @@ -86,7 +86,7 @@ static inline char *rtl819x_translate_scan(struct 
> ieee80211_device *ieee,
>   /* Add the protocol name */
>   iwe.cmd = SIOCGIWNAME;
>   for(i=0; i - if(network->mode&(1< + if(network->mode(i)) {

A space is required before the open parenthesis: 'if ('.  Also, add
spaces around operators, in this case around '&'.

>   
> sprintf(pname,ieee80211_modes[i].mode_string,ieee80211_modes[i].mode_size);
>   pname +=ieee80211_modes[i].mode_size;
>   }
> @@ -394,7 +394,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
>   sec.key_sizes[key] = len;
>   (*crypt)->ops->set_key(sec.keys[key], len, NULL,
>  (*crypt)->priv);
> - sec.flags |= (1 << key);
> + sec.flags |= BIT(key);
>   /* This ensures a key will be activated if no key is
>* explicitely set */

You could send a separate patch to fix the typo in the above
comment: explicitely -> explicitly.

I encourage you to adopt the practice of running checkpatch.pl
on your patches before submitting them.

Thanks
--
Gustavo

>   if (key == sec.active_key)
> @@ -415,7 +415,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
>   (*crypt)->ops->set_key(sec.keys[key], 13, NULL,
>  (*crypt)->priv);
>   sec.key_sizes[key] = 13;
> - sec.flags |= (1 << key);
> + sec.flags |= BIT(key);
>   }
>  
>   /* No key data - just set the default TX key index */
> @@ -636,7 +636,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device 
> *ieee,
>   if (ext->alg != IW_ENCODE_ALG_NONE) {
>   //memcpy(sec.keys[idx], ext->key, ext->key_len);
>   sec.key_sizes[idx] = ext->key_len;
> - sec.flags |= (1 << idx);
> + sec.flags |= BIT(idx);
>   if (ext->alg == IW_ENCODE_ALG_WEP) {
> //  sec.encode_alg[idx] = SEC_ALG_WEP;
>   sec.flags |= SEC_LEVEL;
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: most: core: replace strcpy() by strscpy()

2019-04-22 Thread Gustavo A. R. Silva
The strcpy() function is being deprecated. Replace it by the safer
strscpy() and fix the following Coverity warning:

"You might overrun the 80-character fixed-size string iface->p->name
by copying iface->description without checking the length."

Addresses-Coverity-ID: 1444760 ("Copy into fixed size buffer")
Fixes: 131ac62253db ("staging: most: core: use device description as name")
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/most/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/most/core.c b/drivers/staging/most/core.c
index 956daf8c3bd2..f0b834300c6e 100644
--- a/drivers/staging/most/core.c
+++ b/drivers/staging/most/core.c
@@ -1431,7 +1431,7 @@ int most_register_interface(struct most_interface *iface)
 
INIT_LIST_HEAD(>p->channel_list);
iface->p->dev_id = id;
-   strcpy(iface->p->name, iface->description);
+   strscpy(iface->p->name, iface->description, sizeof(iface->p->name));
iface->dev.init_name = iface->p->name;
iface->dev.bus = 
iface->dev.parent = 
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: greybus: power_supply: use struct_size() helper

2019-04-18 Thread Gustavo A. R. Silva



On 4/18/19 1:27 AM, Johan Hovold wrote:
> On Wed, Apr 17, 2019 at 01:44:40PM -0500, Gustavo A. R. Silva wrote:
>> Make use of the struct_size() helper instead of an open-coded version
>> in order to avoid any potential type mistakes, in particular in the
>> context in which this code is being used.
>>
>> So, replace code of the following form:
>>
>> sizeof(*resp) + props_count * sizeof(struct gb_power_supply_props_desc)
>>
>> with:
>>
>> struct_size(resp, props, props_count)
>>
>> This code was detected with the help of Coccinelle.
>>
>> Signed-off-by: Gustavo A. R. Silva 
>> ---
>> Changes in v2:
>>  - Rebase on top of 47830c1127ef ("staging: greybus: power_supply: fix 
>> prop-descriptor request size")
> 
> Thanks for rebasing.
> 

Glad to help. :)

> Reviewed-by: Johan Hovold 
> 

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: greybus: power_supply: use struct_size() helper

2019-04-17 Thread Gustavo A. R. Silva
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes, in particular in the
context in which this code is being used.

So, replace code of the following form:

sizeof(*resp) + props_count * sizeof(struct gb_power_supply_props_desc)

with:

struct_size(resp, props, props_count)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
Changes in v2:
 - Rebase on top of 47830c1127ef ("staging: greybus: power_supply: fix 
prop-descriptor request size")

 drivers/staging/greybus/power_supply.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/power_supply.c 
b/drivers/staging/greybus/power_supply.c
index ae5c0285a942..34b40a409ea3 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -520,8 +520,8 @@ static int gb_power_supply_prop_descriptors_get(struct 
gb_power_supply *gbpsy)
 
op = gb_operation_create(connection,
 GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS,
-sizeof(*req), sizeof(*resp) + props_count *
-sizeof(struct gb_power_supply_props_desc),
+sizeof(*req),
+struct_size(resp, props, props_count),
 GFP_KERNEL);
if (!op)
return -ENOMEM;
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: power_supply: Use struct_size() helper

2019-04-10 Thread Gustavo A. R. Silva
Johan,

On 4/4/19 2:24 AM, Johan Hovold wrote:
> On Thu, Apr 04, 2019 at 08:09:51AM +0100, Rui Miguel Silva wrote:
>> Hi Gustavo,
>> Thanks a lot for the patch.
>>
>> On Wed 03 Apr 2019 at 21:58, Gustavo A. R. Silva wrote:
>>> Make use of the struct_size() helper instead of an open-coded 
>>> version
>>> in order to avoid any potential type mistakes, in particular in 
>>> the
>>> context in which this code is being used.
>>>
>>> So, replace code of the following form:
>>>
>>> sizeof(*resp) + props_count * sizeof(struct 
>>> gb_power_supply_props_desc)
>>>
>>> with:
>>>
>>> struct_size(resp, props, props_count)
>>>
>>> This code was detected with the help of Coccinelle.
>>>
>>> Signed-off-by: Gustavo A. R. Silva 
>>
>> What are the odds of 2 people changing same code in greybus in
>> the same day :).
> 
> Well, I only noticed the bug in the current code, when reviewing
> Gustavo's diff. ;)
> 

Apparently, your patch hasn't been applied to any tree yet.  So, I'll
wait for it to be applied before sending v2.

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: greybus: power_supply: Use struct_size() helper

2019-04-10 Thread Gustavo A. R. Silva
Hi Johan,

On 4/4/19 1:57 AM, Johan Hovold wrote:
> 
> This patch looks good, but I noticed a bug here in the current code,
> which should be fixed before applying this clean up.
> 
> sizeof(req) should have been sizeof(*req) above.
> 

Good catch.

>> - sizeof(struct gb_power_supply_props_desc),
>> + sizeof(req),
>> + struct_size(resp, props, props_count),
>>   GFP_KERNEL);
>>  if (!op)
>>  return -ENOMEM;
> 
> I've just submitted a fix (and CCed you as well). 
> 
> Would you mind respinning on top of that one?
> 

Yep. I'll send v2 shortly.

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: greybus: power_supply: Use struct_size() helper

2019-04-03 Thread Gustavo A. R. Silva
Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes, in particular in the
context in which this code is being used.

So, replace code of the following form:

sizeof(*resp) + props_count * sizeof(struct gb_power_supply_props_desc)

with:

struct_size(resp, props, props_count)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/greybus/power_supply.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/greybus/power_supply.c 
b/drivers/staging/greybus/power_supply.c
index 0529e5628c24..40cc2d462ba0 100644
--- a/drivers/staging/greybus/power_supply.c
+++ b/drivers/staging/greybus/power_supply.c
@@ -520,8 +520,8 @@ static int gb_power_supply_prop_descriptors_get(struct 
gb_power_supply *gbpsy)
 
op = gb_operation_create(connection,
 GB_POWER_SUPPLY_TYPE_GET_PROP_DESCRIPTORS,
-sizeof(req), sizeof(*resp) + props_count *
-sizeof(struct gb_power_supply_props_desc),
+sizeof(req),
+struct_size(resp, props, props_count),
 GFP_KERNEL);
if (!op)
return -ENOMEM;
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ralink-gdma: Use struct_size() in kzalloc()

2019-04-03 Thread Gustavo A. R. Silva
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
int stuff;
struct boo entry[];
};

size = sizeof(struct foo) + count * sizeof(struct boo);
instance = kzalloc(size, GFP_KERNEL)

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

size = struct_size(instance, entry, count);

or

instance = kzalloc(struct_size(instance, entry, count), GFP_KERNEL)

Based on the above, replace gdma_dma_alloc_desc() with kzalloc() and
use the new struct_size() helper.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/ralink-gdma/ralink-gdma.c | 12 +++-
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c 
b/drivers/staging/ralink-gdma/ralink-gdma.c
index b6d484532269..3228227776dc 100644
--- a/drivers/staging/ralink-gdma/ralink-gdma.c
+++ b/drivers/staging/ralink-gdma/ralink-gdma.c
@@ -169,12 +169,6 @@ static inline void gdma_dma_write(struct gdma_dma_dev 
*dma_dev,
writel(val, dma_dev->base + reg);
 }
 
-static struct gdma_dma_desc *gdma_dma_alloc_desc(unsigned int num_sgs)
-{
-   return kzalloc(sizeof(struct gdma_dma_desc) +
-   sizeof(struct gdma_dma_sg) * num_sgs, GFP_ATOMIC);
-}
-
 static enum gdma_dma_transfer_size gdma_dma_maxburst(u32 maxburst)
 {
if (maxburst < 2)
@@ -531,7 +525,7 @@ static struct dma_async_tx_descriptor 
*gdma_dma_prep_slave_sg(
struct scatterlist *sg;
unsigned int i;
 
-   desc = gdma_dma_alloc_desc(sg_len);
+   desc = kzalloc(struct_size(desc, sg, sg_len), GFP_ATOMIC);
if (!desc) {
dev_err(c->device->dev, "alloc sg decs error\n");
return NULL;
@@ -586,7 +580,7 @@ static struct dma_async_tx_descriptor 
*gdma_dma_prep_dma_memcpy(
xfer_count = GDMA_REG_CTRL0_TX_MASK;
num_periods = DIV_ROUND_UP(len, xfer_count);
 
-   desc = gdma_dma_alloc_desc(num_periods);
+   desc = kzalloc(struct_size(desc, sg, num_periods), GFP_ATOMIC);
if (!desc) {
dev_err(c->device->dev, "alloc memcpy decs error\n");
return NULL;
@@ -631,7 +625,7 @@ static struct dma_async_tx_descriptor 
*gdma_dma_prep_dma_cyclic(
}
 
num_periods = buf_len / period_len;
-   desc = gdma_dma_alloc_desc(num_periods);
+   desc = kzalloc(struct_size(desc, sg, num_periods), GFP_ATOMIC);
if (!desc) {
dev_err(c->device->dev, "alloc cyclic decs error\n");
return NULL;
-- 
2.21.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: comedi: ni_660x: fix missing break in switch statement

2019-02-18 Thread Gustavo A. R. Silva
Hi Sasha,

On 2/18/19 3:14 PM, Sasha Levin wrote:
> Hi,
> 
> [This is an automated email]
> 
> This commit has been processed because it contains a "Fixes:" tag,
> fixing commit: 58dd7c0a2a6e Staging: comedi: add ni_660x driver.
> 
> The bot has tested the following trees: v4.20.8, v4.19.21, v4.14.99, 
> v4.9.156, v4.4.174, v3.18.134.
> 
> v4.20.8: Build OK!
> v4.19.21: Build OK!
> v4.14.99: Build OK!
> v4.9.156: Build OK!
> v4.4.174: Failed to apply! Possible dependencies:
> 01ead0ded315 ("staging: comedi: ni_660x: cleanup the NI660X_IO_CFG 
> register helpers")
> 22acd860137a ("staging: comedi: ni_660x: change IOConfigReg() into a 
> macro")
> 41014593caeb ("staging: comedi: ni_660x: cleanup the 
> NI660X_GLOBAL_INT_{STATUS, CFG}")
> 502552e161ae ("staging: comedi: ni_660x: remove enum 
> clock_config_register_bits")
> 518d38423b48 ("staging: comedi: ni_660x: tidy up 
> ni_660x_select_pfi_output()")
> 9678b73e273a ("staging: comedi: ni_660x: tidy up 
> ni_660x_write_register()")
> aa94f225 ("staging: comedi: ni_660x: tidy up 
> ni_660x_set_pfi_routing()")
> ad98c18cb9de ("staging: comedi: ni_660x: tidy up ni_660x_read_register()")
> cded944fa90c ("staging: comedi: ni_660x: Prefer kernel type 'u64' over 
> 'uint64_t'")
> fecf4cce0021 ("staging: comedi: ni_660x: cleanup the NI660X_DMA_CFG 
> register helpers")
> 
> v3.18.134: Failed to apply! Possible dependencies:
> 01ead0ded315 ("staging: comedi: ni_660x: cleanup the NI660X_IO_CFG 
> register helpers")
> 22acd860137a ("staging: comedi: ni_660x: change IOConfigReg() into a 
> macro")
> 41014593caeb ("staging: comedi: ni_660x: cleanup the 
> NI660X_GLOBAL_INT_{STATUS, CFG}")
> 502552e161ae ("staging: comedi: ni_660x: remove enum 
> clock_config_register_bits")
> 518d38423b48 ("staging: comedi: ni_660x: tidy up 
> ni_660x_select_pfi_output()")
> 9678b73e273a ("staging: comedi: ni_660x: tidy up 
> ni_660x_write_register()")
> aa94f225 ("staging: comedi: ni_660x: tidy up 
> ni_660x_set_pfi_routing()")
> ad98c18cb9de ("staging: comedi: ni_660x: tidy up ni_660x_read_register()")
> cded944fa90c ("staging: comedi: ni_660x: Prefer kernel type 'u64' over 
> 'uint64_t'")
> fecf4cce0021 ("staging: comedi: ni_660x: cleanup the NI660X_DMA_CFG 
> register helpers")
> 
> 
> How should we proceed with this patch?
> 

Ian commented that this bug was introduced in 4.7, so it should be applied to 
4.9 ... 4.20

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: vt6656: key: Mark expected switch fall-throughs

2019-02-18 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch
cases where we are expecting to fall through.

This patch fixes the following warnings:

drivers/staging/vt6656/key.c: In function ‘vnt_set_keymode’:
drivers/staging/vt6656/key.c:70:19: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
   key->hw_key_idx = entry;
   ^~~
drivers/staging/vt6656/key.c:71:2: note: here
  case VNT_KEY_ALLGROUP:
  ^~~~
drivers/staging/vt6656/key.c:73:6: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
   if (onfly_latch)
  ^
drivers/staging/vt6656/key.c:75:2: note: here
  case VNT_KEY_GROUP_ADDRESS:
  ^~~~
drivers/staging/vt6656/key.c:76:12: warning: this statement may fall through 
[-Wimplicit-fallthrough=]
   key_mode |= mode;
   ~^~~
drivers/staging/vt6656/key.c:77:2: note: here
  case VNT_KEY_GROUP:
  ^~~~

Warning level 3 was used: -Wimplicit-fallthrough=3

This patch is part of the ongoing efforts to enable
-Wimplicit-fallthrough.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/vt6656/key.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c
index 91dede54cc1f..dcd933a6b66e 100644
--- a/drivers/staging/vt6656/key.c
+++ b/drivers/staging/vt6656/key.c
@@ -63,17 +63,19 @@ static int vnt_set_keymode(struct ieee80211_hw *hw, u8 
*mac_addr,
}
 
switch (key_type) {
-   /* fallthrough */
case VNT_KEY_DEFAULTKEY:
/* default key last entry */
entry = MAX_KEY_TABLE - 1;
key->hw_key_idx = entry;
+   /* fall through */
case VNT_KEY_ALLGROUP:
key_mode |= VNT_KEY_ALLGROUP;
if (onfly_latch)
key_mode |= VNT_KEY_ONFLY_ALL;
+   /* fall through */
case VNT_KEY_GROUP_ADDRESS:
key_mode |= mode;
+   /* fall through */
case VNT_KEY_GROUP:
key_mode |= (mode << 4);
key_mode |= VNT_KEY_GROUP;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: comedi: ni_660x: fix missing break in switch statement

2019-02-13 Thread Gustavo A. R. Silva


On 2/13/19 4:41 AM, Ian Abbott wrote:
> On 12/02/2019 18:44, Gustavo A. R. Silva wrote:
>> Add missing break statement in order to prevent the code from falling
>> through to the default case and return -EINVAL every time.
>>
>> This bug was found thanks to the ongoing efforts to enable
>> -Wimplicit-fallthrough.
>>
>> Fixes: aa94f225 ("staging: comedi: ni_660x: tidy up 
>> ni_660x_set_pfi_routing()")
>> Cc: sta...@vger.kernel.org
>> Signed-off-by: Gustavo A. R. Silva 
>> ---
>> Changes in v2:
>>   - Fix Fixes tag.
>>
>>   drivers/staging/comedi/drivers/ni_660x.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/staging/comedi/drivers/ni_660x.c 
>> b/drivers/staging/comedi/drivers/ni_660x.c
>> index e70a461e723f..405573e927cf 100644
>> --- a/drivers/staging/comedi/drivers/ni_660x.c
>> +++ b/drivers/staging/comedi/drivers/ni_660x.c
>> @@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device 
>> *dev,
>>   case NI_660X_PFI_OUTPUT_DIO:
>>   if (chan > 31)
>>   return -EINVAL;
>> +    break;
>>   default:
>>   return -EINVAL;
>>   }
>>
> 
> Thanks for the bug fix!
> 

Glad to help. :)

> Reviewed-by: Ian Abbott 
> 

Thanks, Ian.

--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: comedi: ni_660x: fix missing break in switch statement

2019-02-12 Thread Gustavo A. R. Silva
Hi,

Please, drop this.

I've just sent v2 with the right Fixes tag:

https://lore.kernel.org/patchwork/patch/1041301/

Thanks
--
Gustavo

On 2/12/19 12:08 PM, Gustavo A. R. Silva wrote:
> Add missing break statement in order to prevent the code from falling
> through to the default case and return -EINVAL every time.
> 
> This bug was found thanks to the ongoing efforts to enable
> -Wimplicit-fallthrough.
> 
> Fixes: 58dd7c0a2a6e ("Staging: comedi: add ni_660x driver")
> Cc: sta...@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva 
> ---
>  drivers/staging/comedi/drivers/ni_660x.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/comedi/drivers/ni_660x.c 
> b/drivers/staging/comedi/drivers/ni_660x.c
> index e70a461e723f..405573e927cf 100644
> --- a/drivers/staging/comedi/drivers/ni_660x.c
> +++ b/drivers/staging/comedi/drivers/ni_660x.c
> @@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device 
> *dev,
>   case NI_660X_PFI_OUTPUT_DIO:
>   if (chan > 31)
>   return -EINVAL;
> + break;
>   default:
>   return -EINVAL;
>   }
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: comedi: ni_660x: fix missing break in switch statement

2019-02-12 Thread Gustavo A. R. Silva
Add missing break statement in order to prevent the code from falling
through to the default case and return -EINVAL every time.

This bug was found thanks to the ongoing efforts to enable
-Wimplicit-fallthrough.

Fixes: aa94f225 ("staging: comedi: ni_660x: tidy up 
ni_660x_set_pfi_routing()")
Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
---
Changes in v2:
 - Fix Fixes tag.

 drivers/staging/comedi/drivers/ni_660x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/comedi/drivers/ni_660x.c 
b/drivers/staging/comedi/drivers/ni_660x.c
index e70a461e723f..405573e927cf 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device 
*dev,
case NI_660X_PFI_OUTPUT_DIO:
if (chan > 31)
return -EINVAL;
+   break;
default:
return -EINVAL;
}
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: comedi: ni_660x: fix missing break in switch statement

2019-02-12 Thread Gustavo A. R. Silva
Add missing break statement in order to prevent the code from falling
through to the default case and return -EINVAL every time.

This bug was found thanks to the ongoing efforts to enable
-Wimplicit-fallthrough.

Fixes: 58dd7c0a2a6e ("Staging: comedi: add ni_660x driver")
Cc: sta...@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/comedi/drivers/ni_660x.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/comedi/drivers/ni_660x.c 
b/drivers/staging/comedi/drivers/ni_660x.c
index e70a461e723f..405573e927cf 100644
--- a/drivers/staging/comedi/drivers/ni_660x.c
+++ b/drivers/staging/comedi/drivers/ni_660x.c
@@ -656,6 +656,7 @@ static int ni_660x_set_pfi_routing(struct comedi_device 
*dev,
case NI_660X_PFI_OUTPUT_DIO:
if (chan > 31)
return -EINVAL;
+   break;
default:
return -EINVAL;
}
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8188eu: Replace kzalloc with kcalloc

2019-01-14 Thread Gustavo A. R. Silva
Replace kzalloc() function with its 2-factor argument form, kcalloc().

This patch replaces cases of:

kzalloc(a * b, gfp)

with:
kcalloc(a, b, gfp)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/rtl8188eu/core/rtw_efuse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c 
b/drivers/staging/rtl8188eu/core/rtw_efuse.c
index b7be71f904ed..51c3dd6d7ffb 100644
--- a/drivers/staging/rtl8188eu/core/rtw_efuse.c
+++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c
@@ -88,7 +88,9 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 
_size_byte, u8  *pbuf)
if (!efuseTbl)
return;
 
-   tmp = kzalloc(EFUSE_MAX_SECTION_88E * (sizeof(void *) + 
EFUSE_MAX_WORD_UNIT * sizeof(u16)), GFP_KERNEL);
+   tmp = kcalloc(EFUSE_MAX_SECTION_88E,
+ sizeof(void *) + EFUSE_MAX_WORD_UNIT * sizeof(u16),
+ GFP_KERNEL);
if (!tmp) {
DBG_88E("%s: alloc eFuseWord fail!\n", __func__);
goto eFuseWord_failed;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: mt7621-dma: Use struct_size() in devm_kzalloc()

2019-01-04 Thread Gustavo A. R. Silva
One of the more common cases of allocation size calculations is finding
the size of a structure that has a zero-sized array at the end, along
with memory for some number of elements for that array. For example:

struct foo {
int stuff;
void *entry[];
};

instance = devm_kzalloc(dev, sizeof(struct foo) + sizeof(void *) * count, 
GFP_KERNEL);

Instead of leaving these open-coded and prone to type mistakes, we can
now use the new struct_size() helper:

instance = devm_kzalloc(dev, struct_size(instance, entry, count), GFP_KERNEL);

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/mt7621-dma/ralink-gdma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-dma/ralink-gdma.c 
b/drivers/staging/mt7621-dma/ralink-gdma.c
index 792a63bd55d4..d78042eba6dd 100644
--- a/drivers/staging/mt7621-dma/ralink-gdma.c
+++ b/drivers/staging/mt7621-dma/ralink-gdma.c
@@ -821,9 +821,9 @@ static int gdma_dma_probe(struct platform_device *pdev)
return -EINVAL;
data = (struct gdma_data *) match->data;
 
-   dma_dev = devm_kzalloc(>dev, sizeof(*dma_dev) +
-   (sizeof(struct gdma_dmaengine_chan) * data->chancnt),
-   GFP_KERNEL);
+   dma_dev = devm_kzalloc(>dev,
+  struct_size(dma_dev, chan, data->chancnt),
+  GFP_KERNEL);
if (!dma_dev) {
dev_err(>dev, "alloc dma device failed\n");
return -EINVAL;
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wilc1000: fix memory leak in wilc_add_rx_gtk

2018-12-22 Thread Gustavo A. R. Silva
In case *mode* happens to be different than WILC_AP_MODE and
WILC_STATION_MODE, gtk_key is not released, hence leanding
to a memory leak. So, in this case it is safer to release
gtk_key just before returning to callers.

Addresses-Coverity-ID: 1476020 ("Resource leak")
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/wilc1000/host_interface.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 70c854d939ce..ee890a68e663 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1744,7 +1744,6 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 
*rx_gtk, u8 gtk_key_len,
result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list,
  ARRAY_SIZE(wid_list),
  wilc_get_vif_idx(vif));
-   kfree(gtk_key);
} else if (mode == WILC_STATION_MODE) {
struct wid wid;
 
@@ -1754,9 +1753,9 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 
*rx_gtk, u8 gtk_key_len,
wid.val = (u8 *)gtk_key;
result = wilc_send_config_pkt(vif, WILC_SET_CFG, , 1,
  wilc_get_vif_idx(vif));
-   kfree(gtk_key);
}
 
+   kfree(gtk_key);
return result;
 }
 
-- 
2.20.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 3/5] Drivers: hv: kvp: Fix the recent regression caused by incorrect clean-up

2018-10-16 Thread Gustavo A. R. Silva



On 10/17/18 7:07 AM, Greg KH wrote:
> On Wed, Oct 17, 2018 at 03:14:04AM +, k...@linuxonhyperv.com wrote:
>> From: Dexuan Cui 
>>
>> In kvp_send_key(), we do need call process_ib_ipinfo() if
>> message->kvp_hdr.operation is KVP_OP_GET_IP_INFO, because it turns out
>> the userland hv_kvp_daemon needs the info of operation, adapter_id and
>> addr_family. With the incorrect fc62c3b1977d, the host can't get the
>> VM's IP via KVP.
>>
>> And, fc62c3b1977d added a "break;", but actually forgot to initialize
>> the key_size/value in the case of KVP_OP_SET, so the default key_size of
>> 0 is passed to the kvp daemon, and the pool files
>> /var/lib/hyperv/.kvp_pool_* can't be updated.
>>
>> This patch effectively rolls back the previous fc62c3b1977d, and
>> correctly fixes the "this statement may fall through" warnings.
>>
>> This patch is tested on WS 2012 R2 and 2016.
>>
>> Fixes: fc62c3b1977d ("Drivers: hv: kvp: Fix two "this statement may fall 
>> through" warnings")
>> Signed-off-by: Dexuan Cui 
>> Cc: K. Y. Srinivasan 
>> Cc: Haiyang Zhang 
>> Cc: Stephen Hemminger 
>> Cc: 
>> Signed-off-by: K. Y. Srinivasan 
>> ---
>>  drivers/hv/hv_kvp.c | 26 ++
>>  1 file changed, 22 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
>> index a7513a8a8e37..9fbb15c62c6c 100644
>> --- a/drivers/hv/hv_kvp.c
>> +++ b/drivers/hv/hv_kvp.c
>> @@ -353,6 +353,9 @@ static void process_ib_ipinfo(void *in_msg, void 
>> *out_msg, int op)
>>  
>>  out->body.kvp_ip_val.dhcp_enabled = in->kvp_ip_val.dhcp_enabled;
>>  
>> +__attribute__ ((fallthrough));
> 
> The comment should be sufficient for this, right?  I haven't seen many
> uses of this attribute before, how common is it?
> 

It's not common at all.

Dexuan, please use a comment instead: /* fall through */

Thanks
--
Gustavo

> 
>> +
>> +case KVP_OP_GET_IP_INFO:
>>  utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.adapter_id,
>>  MAX_ADAPTER_ID_SIZE,
>>  UTF16_LITTLE_ENDIAN,
>> @@ -405,7 +408,11 @@ kvp_send_key(struct work_struct *dummy)
>>  process_ib_ipinfo(in_msg, message, KVP_OP_SET_IP_INFO);
>>  break;
>>  case KVP_OP_GET_IP_INFO:
>> -/* We only need to pass on message->kvp_hdr.operation.  */
>> +/*
>> + * We only need to pass on the info of operation, adapter_id
>> + * and addr_family to the userland kvp daemon.
>> + */
>> +process_ib_ipinfo(in_msg, message, KVP_OP_GET_IP_INFO);
>>  break;
>>  case KVP_OP_SET:
>>  switch (in_msg->body.kvp_set.data.value_type) {
>> @@ -446,9 +453,9 @@ kvp_send_key(struct work_struct *dummy)
>>  
>>  }
>>  
>> -break;
>> -
>> -case KVP_OP_GET:
>> +/*
>> + * The key is always a string - utf16 encoding.
>> + */
>>  message->body.kvp_set.data.key_size =
>>  utf16s_to_utf8s(
>>  (wchar_t *)in_msg->body.kvp_set.data.key,
>> @@ -456,6 +463,17 @@ kvp_send_key(struct work_struct *dummy)
>>  UTF16_LITTLE_ENDIAN,
>>  message->body.kvp_set.data.key,
>>  HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1;
>> +
>> +break;
>> +
>> +case KVP_OP_GET:
>> +message->body.kvp_get.data.key_size =
>> +utf16s_to_utf8s(
>> +(wchar_t *)in_msg->body.kvp_get.data.key,
>> +in_msg->body.kvp_get.data.key_size,
>> +UTF16_LITTLE_ENDIAN,
>> +message->body.kvp_get.data.key,
>> +HV_KVP_EXCHANGE_MAX_KEY_SIZE - 1) + 1;
> 
> Worst indentation ever :(
> 
> Yeah, I know it follows the others above it, but you should reconsider
> it in the future...
> 
> thanks,
> 
> greg k-h
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: comedi: tio: fix multiple missing break in switch bugs

2018-10-12 Thread Gustavo A. R. Silva


On 10/12/18 11:04 AM, Ian Abbott wrote:
> On 11/10/2018 20:05, Gustavo A. R. Silva wrote:
>> Currently, there are multiple missing break statements in two switch code
>> blocks. This makes the execution path to fall all the way down through
>> to the default cases, which makes the function ni_tio_set_gate_src() to
>> always return -EINVAL.
>>
>> Fix this by adding the missing break statements.
>>
>> Also, notice that due to the absence of the break statements,
>> the following pieces of code are unreachable:
>>
>> 1078    if (ret)
>> 1079    return ret;
>> 1080    /* 3.  reenable & set mode to starts things back up */
>> 1081    ni_tio_set_gate_mode(counter, src);
>>
>> 1098    if (ret)
>> 1099    return ret;
>> 1100    /* 3.  reenable & set mode to starts things back up */
>> 1101    ni_tio_set_gate2_mode(counter, src);
>>
>> So, by adding the missing breaks, this patch also fixes the problem
>> above.
>>
>> Addresses-Coverity-ID: 1474165 ("Missing break in switch")
>> Addresses-Coverity-ID: 1474162 ("Structurally dead code")
>> Fixes: 347e244884c3 ("staging: comedi: tio: implement global tio/ctr 
>> routing")
>> Signed-off-by: Gustavo A. R. Silva 
>> ---
>>   drivers/staging/comedi/drivers/ni_tio.c | 4 
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
>> b/drivers/staging/comedi/drivers/ni_tio.c
>> index 838614e..0eb388c 100644
>> --- a/drivers/staging/comedi/drivers/ni_tio.c
>> +++ b/drivers/staging/comedi/drivers/ni_tio.c
>> @@ -1070,8 +1070,10 @@ int ni_tio_set_gate_src(struct ni_gpct *counter,
>>   case ni_gpct_variant_e_series:
>>   case ni_gpct_variant_m_series:
>>   ret = ni_m_set_gate(counter, chan);
>> +    break;
>>   case ni_gpct_variant_660x:
>>   ret = ni_660x_set_gate(counter, chan);
>> +    break;
>>   default:
>>   return -EINVAL;
>>   }
>> @@ -1090,8 +1092,10 @@ int ni_tio_set_gate_src(struct ni_gpct *counter,
>>   switch (counter_dev->variant) {
>>   case ni_gpct_variant_m_series:
>>   ret = ni_m_set_gate2(counter, chan);
>> +    break;
>>   case ni_gpct_variant_660x:
>>   ret = ni_660x_set_gate2(counter, chan);
>> +    break;
>>   default:
>>   return -EINVAL;
>>   }
>>
> 
> Thanks for catching that bug!
> 

Glad to help. :)

> Reviewed-by: Ian Abbott 
> 

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: comedi: tio: fix multiple missing break in switch bugs

2018-10-11 Thread Gustavo A. R. Silva
Currently, there are multiple missing break statements in two switch code
blocks. This makes the execution path to fall all the way down through
to the default cases, which makes the function ni_tio_set_gate_src() to
always return -EINVAL.

Fix this by adding the missing break statements.

Also, notice that due to the absence of the break statements,
the following pieces of code are unreachable:

1078if (ret)
1079return ret;
1080/* 3.  reenable & set mode to starts things back up */
1081ni_tio_set_gate_mode(counter, src);

1098if (ret)
1099return ret;
1100/* 3.  reenable & set mode to starts things back up */
1101ni_tio_set_gate2_mode(counter, src);

So, by adding the missing breaks, this patch also fixes the problem
above.

Addresses-Coverity-ID: 1474165 ("Missing break in switch")
Addresses-Coverity-ID: 1474162 ("Structurally dead code")
Fixes: 347e244884c3 ("staging: comedi: tio: implement global tio/ctr routing")
Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/comedi/drivers/ni_tio.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/comedi/drivers/ni_tio.c 
b/drivers/staging/comedi/drivers/ni_tio.c
index 838614e..0eb388c 100644
--- a/drivers/staging/comedi/drivers/ni_tio.c
+++ b/drivers/staging/comedi/drivers/ni_tio.c
@@ -1070,8 +1070,10 @@ int ni_tio_set_gate_src(struct ni_gpct *counter,
case ni_gpct_variant_e_series:
case ni_gpct_variant_m_series:
ret = ni_m_set_gate(counter, chan);
+   break;
case ni_gpct_variant_660x:
ret = ni_660x_set_gate(counter, chan);
+   break;
default:
return -EINVAL;
}
@@ -1090,8 +1092,10 @@ int ni_tio_set_gate_src(struct ni_gpct *counter,
switch (counter_dev->variant) {
case ni_gpct_variant_m_series:
ret = ni_m_set_gate2(counter, chan);
+   break;
case ni_gpct_variant_660x:
ret = ni_660x_set_gate2(counter, chan);
+   break;
default:
return -EINVAL;
}
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: erofs: adds a space around '*'

2018-10-08 Thread Gustavo A. R. Silva
Hi,

On 10/8/18 1:45 PM, Daeseok Youn wrote:
> fix checkpatch.pl error:
> ERROR: need consistent spacing around '*' (ctx:WxV)
> +   memcpy(vin + PAGE_SIZE *i, t, PAGE_SIZE);
> 
> Signed-off-by: Daeseok Youn 
> ---
>  drivers/staging/erofs/unzip_vle_lz4.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/erofs/unzip_vle_lz4.c 
> b/drivers/staging/erofs/unzip_vle_lz4.c
> index f5b665f..501cfe0 100644
> --- a/drivers/staging/erofs/unzip_vle_lz4.c
> +++ b/drivers/staging/erofs/unzip_vle_lz4.c
> @@ -181,7 +181,7 @@ int z_erofs_vle_unzip_vmap(struct page **compressed_pages,
>   for (i = 0; i < clusterpages; ++i) {
>   void *t = kmap_atomic(compressed_pages[i]);
>  
> - memcpy(vin + PAGE_SIZE *i, t, PAGE_SIZE);
> + memcpy(vin + PAGE_SIZE * i, t, PAGE_SIZE);
>   kunmap_atomic(t);
>   }
>   } else if (clusterpages == 1)
> 

This exact fix was applied to linux-next some days ago:

commit ea0b2d429bd82ec152d286a0c026ebcaa4154ccc

Make sure you are working from linux-next rather than from mainline.

See this link: https://www.kernel.org/doc/man-pages/linux-next.html

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: emxx_udc: remove unused code

2018-10-08 Thread Gustavo A. R. Silva
Hi,

On 10/8/18 9:33 AM, Loic Tourlonias wrote:
> Remove useless code inside if_0 endif
> 
> Signed-off-by: Loic Tourlonias 
> ---
>  drivers/staging/emxx_udc/emxx_udc.h | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/drivers/staging/emxx_udc/emxx_udc.h 
> b/drivers/staging/emxx_udc/emxx_udc.h
> index 8337e38c238a..78fa60192a14 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.h
> +++ b/drivers/staging/emxx_udc/emxx_udc.h
> @@ -10,10 +10,6 @@
>  
>  
> /*---*/
>  /*- Default undef */
> -#if 0
> -#define DEBUG
> -#define UDC_DEBUG_DUMP
> -#endif
>  

Don't remove that code. This is a common practice for debugging.

Whenever the developer needs to debug something in the whole driver, he/she
just has to change that #if 0 to #if 1 and then all the code under DEBUG
and UDC_DEBUG_DUMP will be enabled.

Notice that UDC_DEBUG_DUMP is being used in drivers/staging/emxx_udc/emxx_udc.c

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] Staging: rts5208: rtsx_card: Fixed multiple coding style issues

2018-10-06 Thread Gustavo A. R. Silva
Hi,

On 9/29/18 4:03 AM, Maxime Desroches wrote:
> Fixed multiple coding style issues
> 

What kind of style issues are you trying to fix?

Please, always be specific about what you are trying to fix. This makes
it easier for the maintainers to review your patch and give you feedback.

Thanks
--
Gustavo

> Signed-off-by: Maxime Desroches 
> ---
>  drivers/staging/rts5208/rtsx_card.c | 96 +++--
>  1 file changed, 37 insertions(+), 59 deletions(-)
> 
> diff --git a/drivers/staging/rts5208/rtsx_card.c 
> b/drivers/staging/rts5208/rtsx_card.c
> index d26a8e372fce..b45abbe29bc2 100644
> --- a/drivers/staging/rts5208/rtsx_card.c
> +++ b/drivers/staging/rts5208/rtsx_card.c
> @@ -647,9 +647,8 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
>   dev_dbg(rtsx_dev(chip), "Switch SSC clock to %dMHz (cur_clk = %d)\n",
>   clk, chip->cur_clk);
>  
> - if ((clk <= 2) || (n > max_n)) {
> + if ((clk <= 2) || (n > max_n))
>   return STATUS_FAIL;
> - }
>  
>   mcu_cnt = (u8)(125 / clk + 3);
>   if (mcu_cnt > 7)
> @@ -688,15 +687,13 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
>   }
>  
>   retval = rtsx_send_cmd(chip, 0, WAIT_TIME);
> - if (retval < 0) {
> + if (retval < 0)
>   return STATUS_ERROR;
> - }
>  
>   udelay(10);
>   retval = rtsx_write_register(chip, CLK_CTL, CLK_LOW_FREQ, 0);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>  
>   chip->cur_clk = clk;
>  
> @@ -790,49 +787,44 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk)
>   }
>  
>   retval = rtsx_write_register(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>   if (sd_vpclk_phase_reset) {
>   retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
>PHASE_NOT_RESET, 0);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
> +
>   retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
>PHASE_NOT_RESET, 0);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>   }
>   retval = rtsx_write_register(chip, CLK_DIV, 0xFF,
>(div << 4) | mcu_cnt);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>   retval = rtsx_write_register(chip, CLK_SEL, 0xFF, sel);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>  
>   if (sd_vpclk_phase_reset) {
>   udelay(200);
>   retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
>PHASE_NOT_RESET, PHASE_NOT_RESET);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
> +
>   retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
>PHASE_NOT_RESET, PHASE_NOT_RESET);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
> +
>   udelay(200);
>   }
>   retval = rtsx_write_register(chip, CLK_CTL, 0xFF, 0);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>  
>   chip->cur_clk = clk;
>  
> @@ -878,9 +870,8 @@ int enable_card_clock(struct rtsx_chip *chip, u8 card)
>   clk_en |= MS_CLK_EN;
>  
>   retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, clk_en);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>  
>   return STATUS_SUCCESS;
>  }
> @@ -898,9 +889,8 @@ int disable_card_clock(struct rtsx_chip *chip, u8 card)
>   clk_en |= MS_CLK_EN;
>  
>   retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, 0);
> - if (retval) {
> + if (retval)
>   return retval;
> - }
>  
>   return STATUS_SUCCESS;
>  }
> @@ -924,9 +914,8 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
>   rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val1);
>  
>   retval = rtsx_send_cmd(chip, 0, 100);
> - if (retval != STATUS_SUCCESS) {
> + if (retval != STATUS_SUCCESS)
>   return STATUS_FAIL;
> - }
>  
>   udelay(chip->pmos_pwr_on_interval);
>  
> @@ -934,9 +923,8 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
>   rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val2);
>  
>   retval = rtsx_send_cmd(chip, 0, 100);
> - if (retval != STATUS_SUCCESS) {
> + if (retval != STATUS_SUCCESS)
>   return STATUS_FAIL;
> - }
>  
>   return STATUS_SUCCESS;
>  }
> @@ -955,9 +943,8 @@ int card_power_off(struct rtsx_chip *chip, u8 card)
>   }
>  
>   retval = rtsx_write_register(chip, CARD_PWR_CTL, 

Re: [PATCH] staging/rtlwifi: Fixing formatting warnings.

2018-10-05 Thread Gustavo A. R. Silva



On 10/5/18 10:58 PM, Scott Tracy wrote:
> Signed-off-by: Scott Tracy 
> ---
>  drivers/staging/rtlwifi/core.c  | 5 +++--
>  drivers/staging/rtlwifi/efuse.c | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c
> index ca37f7511c4d..a36cb44a5388 100644
> --- a/drivers/staging/rtlwifi/core.c
> +++ b/drivers/staging/rtlwifi/core.c
> @@ -1109,7 +1109,7 @@ static void rtl_op_bss_info_changed(struct ieee80211_hw 
> *hw,
>   if (rtlpriv->dm.supp_phymode_switch) {
>   if (sta->ht_cap.ht_supported)
>   rtl_send_smps_action(hw, sta,
> -  
> IEEE80211_SMPS_STATIC);
> + IEEE80211_SMPS_STATIC);
>   }
>  
>   if (rtlhal->current_bandtype == BAND_ON_5G) {
> @@ -1882,7 +1882,8 @@ bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, 
> u8 cut_version,
>   return true;
>   default:
>   WARN_ONCE(true,
> -   "rtlwifi: %s(): Unknown CMD!!\n", 
> __func__);
> +  "rtlwifi: %s(): Unknown CMD!!\n",
> +   __func__);
>   break;
>   }
>   }
> diff --git a/drivers/staging/rtlwifi/efuse.c b/drivers/staging/rtlwifi/efuse.c
> index 1dc71455f270..5b8afdb3e0fe 100644
> --- a/drivers/staging/rtlwifi/efuse.c
> +++ b/drivers/staging/rtlwifi/efuse.c
> @@ -245,7 +245,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 
> _size_byte, u8 *pbuf)
>   if (!efuse_word)
>   goto out;
>   for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) {
> - efuse_word[i] = kcalloc(efuse_max_section, sizeof(u16), 
> GFP_ATOMIC);
> + efuse_word[i] = kcalloc(efuse_max_section,
> + sizeof(u16), GFP_ATOMIC);
>   if (!efuse_word[i])
>   goto done;
>   }
> @@ -375,7 +376,7 @@ bool efuse_shadow_update_chk(struct ieee80211_hw *hw)
>   for (i = 0; i < 8; i = i + 2) {
>   if ((rtlefuse->efuse_map[EFUSE_INIT_MAP][base + i] !=
>rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base + i]) ||
> - (rtlefuse->efuse_map[EFUSE_INIT_MAP][base + i + 1] 
> !=
> +(rtlefuse->efuse_map[EFUSE_INIT_MAP][base + i + 1] !=
>rtlefuse->efuse_map[EFUSE_MODIFY_MAP][base + i +
>  1])) {
>   words_need++;
> 

Hi,

Please, always add a commit log explaining what exactly are you trying to fix.

Thanks
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Drivers: hv: hv_kvp: Mark expected switch fall-through

2018-07-02 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/hv/hv_kvp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c
index 5eed1e7..9b1adcb 100644
--- a/drivers/hv/hv_kvp.c
+++ b/drivers/hv/hv_kvp.c
@@ -352,6 +352,7 @@ static void process_ib_ipinfo(void *in_msg, void *out_msg, 
int op)
MAX_IP_ADDR_SIZE);
 
out->body.kvp_ip_val.dhcp_enabled = in->kvp_ip_val.dhcp_enabled;
+   /* fall through */
 
default:
utf16s_to_utf8s((wchar_t *)in->kvp_ip_val.adapter_id,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access

2018-04-30 Thread Gustavo A. R. Silva
If i < slot_id is initially true then it will remain true. Also,
as i is being decremented it will end up accessing memory out of
bounds.

Fix this by incrementing *i* instead of decrementing it.

Addresses-Coverity-ID: 1468454 ("Infinite loop")
Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free kmalloc
memory on failure cases")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---

BTW... at first sight it seems to me that variables slot_id
and i should be of type unsigned instead of signed.

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

diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index 3ca0c97..67104e8 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -608,7 +608,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request 
*request,
 
 out_free:
 
-   for (i = 0; i < slot_id ; i--)
+   for (i = 0; i < slot_id; i++)
kfree(ntwk->net_info[i].ssid);
 
kfree(ntwk->net_info);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: media: davinci_vpfe: fix spin_lock/unlock imbalance

2018-04-18 Thread Gustavo A. R. Silva
It seems that this is a copy-paste error and that the proper
variable to use in this particular case is video_out2 instead
of video_out.

Addresses-Coverity-ID: 1467961 ("Copy-paste error")
Fixes: 45e46b3bbe18 ("[media] davinci: vpfe: dm365: resizer driver based on 
media framework")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/staging/media/davinci_vpfe/dm365_resizer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c 
b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
index df6d55e..2b79747 100644
--- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c
+++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c
@@ -1060,7 +1060,7 @@ static void resizer_ss_isr(struct vpfe_resizer_device 
*resizer)
/* If resizer B is enabled */
if (pipe->output_num > 1 && resizer->resizer_b.output ==
RESIZER_OUTPUT_MEMORY) {
-   spin_lock(_out->dma_queue_lock);
+   spin_lock(_out2->dma_queue_lock);
vpfe_video_process_buffer_complete(video_out2);
video_out2->state = VPFE_VIDEO_BUFFER_NOT_QUEUED;
vpfe_video_schedule_next_buffer(video_out2);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging: ks7010_sdio: fix NULL pointer dereference and memory leak

2018-04-12 Thread Gustavo A. R. Silva
priv is being explicitly dereferenced when it is still null, when
jumping to goto label err_free_netdev, before it is properly
updated with a valid memory address.

Also, when this happens, memory allocated for netdev at line 854:
netdev = alloc_etherdev(sizeof(*priv)) is not being free'd before
return, hence there is a memory leak.

The current code looks a bit too complicated and can be replaced
by just directly freeing netdev before return.

Notice that card->priv = NULL isn't required because the next thing
we do to card is kfree(card).

Addresses-Coverity-ID: 1467844 ("Explicit null dereferenced")
Suggested-by: Dan Carpenter <dan.carpen...@oracle.com>
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
Changes in v3:
 - Update subject and improve changelog.
 - Add Suggested-by: Dan Carpenter <dan.carpen...@oracle.com>

Changes in v2:
 - Update subject and commit changelog.
 - Just directly free netdev. Thanks to Dan Carpenter for the feedback.

 drivers/staging/ks7010/ks7010_sdio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a1..2c9b92c 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -932,8 +932,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
return 0;
 
  err_free_netdev:
-   free_netdev(priv->net_dev);
-   card->priv = NULL;
+   free_netdev(netdev);
  err_release_irq:
sdio_claim_host(func);
sdio_release_irq(func);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: ks7010_sdio: fix NULL pointer dereference and memory leak

2018-04-12 Thread Gustavo A. R. Silva

Hi Dan,

On 04/12/2018 10:08 AM, Dan Carpenter wrote:

I added Colin to the Cc list.

On Thu, Apr 12, 2018 at 09:30:09AM -0500, Gustavo A. R. Silva wrote:

priv is being dereferenced when it is still null, hence there is an
explicit null pointer dereference at line 935: free_netdev(priv->net_dev)

Also, memory allocated for netdev at line 854:
netdev = alloc_etherdev(sizeof(*priv));
is not being free'd, hence there is a memory leak.

Fix this by null checking priv before dererefencing it and free netdev
before return.

Addresses-Coverity-ID: 1467844 ("Explicit null dereferenced")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
  drivers/staging/ks7010/ks7010_sdio.c | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a1..f5d4c62 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -932,8 +932,12 @@ static int ks7010_sdio_probe(struct sdio_func *func,
return 0;
  
   err_free_netdev:

-   free_netdev(priv->net_dev);
-   card->priv = NULL;
+   if (priv) {
+   free_netdev(priv->net_dev);
+   card->priv = NULL;


This isn't required because the next thing we do to card is kfree(card).



I got it.


+   } else {
+   free_netdev(netdev);
+   }



That's too complicated.  Just do:

err_free_netdev:
free_netdev(net_dev);

err_release_irq:
...

Please send a v2 patch.



Sure thing, I'll send it shortly.

Thanks for the feedback.
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: ks7010_sdio: fix memory leak

2018-04-12 Thread Gustavo A. R. Silva
Memory allocated for netdev at line 854:
netdev = alloc_etherdev(sizeof(*priv));
is not being free'd before return, hence
there is a memory leak.

Fix this by freeing netdev before return.

Addresses-Coverity-ID: 1467844
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
Changes in v2:
 - Update subject and commit changelog.
 - Just directly free netdev. Thanks to Dan Carpenter for the feedback.

 drivers/staging/ks7010/ks7010_sdio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a1..2c9b92c 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -932,8 +932,7 @@ static int ks7010_sdio_probe(struct sdio_func *func,
return 0;
 
  err_free_netdev:
-   free_netdev(priv->net_dev);
-   card->priv = NULL;
+   free_netdev(netdev);
  err_release_irq:
sdio_claim_host(func);
sdio_release_irq(func);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: ks7010_sdio: fix NULL pointer dereference and memory leak

2018-04-12 Thread Gustavo A. R. Silva
priv is being dereferenced when it is still null, hence there is an
explicit null pointer dereference at line 935: free_netdev(priv->net_dev)

Also, memory allocated for netdev at line 854:
netdev = alloc_etherdev(sizeof(*priv));
is not being free'd, hence there is a memory leak.

Fix this by null checking priv before dererefencing it and free netdev
before return.

Addresses-Coverity-ID: 1467844 ("Explicit null dereferenced")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/staging/ks7010/ks7010_sdio.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index b8f55a1..f5d4c62 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -932,8 +932,12 @@ static int ks7010_sdio_probe(struct sdio_func *func,
return 0;
 
  err_free_netdev:
-   free_netdev(priv->net_dev);
-   card->priv = NULL;
+   if (priv) {
+   free_netdev(priv->net_dev);
+   card->priv = NULL;
+   } else {
+   free_netdev(netdev);
+   }
  err_release_irq:
sdio_claim_host(func);
sdio_release_irq(func);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 4/4] video: Remove stack VLA usage

2018-03-08 Thread Gustavo A. R. Silva


I sent a patch for this six hours ago:

https://patchwork.kernel.org/patch/10268591/

--
Gustavo

On 03/09/2018 12:11 AM, Tycho Andersen wrote:

On Thu, Mar 08, 2018 at 10:01:07PM -0800, Joe Perches wrote:

On Fri, 2018-03-09 at 16:50 +1100, Tobin C. Harding wrote:

The kernel would like to have all stack VLA usage removed[1].  The
arrays are fixed here (declared with a const variable) but they appear
like VLAs to the compiler.  We can use a pre-processor define to fix the
warning.

[]

diff --git a/drivers/video/fbdev/via/via_aux_sii164.c 
b/drivers/video/fbdev/via/via_aux_sii164.c

[]

@@ -27,6 +27,9 @@
  
  static const char *name = "SiI 164 PanelLink Transmitter";
  
+/* check vendor id and device id */

+const u8 id[] = {0x01, 0x00, 0x06, 0x00};


It seems id is now global in multiple places.
Perhaps these should be static.


Does it even need to be global? Why not just get rid of the indirection and use
ARRAY_SIZE where we mean it? This seems to work for me,

diff --git a/drivers/video/fbdev/via/via_aux_sii164.c 
b/drivers/video/fbdev/via/via_aux_sii164.c
index ca1b35f033b1..87db6c98d680 100644
--- a/drivers/video/fbdev/via/via_aux_sii164.c
+++ b/drivers/video/fbdev/via/via_aux_sii164.c
@@ -35,10 +35,10 @@ static void probe(struct via_aux_bus *bus, u8 addr)
 .addr   =   addr,
 .name   =   name};
 /* check vendor id and device id */
-   const u8 id[] = {0x01, 0x00, 0x06, 0x00}, len = ARRAY_SIZE(id);
-   u8 tmp[len];
+   const u8 id[] = {0x01, 0x00, 0x06, 0x00};
+   u8 tmp[ARRAY_SIZE(id)];
  
-   if (!via_aux_read(, 0x00, tmp, len) || memcmp(id, tmp, len))

+   if (!via_aux_read(, 0x00, tmp, sizeof(tmp)) || memcmp(id, tmp, 
sizeof(tmp)))
 return;
  
 printk(KERN_INFO "viafb: Found %s at address 0x%x\n", name, addr);


Cheers,

Tycho




___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging/imx: Fix inconsistent IS_ERR and PTR_ERR

2018-02-28 Thread Gustavo A. R. Silva
Fix inconsistent IS_ERR and PTR_ERR in imx_csi_probe.
The proper pointer to be passed as argument is pinctrl
instead of priv->vdev.

This issue was detected with the help of Coccinelle.

Fixes: 52e17089d185 ("media: imx: Don't initialize vars that won't be used")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/staging/media/imx/imx-media-csi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 5a195f8..4f290a0 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1798,7 +1798,7 @@ static int imx_csi_probe(struct platform_device *pdev)
priv->dev->of_node = pdata->of_node;
pinctrl = devm_pinctrl_get_select_default(priv->dev);
if (IS_ERR(pinctrl)) {
-   ret = PTR_ERR(priv->vdev);
+   ret = PTR_ERR(pinctrl);
goto free;
}
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: imx-media-vdic: fix inconsistent IS_ERR and PTR_ERR

2018-02-19 Thread Gustavo A. R. Silva

Hi Philipp,

On 02/19/2018 08:23 AM, Philipp Zabel wrote:

Hi Gustavo,

On Wed, 2018-02-14 at 14:57 -0600, Gustavo A. R. Silva wrote:

Hi all,

I was just wondering about the status of this patch.


It is en route as commit dcd71a9292b1 ("staging: imx-media-vdic: fix
inconsistent IS_ERR and PTR_ERR") in Hans' for-v4.17a branch:
   git://linuxtv.org/hverkuil/media_tree.git for-v4.17a



Awesome.

Thanks for the info.
--
Gustavo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: imx-media-vdic: fix inconsistent IS_ERR and PTR_ERR

2018-02-14 Thread Gustavo A. R. Silva

Hi all,

I was just wondering about the status of this patch.

Thanks
--
Gustavo

On 01/24/2018 06:14 PM, Steve Longerbeam wrote:

Acked-by: Steve Longerbeam <steve_longerb...@mentor.com>


On 01/23/2018 04:43 PM, Gustavo A. R. Silva wrote:

Fix inconsistent IS_ERR and PTR_ERR in vdic_get_ipu_resources.
The proper pointer to be passed as argument is ch.

This issue was detected with the help of Coccinelle.

Fixes: 0b2e9e7947e7 ("media: staging/imx: remove confusing 
IS_ERR_OR_NULL usage")

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
  drivers/staging/media/imx/imx-media-vdic.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-vdic.c 
b/drivers/staging/media/imx/imx-media-vdic.c

index 433474d..ed35684 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -177,7 +177,7 @@ static int vdic_get_ipu_resources(struct vdic_priv 
*priv)

  priv->vdi_in_ch = ch;
  ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_NEXT);
-    if (IS_ERR(priv->vdi_in_ch_n)) {
+    if (IS_ERR(ch)) {
  err_chan = IPUV3_CHANNEL_MEM_VDI_NEXT;
  ret = PTR_ERR(ch);
  goto out_err_chan;




___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: imx-media-vdic: fix inconsistent IS_ERR and PTR_ERR

2018-01-25 Thread Gustavo A. R. Silva


Quoting Arnd Bergmann <a...@arndb.de>:


On Wed, Jan 24, 2018 at 1:43 AM, Gustavo A. R. Silva
<gust...@embeddedor.com> wrote:

Fix inconsistent IS_ERR and PTR_ERR in vdic_get_ipu_resources.
The proper pointer to be passed as argument is ch.

This issue was detected with the help of Coccinelle.

Fixes: 0b2e9e7947e7 ("media: staging/imx: remove confusing  
IS_ERR_OR_NULL usage")

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>


good catch!



:)


Acked-by: Arnd Bergmann <a...@arndb.de>


Thanks, Arnd.
--
Gustavo




___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: imx-media-vdic: fix inconsistent IS_ERR and PTR_ERR

2018-01-23 Thread Gustavo A. R. Silva
Fix inconsistent IS_ERR and PTR_ERR in vdic_get_ipu_resources.
The proper pointer to be passed as argument is ch.

This issue was detected with the help of Coccinelle.

Fixes: 0b2e9e7947e7 ("media: staging/imx: remove confusing IS_ERR_OR_NULL 
usage")
Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/staging/media/imx/imx-media-vdic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-vdic.c 
b/drivers/staging/media/imx/imx-media-vdic.c
index 433474d..ed35684 100644
--- a/drivers/staging/media/imx/imx-media-vdic.c
+++ b/drivers/staging/media/imx/imx-media-vdic.c
@@ -177,7 +177,7 @@ static int vdic_get_ipu_resources(struct vdic_priv *priv)
priv->vdi_in_ch = ch;
 
ch = ipu_idmac_get(priv->ipu, IPUV3_CHANNEL_MEM_VDI_NEXT);
-   if (IS_ERR(priv->vdi_in_ch_n)) {
+   if (IS_ERR(ch)) {
err_chan = IPUV3_CHANNEL_MEM_VDI_NEXT;
ret = PTR_ERR(ch);
goto out_err_chan;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] android: binder: Use true and false for boolean values

2018-01-23 Thread Gustavo A. R. Silva
Assign true or false to boolean variables instead of an integer value.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gust...@embeddedor.com>
---
 drivers/android/binder.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index 745b03a..d21040c 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -249,7 +249,7 @@ static struct binder_transaction_log_entry 
*binder_transaction_log_add(
unsigned int cur = atomic_inc_return(>cur);
 
if (cur >= ARRAY_SIZE(log->entry))
-   log->full = 1;
+   log->full = true;
e = >entry[cur % ARRAY_SIZE(log->entry)];
WRITE_ONCE(e->debug_id_done, 0);
/*
@@ -2638,7 +2638,7 @@ static bool binder_proc_transaction(struct 
binder_transaction *t,
if (node->has_async_transaction) {
pending_async = true;
} else {
-   node->has_async_transaction = 1;
+   node->has_async_transaction = true;
}
}
 
@@ -3483,7 +3483,7 @@ static int binder_thread_write(struct binder_proc *proc,
w = binder_dequeue_work_head_ilocked(
_node->async_todo);
if (!w) {
-   buf_node->has_async_transaction = 0;
+   buf_node->has_async_transaction = false;
} else {
binder_enqueue_work_ilocked(
w, >todo);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: speakup: selection: replace _manual_ swap with swap macro

2017-11-10 Thread Gustavo A. R. Silva
Make use of the swap macro instead of _manually_ swapping values
and remove unnecessary variable tmp.

This makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/speakup/selection.c | 9 ++---
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/speakup/selection.c 
b/drivers/staging/speakup/selection.c
index 66061b5..0ed1fef 100644
--- a/drivers/staging/speakup/selection.c
+++ b/drivers/staging/speakup/selection.c
@@ -64,13 +64,8 @@ int speakup_set_selection(struct tty_struct *tty)
ps = spk_ys * vc->vc_size_row + (spk_xs << 1);
pe = spk_ye * vc->vc_size_row + (spk_xe << 1);
 
-   if (ps > pe) {
-   /* make sel_start <= sel_end */
-   int tmp = ps;
-
-   ps = pe;
-   pe = tmp;
-   }
+   if (ps > pe)/* make sel_start <= sel_end */
+   swap(ps, pe);
 
if (spk_sel_cons != vc_cons[fg_console].d) {
speakup_clear_selection();
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 00/20] mark expected switch fall-throughs

2017-10-23 Thread Gustavo A. R. Silva


Quoting "Gustavo A. R. Silva" <garsi...@embeddedor.com>:


In preparation to enabling -Wimplicit-fallthrough, this patchset aims
to mark switch cases where we are expecting to fall through.

In Kees Cook words:
"This is an unfortunate omission in the C language, and thankfully both
gcc and clang have stepped up to solve this the same way static
analyzers have solved it. It does both document the intention for
humans and provide a way for analyzers to report issues.

Having the compiler help us not make mistakes is quite handy."

In some cases there were "no break" or "fall thru" comments already
in place. So I replaced them with proper "fall through" comments, which
is what GCC is expecting to find.

For the rest of the cases, please double check if the actual intention
of the code is to fall through.

Thanks!

Gustavo A. R. Silva (20):
  staging: ks7010: ks_wlan_net: mark expected switch fall-throughs
  staging: lustre: lnet: socklnd: mark expected switch fall-through
  staging: rtl8192e: mark expected switch fall-through
  staging: rtl8723bs: rtw_mlme_ext: mark expected switch fall-through
  staging: lustre: lnet: net_fault: mark expected switch fall-through
  staging: comedi: s526: mark expected switch fall-through
  staging: rtl8188eu: usb_halinit: mark expected switch fall-through
  staging: vc04_services: vchiq_core: mark expected switch fall-through
  staging: vt6656: card: mark expected switch fall-throughs
  staging: rtl8188eu: usb_ops_linux: mark expected switch fall-through
  staging: r8822be: mark expected switch fall-throughs
  staging: lustre: lnet: selftest: mark expected switch fall-through
  staging: rtlwifi: halmac: mark expected switch fall-through
  staging: lustre: lnet: selftest: mark expected switch fall-throughs
  staging: lustre: llite: mark expected switch fall-through
  staging: lustre: lprocfs: mark expected switch fall-throughs
  staging: lustre: ldlm: mark expected switch fall-through
  staging: lustre: osc: mark expected switch fall-through
  staging: lustre: ptlrpc: mark expected switch fall-throughs
  staging: lustre: rpc: mark expected switch fall-throughs

 drivers/staging/comedi/drivers/s526.c   |  5 ++---
 drivers/staging/ks7010/ks_wlan_net.c| 10 ++
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c |  2 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c|  1 +
 drivers/staging/lustre/lnet/selftest/conctl.c   |  1 +
 drivers/staging/lustre/lnet/selftest/module.c   |  5 -
 drivers/staging/lustre/lnet/selftest/rpc.c  | 13  
+

 drivers/staging/lustre/lustre/ldlm/ldlm_request.c   |  1 +
 drivers/staging/lustre/lustre/llite/namei.c |  4 +++-
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c |  4 
 drivers/staging/lustre/lustre/osc/osc_cache.c   |  1 +
 drivers/staging/lustre/lustre/ptlrpc/pack_generic.c |  6 +++---
 drivers/staging/rtl8188eu/hal/usb_halinit.c |  1 +
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c|  1 +
 drivers/staging/rtl8192e/rtllib_wx.c|  3 +--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c   |  2 +-
 .../staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c|  2 ++
 drivers/staging/rtlwifi/halmac/rtl_halmac.c |  2 +-
 .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c  |  3 +--
 drivers/staging/vt6656/card.c   |  2 ++
 20 files changed, 50 insertions(+), 19 deletions(-)

--
2.7.4


Andreas, Stefan:
Thank you for your reviews and ACKs

Greg:
Thank you for applying the patches.

--
Gustavo A. R. Silva





___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: media: imx: fix inconsistent IS_ERR and PTR_ERR

2017-10-17 Thread Gustavo A. R. Silva
Fix inconsistent IS_ERR and PTR_ERR in csi_link_validate.
The proper pointer to be passed as argument is sensor.

This issue was detected with the help of Coccinelle.

Reported-by: Julia Lawall <julia.law...@lip6.fr>
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
This code was tested by compilation only.

 drivers/staging/media/imx/imx-media-csi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index 6d85611..2fa72c1 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -989,7 +989,7 @@ static int csi_link_validate(struct v4l2_subdev *sd,
sensor = __imx_media_find_sensor(priv->md, >sd.entity);
if (IS_ERR(sensor)) {
v4l2_err(>sd, "no sensor attached\n");
-   return PTR_ERR(priv->sensor);
+   return PTR_ERR(sensor);
}
 
mutex_lock(>lock);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 19/20] staging: lustre: ptlrpc: mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lustre/ptlrpc/pack_generic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c 
b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index aad4ff1..a3664c1 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -786,7 +786,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
 
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
}
-   /* no break */
+   /* fall through */
default:
/* flags might be printed in debug code while message
 * uninitialized
@@ -854,7 +854,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
 
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
}
-   /* no break */
+   /* fall through */
default:
return 0;
}
@@ -1035,7 +1035,7 @@ int lustre_msg_get_status(struct lustre_msg *msg)
 
CERROR("invalid msg %p: no ptlrpc body!\n", msg);
}
-   /* no break */
+   /* fall through */
default:
/* status might be printed in debug code while message
 * uninitialized
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/20] staging: rtl8188eu: usb_ops_linux: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1077613
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c 
b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index 64397b6..7e75030 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -407,6 +407,7 @@ static void usb_read_port_complete(struct urb *purb, struct 
pt_regs *regs)
case -ENODEV:
case -ESHUTDOWN:
adapt->bSurpriseRemoved = true;
+   /* fall through */
case -ENOENT:
adapt->bDriverStopped = true;
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, 
("usb_read_port_complete:bDriverStopped=true\n"));
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/20] staging: rtl8723bs: rtw_mlme_ext: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c 
b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 355ce9b..66127d1 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -584,7 +584,7 @@ void mgt_dispatcher(struct adapter *padapter, union 
recv_frame *precv_frame)
ptable->func = 
else
ptable->func = 
-   /* pass through */
+   /* fall through */
case WIFI_ASSOCREQ:
case WIFI_REASSOCREQ:
_mgt_dispatcher(padapter, ptable, precv_frame);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 06/20] staging: comedi: s526: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/comedi/drivers/s526.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/drivers/s526.c 
b/drivers/staging/comedi/drivers/s526.c
index c80527d..e620f6a 100644
--- a/drivers/staging/comedi/drivers/s526.c
+++ b/drivers/staging/comedi/drivers/s526.c
@@ -408,9 +408,8 @@ static int s526_gpct_winsn(struct comedi_device *dev,
 */
if ((data[1] <= data[0]) || !data[0])
return -EINVAL;
-
-   /* Fall thru to write the PULSE_WIDTH */
-
+   /* to write the PULSE_WIDTH */
+   /* fall through */
case INSN_CONFIG_GPCT_QUADRATURE_ENCODER:
case INSN_CONFIG_GPCT_SINGLE_PULSE_GENERATOR:
s526_gpct_write(dev, chan, data[0]);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 18/20] staging: lustre: osc: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1077598
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lustre/osc/osc_cache.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c 
b/drivers/staging/lustre/lustre/osc/osc_cache.c
index e1207c2..eab7759 100644
--- a/drivers/staging/lustre/lustre/osc/osc_cache.c
+++ b/drivers/staging/lustre/lustre/osc/osc_cache.c
@@ -227,6 +227,7 @@ static int osc_extent_sanity_check0(struct osc_extent *ext,
rc = 65;
goto out;
}
+   /* fall through */
default:
if (atomic_read(>oe_users) > 0) {
rc = 70;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 03/20] staging: rtl8192e: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/rtl8192e/rtllib_wx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_wx.c 
b/drivers/staging/rtl8192e/rtllib_wx.c
index f7eba01..03fbff0 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -694,8 +694,7 @@ int rtllib_wx_set_mlme(struct rtllib_device *ieee,
switch (mlme->cmd) {
case IW_MLME_DEAUTH:
deauth = true;
-   /* leave break out intentionly */
-
+   /* fall through */
case IW_MLME_DISASSOC:
if (deauth)
netdev_info(ieee->dev, "disauth packet !\n");
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/20] staging: vc04_services: vchiq_core: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
index c3bb8e0..ecff92b 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c
@@ -2951,8 +2951,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, 
int close_recvd)
 
case VCHIQ_SRVSTATE_OPENSYNC:
mutex_lock(>sync_mutex);
-   /* Drop through */
-
+   /* fall through */
case VCHIQ_SRVSTATE_OPEN:
if (state->is_master || close_recvd) {
if (!do_abort_bulks(service))
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 00/20] mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, this patchset aims
to mark switch cases where we are expecting to fall through.

In Kees Cook words:
"This is an unfortunate omission in the C language, and thankfully both
gcc and clang have stepped up to solve this the same way static
analyzers have solved it. It does both document the intention for
humans and provide a way for analyzers to report issues.

Having the compiler help us not make mistakes is quite handy."

In some cases there were "no break" or "fall thru" comments already
in place. So I replaced them with proper "fall through" comments, which
is what GCC is expecting to find.

For the rest of the cases, please double check if the actual intention
of the code is to fall through.

Thanks!

Gustavo A. R. Silva (20):
  staging: ks7010: ks_wlan_net: mark expected switch fall-throughs
  staging: lustre: lnet: socklnd: mark expected switch fall-through
  staging: rtl8192e: mark expected switch fall-through
  staging: rtl8723bs: rtw_mlme_ext: mark expected switch fall-through
  staging: lustre: lnet: net_fault: mark expected switch fall-through
  staging: comedi: s526: mark expected switch fall-through
  staging: rtl8188eu: usb_halinit: mark expected switch fall-through
  staging: vc04_services: vchiq_core: mark expected switch fall-through
  staging: vt6656: card: mark expected switch fall-throughs
  staging: rtl8188eu: usb_ops_linux: mark expected switch fall-through
  staging: r8822be: mark expected switch fall-throughs
  staging: lustre: lnet: selftest: mark expected switch fall-through
  staging: rtlwifi: halmac: mark expected switch fall-through
  staging: lustre: lnet: selftest: mark expected switch fall-throughs
  staging: lustre: llite: mark expected switch fall-through
  staging: lustre: lprocfs: mark expected switch fall-throughs
  staging: lustre: ldlm: mark expected switch fall-through
  staging: lustre: osc: mark expected switch fall-through
  staging: lustre: ptlrpc: mark expected switch fall-throughs
  staging: lustre: rpc: mark expected switch fall-throughs

 drivers/staging/comedi/drivers/s526.c   |  5 ++---
 drivers/staging/ks7010/ks_wlan_net.c| 10 ++
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c |  2 +-
 drivers/staging/lustre/lnet/lnet/net_fault.c|  1 +
 drivers/staging/lustre/lnet/selftest/conctl.c   |  1 +
 drivers/staging/lustre/lnet/selftest/module.c   |  5 -
 drivers/staging/lustre/lnet/selftest/rpc.c  | 13 +
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c   |  1 +
 drivers/staging/lustre/lustre/llite/namei.c |  4 +++-
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c |  4 
 drivers/staging/lustre/lustre/osc/osc_cache.c   |  1 +
 drivers/staging/lustre/lustre/ptlrpc/pack_generic.c |  6 +++---
 drivers/staging/rtl8188eu/hal/usb_halinit.c |  1 +
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c|  1 +
 drivers/staging/rtl8192e/rtllib_wx.c|  3 +--
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c   |  2 +-
 .../staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c|  2 ++
 drivers/staging/rtlwifi/halmac/rtl_halmac.c |  2 +-
 .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c  |  3 +--
 drivers/staging/vt6656/card.c   |  2 ++
 20 files changed, 50 insertions(+), 19 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 01/20] staging: ks7010: ks_wlan_net: mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1364489
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/ks7010/ks_wlan_net.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/staging/ks7010/ks_wlan_net.c 
b/drivers/staging/ks7010/ks_wlan_net.c
index 0f9348b..b82b515 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -473,13 +473,16 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[3] =
TX_RATE_11M;
i++;
+   /* fall through */
case 550:
priv->reg.rate_set.body[2] = TX_RATE_5M;
i++;
+   /* fall through */
case 200:
priv->reg.rate_set.body[1] =
TX_RATE_2M | BASIC_RATE;
i++;
+   /* fall through */
case 100:
priv->reg.rate_set.body[0] =
TX_RATE_1M | BASIC_RATE;
@@ -535,14 +538,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
priv->reg.rate_set.body[11] =
TX_RATE_54M;
i++;
+   /* fall through */
case 4800:
priv->reg.rate_set.body[10] =
TX_RATE_48M;
i++;
+   /* fall through */
case 3600:
priv->reg.rate_set.body[9] =
TX_RATE_36M;
i++;
+   /* fall through */
case 2400:
case 1800:
case 1200:
@@ -619,14 +625,17 @@ static int ks_wlan_set_rate(struct net_device *dev,
TX_RATE_6M | BASIC_RATE;
i++;
}
+   /* fall through */
case 550:
priv->reg.rate_set.body[2] =
TX_RATE_5M | BASIC_RATE;
i++;
+   /* fall through */
case 200:
priv->reg.rate_set.body[1] =
TX_RATE_2M | BASIC_RATE;
i++;
+   /* fall through */
case 100:
priv->reg.rate_set.body[0] =
TX_RATE_1M | BASIC_RATE;
@@ -2010,6 +2019,7 @@ static int ks_wlan_set_mlme(struct net_device *dev,
case IW_MLME_DEAUTH:
if (mlme->reason_code == WLAN_REASON_MIC_FAILURE)
return 0;
+   /* fall through */
case IW_MLME_DISASSOC:
mode = 1;
return ks_wlan_set_stop_request(dev, NULL, , NULL);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 05/20] staging: lustre: lnet: net_fault: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lnet/lnet/net_fault.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/lustre/lnet/lnet/net_fault.c 
b/drivers/staging/lustre/lnet/lnet/net_fault.c
index 03f3d18..7391e16 100644
--- a/drivers/staging/lustre/lnet/lnet/net_fault.c
+++ b/drivers/staging/lustre/lnet/lnet/net_fault.c
@@ -629,6 +629,7 @@ delayed_msg_process(struct list_head *msg_list, bool drop)
case LNET_CREDIT_OK:
lnet_ni_recv(ni, msg->msg_private, msg, 0,
 0, msg->msg_len, msg->msg_len);
+   /* fall through */
case LNET_CREDIT_WAIT:
continue;
default: /* failures */
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 12/20] staging: lustre: lnet: selftest: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lnet/selftest/conctl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c 
b/drivers/staging/lustre/lnet/selftest/conctl.c
index 9619ecb..551e921 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -151,6 +151,7 @@ lst_debug_ioctl(struct lstio_debug_args *args)
 
case LST_OPC_BATCHSRV:
client = 0;
+   /* fall through */
case LST_OPC_BATCHCLI:
if (!name)
goto out;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 20/20] staging: lustre: rpc: mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1077604
Addresses-Coverity-ID: 1077605
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lnet/selftest/rpc.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c 
b/drivers/staging/lustre/lnet/selftest/rpc.c
index 77c222c..74ef3c3 100644
--- a/drivers/staging/lustre/lnet/selftest/rpc.c
+++ b/drivers/staging/lustre/lnet/selftest/rpc.c
@@ -1037,6 +1037,7 @@ srpc_handle_rpc(struct swi_workitem *wi)
ev->ev_status = rc;
}
}
+   /* fall through */
case SWI_STATE_BULK_STARTED:
LASSERT(!rpc->srpc_bulk || ev->ev_fired);
 
@@ -1237,7 +1238,8 @@ srpc_send_rpc(struct swi_workitem *wi)
break;
 
wi->swi_state = SWI_STATE_REQUEST_SENT;
-   /* perhaps more events, fall thru */
+   /* perhaps more events */
+   /* fall through */
case SWI_STATE_REQUEST_SENT: {
enum srpc_msg_type type = srpc_service2reply(rpc->crpc_service);
 
@@ -1269,6 +1271,7 @@ srpc_send_rpc(struct swi_workitem *wi)
 
wi->swi_state = SWI_STATE_REPLY_RECEIVED;
}
+   /* fall through */
case SWI_STATE_REPLY_RECEIVED:
if (do_bulk && !rpc->crpc_bulkev.ev_fired)
break;
@@ -1448,6 +1451,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
srpc_data.rpc_counters.rpcs_sent++;
spin_unlock(_data.rpc_glock);
}
+   /* fall through */
case SRPC_REPLY_RCVD:
case SRPC_BULK_REQ_RCVD:
crpc = rpcev->ev_data;
@@ -1570,7 +1574,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 
if (!ev->unlinked)
break; /* wait for final event */
-
+   /* fall through */
case SRPC_BULK_PUT_SENT:
if (!ev->status && ev->type != LNET_EVENT_UNLINK) {
spin_lock(_data.rpc_glock);
@@ -1582,6 +1586,7 @@ srpc_lnet_ev_handler(struct lnet_event *ev)
 
spin_unlock(_data.rpc_glock);
}
+   /* fall through */
case SRPC_REPLY_SENT:
srpc = rpcev->ev_data;
scd = srpc->srpc_scd;
@@ -1674,14 +1679,14 @@ srpc_shutdown(void)
spin_unlock(_data.rpc_glock);
 
stt_shutdown();
-
+   /* fall through */
case SRPC_STATE_EQ_INIT:
rc = LNetClearLazyPortal(SRPC_FRAMEWORK_REQUEST_PORTAL);
rc = LNetClearLazyPortal(SRPC_REQUEST_PORTAL);
LASSERT(!rc);
rc = LNetEQFree(srpc_data.rpc_lnet_eq);
LASSERT(!rc); /* the EQ should have no user by now */
-
+   /* fall through */
case SRPC_STATE_NI_INIT:
LNetNIFini();
}
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 16/20] staging: lustre: lprocfs: mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1271166
Addresses-Coverity-ID: 1271167
Addresses-Coverity-ID: 1271168
Addresses-Coverity-ID: 1271169
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index e79485b..4ec582f 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1507,12 +1507,16 @@ int lprocfs_write_frac_u64_helper(const char __user 
*buffer,
switch (tolower(*end)) {
case 'p':
units <<= 10;
+   /* fall through */
case 't':
units <<= 10;
+   /* fall through */
case 'g':
units <<= 10;
+   /* fall through */
case 'm':
units <<= 10;
+   /* fall through */
case 'k':
units <<= 10;
}
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 14/20] staging: lustre: lnet: selftest: mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lnet/selftest/module.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/selftest/module.c 
b/drivers/staging/lustre/lnet/selftest/module.c
index b5d556f..fa1bccc 100644
--- a/drivers/staging/lustre/lnet/selftest/module.c
+++ b/drivers/staging/lustre/lnet/selftest/module.c
@@ -57,10 +57,13 @@ lnet_selftest_exit(void)
switch (lst_init_step) {
case LST_INIT_CONSOLE:
lstcon_console_fini();
+   /* fall through */
case LST_INIT_FW:
sfw_shutdown();
+   /* fall through */
case LST_INIT_RPC:
srpc_shutdown();
+   /* fall through */
case LST_INIT_WI_TEST:
for (i = 0;
 i < cfs_cpt_number(lnet_cpt_table()); i++) {
@@ -72,7 +75,7 @@ lnet_selftest_exit(void)
sizeof(lst_sched_test[0]) *
cfs_cpt_number(lnet_cpt_table()));
lst_sched_test = NULL;
-
+   /* fall through */
case LST_INIT_WI_SERIAL:
cfs_wi_sched_destroy(lst_sched_serial);
lst_sched_serial = NULL;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 02/20] staging: lustre: lnet: socklnd: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c 
b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index d0ee58d..7b014ca 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -2308,7 +2308,7 @@ ksocknal_base_shutdown(void)
switch (ksocknal_data.ksnd_init) {
default:
LASSERT(0);
-
+   /* fall through */
case SOCKNAL_INIT_ALL:
case SOCKNAL_INIT_DATA:
LASSERT(ksocknal_data.ksnd_peers);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 07/20] staging: rtl8188eu: usb_halinit: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Addresses-Coverity-ID: 1373894
Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/rtl8188eu/hal/usb_halinit.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c 
b/drivers/staging/rtl8188eu/hal/usb_halinit.c
index 674ac53..17967c9 100644
--- a/drivers/staging/rtl8188eu/hal/usb_halinit.c
+++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c
@@ -1745,6 +1745,7 @@ void rtw_hal_get_hwreg(struct adapter *Adapter, u8 
variable, u8 *val)
switch (variable) {
case HW_VAR_BASIC_RATE:
*((u16 *)(val)) = Adapter->HalData->BasicRateSet;
+   /* fall through */
case HW_VAR_TXPAUSE:
val[0] = usb_read8(Adapter, REG_TXPAUSE);
break;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 09/20] staging: vt6656: card: mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/vt6656/card.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c
index c61422e..4fd9cd6 100644
--- a/drivers/staging/vt6656/card.c
+++ b/drivers/staging/vt6656/card.c
@@ -382,11 +382,13 @@ void vnt_update_ifs(struct vnt_private *priv)
priv->difs -= 1;
break;
}
+   /* fall through */
case RF_AIROHA7230:
case RF_AL2230:
case RF_AL2230S:
if (priv->bb_type != BB_TYPE_11B)
break;
+   /* fall through */
case RF_RFMD2959:
case RF_VT3226:
case RF_VT3342A0:
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/20] staging: r8822be: mark expected switch fall-throughs

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c 
b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
index edbf6af..448b137 100644
--- a/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
+++ b/drivers/staging/rtlwifi/halmac/halmac_88xx/halmac_api_88xx.c
@@ -3391,8 +3391,10 @@ halmac_cfg_txbf_88xx(struct halmac_adapter 
*halmac_adapter, u8 userid,
switch (bw) {
case HALMAC_BW_80:
temp42C |= BIT_R_TXBF0_80M;
+   /* fall through */
case HALMAC_BW_40:
temp42C |= BIT_R_TXBF0_40M;
+   /* fall through */
case HALMAC_BW_20:
temp42C |= BIT_R_TXBF0_20M;
break;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 15/20] staging: lustre: llite: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lustre/llite/namei.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/llite/namei.c 
b/drivers/staging/lustre/lustre/llite/namei.c
index 5cc2b32..55e0d03 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -949,7 +949,9 @@ static int ll_mknod(struct inode *dir, struct dentry 
*dchild,
 
switch (mode & S_IFMT) {
case 0:
-   mode |= S_IFREG; /* for mode = 0 case, fallthrough */
+   mode |= S_IFREG;
+   /* for mode = 0 case */
+   /* fall through */
case S_IFREG:
case S_IFCHR:
case S_IFBLK:
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 17/20] staging: lustre: ldlm: mark expected switch fall-through

2017-10-12 Thread Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.

Signed-off-by: Gustavo A. R. Silva <garsi...@embeddedor.com>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index f3bf238..6943987 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1175,6 +1175,7 @@ ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, 
struct ldlm_lock *lock,
case LDLM_IBITS:
if (ns->ns_cancel && ns->ns_cancel(lock) != 0)
break;
+   /* fall through */
default:
result = LDLM_POLICY_SKIP_LOCK;
lock_res_and_lock(lock);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


  1   2   >