linux-4.7-rc3/drivers/net/wireless/ath/ath9k/htc_drv_main.c: 2 * strange tests ?

2016-06-13 Thread David Binderman
Hello there,

1.

linux-4.7-rc3/drivers/net/wireless/ath/ath9k/htc_drv_main.c:798]:
(warning) Comparison of a boolean expression with an integer other
than 0 or 1.

Source code is

   if (common->ani.caldone <= 0) {

but

drivers/net/wireless/ath/ath.h:bool caldone;

Maybe better code

  if (!(common->ani.caldone)) {

2.

linux-4.7-rc3/drivers/net/wireless/ath/ath9k/htc_drv_main.c:851]:
(warning) Comparison of a boolean expression with an integer other
than 0 or 1.

   if (common->ani.caldone <= 0)

Duplicate. Also in the same file:

drivers/net/wireless/ath/ath9k/htc_drv_main.c:228]: (style) Variable
'ret' is assigned a value that is never used.

This might be a case where a function return value is not checked.

Regards

David Binderman


linux-4.7-rc2/drivers/net/wireless/ath/ath6kl/wmi.c:2547]: (style) Redundant condition

2016-06-07 Thread David Binderman
Hello there,

linux-4.7-rc2/drivers/net/wireless/ath/ath6kl/wmi.c:2547]: (style)
Redundant condition: If 'EXPR <= 7', the comparison 'EXPR < 8' is
always true.

Source code is

if (!((params->user_pri < 8) &&
  (params->user_pri <= 0x7) &&

This might be a possible cut'n'paste error. Also in the same file

[drivers/net/wireless/ath/ath6kl/wmi.c:1220]: (style) Variable 'rate'
is assigned a value that is never used.
[drivers/net/wireless/ath/ath6kl/wmi.c:1484]: (style) Variable
'new_threshold' is assigned a value that is never used.
[drivers/net/wireless/ath/ath6kl/wmi.c:3521]: (style) Variable 'ret'
is assigned a value that is never used.

Regards

David Binderman


linux-4.7-rc2/drivers/net/fjes/fjes_main.c:1346]: (style) Redundant condition

2016-06-07 Thread David Binderman
Hello there,

linux-4.7-rc2/drivers/net/fjes/fjes_main.c:1346]: (style) Redundant
condition: !is_shared. 'is_shared && (!is_shared || !stop_req_done)'
is equivalent to 'is_shared && !stop_req_done'

Source code is

if ((!stop_req ||
 (is_shared && (!is_shared || !stop_req_done))) &&
(is_shared || !unshare_watch || !unshare_reserve))

  if ((!stop_req ||
 (is_shared && !stop_req_done)) &&
(is_shared || !unshare_watch || !unshare_reserve))

Also in the same file:

[drivers/net/fjes/fjes_main.c:1321]: (style) Variable 'max_epid' is
assigned a value that is never used.
[drivers/net/fjes/fjes_main.c:1320]: (style) Variable 'my_epid' is
assigned a value that is never used.

These two might be candidates for deletion.

Regards

David Binderman


linux-4.7-rc2/drivers/net/ethernet/freescale/fman/fman.c:2329]: (style) Redundant condition

2016-06-07 Thread David Binderman
Hello there,

linux-4.7-rc2/drivers/net/ethernet/freescale/fman/fman.c:2329]:
(style) Redundant condition: fman.state.port_mfl[mac_id]. '!A || (A &&
B)' is equivalent to '!A || B'

Source code is

if ((!fman->state->port_mfl[mac_id]) ||
(fman->state->port_mfl[mac_id] &&
(mfl <= fman->state->port_mfl[mac_id]))) {

Suggest new code

if ((!fman->state->port_mfl[mac_id]) ||
(mfl <= fman->state->port_mfl[mac_id])) {

Regards

David Binderman


linux-4.7-rc1/drivers/isdn/capi/capidrv.c:1707]: (style) Redundant condition

2016-05-30 Thread David Binderman
Hello there,

linux-4.7-rc1/drivers/isdn/capi/capidrv.c:1707]: (style) Redundant
condition: If 'EXPR == ' '', the comparison 'EXPR' is always true.

Source code is

   while (*s && *s == ' ') s++;

Suggest new code

   while (*s == ' ') s++;


Regards

David Binderman


drivers/net/ethernet/qlogic/qed/qed_dcbx.c:210: pointless test ?

2016-05-23 Thread David Binderman
Hello there,

drivers/net/ethernet/qlogic/qed/qed_dcbx.c:210:16: warning: comparison
is always false due to limited range of data type [-Wtype-limits]

Source code is

   if (priority < 0) {

but

u8 tc, priority, priority_map;


Regards

David Binderman


linux-4.6/net/kcm/kcmsock.c:1508: bad if test ?

2016-05-16 Thread David Binderman
Hello there,

linux-4.6/net/kcm/kcmsock.c:1508]: (style) Checking if unsigned
variable 'copied' is less than zero.

Source code is

if (copied < 0) {

but

   size_t copied;

Suggest code rework.


Regards

David Binderman


drivers/net/phy/dp83867.c:167: possible bad if ?

2015-07-20 Thread David Binderman
Hello there,

drivers/net/phy/dp83867.c:167:57: warning: logical ‘or’ of collectively 
exhaustive tests is always true [-Wlogical-op]

Source code is

    if ((phydev-interface= PHY_INTERFACE_MODE_RGMII_ID) ||
    (phydev-interface = PHY_INTERFACE_MODE_RGMII_RXID)) {

Maybe

    if ((phydev-interface= PHY_INTERFACE_MODE_RGMII_ID) 
    (phydev-interface = PHY_INTERFACE_MODE_RGMII_RXID)) {


Regards

David Binderman

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


RE: drivers/net/phy/dp83867.c:167: possible bad if ?

2015-07-20 Thread David Binderman
Hello there,


 The proposed fix is logically correct. And it matches the code for
 phy_interface_is_rgmii with the ''.

As the original warning message indicates, I used compiler flag
-Wlogical-op to find this problem.

In order to detect this problem in future in your section of
the Linux kernel, it might be a wise idea to add compiler flag
-Wlogical-op to your builds.

If all goes well, this extra compiler flag should have nothing to say.

Just an idea.


Regards

David Binderman

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


linux-4.2-rc2/drivers/net/ethernet/brocade/bna/bfa_ioc.c:2843: out of bounds string access ?

2015-07-13 Thread David Binderman
Hello there,

[linux-4.2-rc2/drivers/net/ethernet/brocade/bna/bfa_ioc.c:2843]: (error) Buffer 
is accessed out of bounds.

Source code is

    memcpy(manufacturer, BFA_MFG_NAME, BFA_ADAPTER_MFG_NAME_LEN);

and

#define BFA_MFG_NAME QLogic

and

$ fgrep BFA_ADAPTER_MFG_NAME_LEN `find 
linux-4.2-rc2/drivers/net/ethernet/brocade/ -name \*.h -print`
linux-4.2-rc2/drivers/net/ethernet/brocade/bna/bfa_defs.h:    
BFA_ADAPTER_MFG_NAME_LEN    = 8,   /*! manufacturer name length */
$

so the code attempts to read eight bytes from a seven byte string. Suggest code 
rework.

Regards

David Binderman

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


linux-4.2-rc2/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:1993: possible bad error checking ?

2015-07-13 Thread David Binderman
Hello there,

[linux-4.2-rc2/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:1993]: (style) 
Checking if unsigned variable 'entry' is less than zero.

Source code is

    entry = priv-hw-mode-jumbo_frm(priv, skb, csum_insertion);
    if (unlikely(entry  0))
    goto dma_map_err;

but

    unsigned int entry;

So the error checking from the function call looks broken to me.

If the return value from the function call to jumbo_frm is a plain signed 
integer, suggest
sanity check that *before* assigning into an unsigned integer.

Regards

David Binderman

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


RE: linux-4.2-rc1/samples/bpf/sockex3_kern.c: bad expression ?

2015-07-07 Thread David Binderman
Hello there Alexei,


 oops, yes. Could you please send a patch to fix it. 

Sorry, but I gave up trying to do kernel patches many years ago.

Regards

David Binderman

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


linux-4.2-rc1/samples/bpf/sockex3_kern.c: bad expression ?

2015-07-07 Thread David Binderman
Hello there,

[linux-4.2-rc1/samples/bpf/sockex3_kern.c:268]: (style) Expression '(X  0xf0) 
== 0x4' is always false.

Source code is

   if ((verlen  0xF0) == 4)

Maybe

   if ((verlen  0xF0) == 0x40)

Regards

David Binderman


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