linux/drivers/net/ethernet
Arnd Bergmann 287980e49f remove lots of IS_ERR_VALUE abuses
Most users of IS_ERR_VALUE() in the kernel are wrong, as they
pass an 'int' into a function that takes an 'unsigned long'
argument. This happens to work because the type is sign-extended
on 64-bit architectures before it gets converted into an
unsigned type.

However, anything that passes an 'unsigned short' or 'unsigned int'
argument into IS_ERR_VALUE() is guaranteed to be broken, as are
8-bit integers and types that are wider than 'unsigned long'.

Andrzej Hajda has already fixed a lot of the worst abusers that
were causing actual bugs, but it would be nice to prevent any
users that are not passing 'unsigned long' arguments.

This patch changes all users of IS_ERR_VALUE() that I could find
on 32-bit ARM randconfig builds and x86 allmodconfig. For the
moment, this doesn't change the definition of IS_ERR_VALUE()
because there are probably still architecture specific users
elsewhere.

Almost all the warnings I got are for files that are better off
using 'if (err)' or 'if (err < 0)'.
The only legitimate user I could find that we get a warning for
is the (32-bit only) freescale fman driver, so I did not remove
the IS_ERR_VALUE() there but changed the type to 'unsigned long'.
For 9pfs, I just worked around one user whose calling conventions
are so obscure that I did not dare change the behavior.

I was using this definition for testing:

 #define IS_ERR_VALUE(x) ((unsigned long*)NULL == (typeof (x)*)NULL && \
       unlikely((unsigned long long)(x) >= (unsigned long long)(typeof(x))-MAX_ERRNO))

which ends up making all 16-bit or wider types work correctly with
the most plausible interpretation of what IS_ERR_VALUE() was supposed
to return according to its users, but also causes a compile-time
warning for any users that do not pass an 'unsigned long' argument.

I suggested this approach earlier this year, but back then we ended
up deciding to just fix the users that are obviously broken. After
the initial warning that caused me to get involved in the discussion
(fs/gfs2/dir.c) showed up again in the mainline kernel, Linus
asked me to send the whole thing again.

[ Updated the 9p parts as per Al Viro  - Linus ]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrzej Hajda <a.hajda@samsung.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: https://lkml.org/lkml/2016/1/7/363
Link: https://lkml.org/lkml/2016/5/27/486
Acked-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> # For nvmem part
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-05-27 15:26:11 -07:00
..
3com treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
8390 treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
adaptec treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
adi treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
aeroflex aeroflex/greth: fix warning about unused variable 2016-05-20 18:33:37 -07:00
agere treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
allwinner treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
alteon
altera net: eth: altera: do not free array priv->mdio->irq 2016-03-06 22:59:18 -05:00
amd net: au1000 eth: simplify logical expression 2016-05-19 11:32:05 -07:00
apm Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-05-15 13:32:48 -04:00
apple
arc net: arc: trivial: cleanup the emac driver 2016-03-16 19:28:01 -04:00
atheros treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
aurora net: ethernet: nb8800: support fixed-link DT node 2016-02-24 11:32:11 -05:00
broadcom net: define gso types for IPx over IPv4 and IPv6 2016-05-20 18:03:15 -04:00
brocade bna: fix list corruption 2016-03-01 15:19:43 -05:00
cadence Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-05-04 00:52:29 -04:00
calxeda
cavium Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-05-20 20:01:26 -07:00
chelsio Primary 4.7 merge window changes 2016-05-20 14:35:07 -07:00
cirrus
cisco enic: set netdev->vlan_features 2016-04-18 14:53:21 -04:00
davicom drivers: net: Don't print unpopulated net_device name 2016-05-17 12:30:19 -04:00
dec treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
dlink treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
emulex benet: be_resume needs to protect be_open with rtnl_lock 2016-04-21 15:35:07 -04:00
ezchip net: nps_enet: bug fix - handle lost tx interrupts 2016-05-10 15:04:49 -04:00
faraday net: ethernet: ftgmac100: use phy_ethtool_{get|set}_link_ksettings 2016-05-16 21:51:41 -04:00
freescale remove lots of IS_ERR_VALUE abuses 2016-05-27 15:26:11 -07:00
fujitsu treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
hisilicon treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
hp treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
i825xx treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
ibm net: ehea: avoid null pointer dereference 2016-05-19 11:25:30 -07:00
intel intel: Add support for IPv6 IP-in-IP offload 2016-05-20 19:25:52 -04:00
marvell net: pxa168_eth: Use dma_wmb/rmb where appropriate 2016-05-16 13:39:49 -04:00
mediatek net: mediatek: do not set the QID field in the TX DMA descriptors 2016-04-12 22:41:33 -04:00
mellanox Primary 4.7 merge window changes 2016-05-20 14:35:07 -07:00
micrel drivers: net: Don't print unpopulated net_device name 2016-05-17 12:30:19 -04:00
microchip treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
moxa treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
myricom myri10ge: fix sleeping with bh disabled 2016-04-28 14:21:14 -04:00
natsemi treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
neterion drivers: net: remove NETDEV_TX_LOCKED 2016-04-26 15:53:05 -04:00
netronome nfp: add async reconfiguration mechanism 2016-04-16 22:34:40 -04:00
nuvoton treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
nvidia forcedeth: Use setup_timer() 2016-02-25 16:51:05 -05:00
nxp
oki-semi pch_gbe: replace private tx ring lock with common netif_tx_lock 2016-04-28 17:19:58 -04:00
packetengines treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
pasemi pasemi_mac: Replace LRO with GRO 2016-02-17 16:15:45 -05:00
qlogic Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-05-20 20:01:26 -07:00
qualcomm treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
rdc
realtek r8169: default to 64-bit DMA on recent PCIe chips 2016-05-17 14:31:09 -04:00
renesas ravb: Add missing free_irq() calls to ravb_close() 2016-05-17 12:26:56 -04:00
rocker switchdev: pass pointer to fib_info instead of copy 2016-05-17 13:58:49 -04:00
samsung net: sxgbe: fix error paths in sxgbe_platform_probe() 2016-03-27 22:39:22 -04:00
seeq treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
sfc sfc: disable RSS when unsupported 2016-04-28 14:21:15 -04:00
sgi treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
silan
sis treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
smsc treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
stmicro stmmac: hardware TX COE doesn't work when force_thresh_dma_mode is set 2016-05-16 22:17:45 -04:00
sun treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
synopsys treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
tehuti treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
ti treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
tile drivers: fix dev->trans_start removal fallout 2016-05-04 17:07:14 -04:00
toshiba ps3_gelic: use kmemdup 2016-05-20 19:50:07 -04:00
tundra net: tsi108: use NULL for pointer-typed argument 2016-04-26 01:10:26 -04:00
via treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
wiznet net: w5100-spi: add support to specify MAC address by device tree 2016-05-16 13:55:49 -04:00
xilinx treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
xircom treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
xscale
Kconfig netdev: Move octeon/octeon_mgmt driver to cavium directory. 2016-03-18 18:25:30 -04:00
Makefile netdev: Move octeon/octeon_mgmt driver to cavium directory. 2016-03-18 18:25:30 -04:00
dnet.c
dnet.h
ec_bhf.c
ethoc.c net/ethoc: do not free array priv->mdio->irq 2016-03-06 22:58:51 -05:00
fealnx.c treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
jme.c drivers/net/ethernet/jme.c: Deinline jme_reset_mac_processor, save 2816 bytes 2016-04-13 22:57:00 -04:00
jme.h
korina.c treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
lantiq_etop.c treewide: replace dev->trans_start update with helper 2016-05-04 14:16:49 -04:00
netx-eth.c drivers: net: Don't print unpopulated net_device name 2016-05-17 12:30:19 -04:00