linux/drivers/net
Michal Nazarewicz 8f57e4d930 include/linux/kernel.h: change abs() macro so it uses consistent return type
Rewrite abs() so that its return type does not depend on the
architecture and no unexpected type conversion happen inside of it.  The
only conversion is from unsigned to signed type.  char is left as a
return type but treated as a signed type regradless of it's actual
signedness.

With the old version, int arguments were promoted to long and depending
on architecture a long argument might result in s64 or long return type
(which may or may not be the same).

This came after some back and forth with Nicolas.  The current macro has
different return type (for the same input type) depending on
architecture which might be midly iritating.

An alternative version would promote to int like so:

	#define abs(x)	__abs_choose_expr(x, long long,			\
			__abs_choose_expr(x, long,			\
			__builtin_choose_expr(				\
				sizeof(x) <= sizeof(int),		\
				({ int __x = (x); __x<0?-__x:__x; }),	\
				((void)0))))

I have no preference but imagine Linus might.  :] Nicolas argument against
is that promoting to int causes iconsistent behaviour:

	int main(void) {
		unsigned short a = 0, b = 1, c = a - b;
		unsigned short d = abs(a - b);
		unsigned short e = abs(c);
		printf("%u %u\n", d, e);  // prints: 1 65535
	}

Then again, no sane person expects consistent behaviour from C integer
arithmetic.  ;)

Note:

  __builtin_types_compatible_p(unsigned char, char) is always false, and
  __builtin_types_compatible_p(signed char, char) is also always false.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Cc: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Cc: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-01-16 11:17:22 -08:00
..
appletalk
arcnet arcnet/com20020: add LEDS_CLASS dependency 2015-11-03 11:29:56 -05:00
bonding Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-01-11 23:55:43 -05:00
caif net: caif: check return value of alloc_netdev 2015-11-09 11:31:13 -05:00
can Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-12-03 21:09:12 -05:00
cris
dsa dsa: mv88e6xxx: Add Second back of statistics 2015-12-23 22:17:00 -05:00
ethernet Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-01-15 13:33:12 -08:00
fddi
fjes fjes: fix inconsistent indenting 2015-11-15 17:09:23 -05:00
hamradio mkiss: fix scribble on freed memory 2016-01-06 15:06:27 -05:00
hippi
hyperv hv_netvsc: Fix race condition on Multi-Send Data field 2015-12-14 00:02:06 -05:00
ieee802154 ieee802154: cc2520: Check CRC & add promiscuous 2016-01-03 09:17:42 +01:00
ipvlan net: Rename NETIF_F_ALL_CSUM to NETIF_F_CSUM_MASK 2015-12-15 16:50:08 -05:00
irda irda: toim3232-sir: delete some dead code 2016-01-08 13:25:33 -05:00
phy net: phy: turn carrier off on phy attach 2016-01-15 14:49:11 -05:00
plip net: plip: use new parport device model 2016-01-09 21:02:05 -05:00
ppp Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-12-17 22:08:28 -05:00
slip ppp, slip: Validate VJ compression slot parameters completely 2015-11-02 16:25:00 -05:00
team team: Advertise tunneling offload features 2015-12-17 16:24:36 -05:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-01-11 23:55:43 -05:00
vmxnet3 Driver: Vmxnet3: Fix regression caused by 5738a09 2016-01-06 16:20:13 -05:00
wan x25_asy: Free x25_asy on x25_asy_open() failure. 2016-01-13 11:45:39 -05:00
wimax
wireless include/linux/kernel.h: change abs() macro so it uses consistent return type 2016-01-16 11:17:22 -08:00
xen-netback xen-netback: free queues after freeing the net device 2016-01-15 15:13:19 -05:00
Kconfig net: Add IPv6 support to VRF device 2015-10-13 04:55:07 -07:00
LICENSE.SRC
Makefile
Space.c
dummy.c net: dummy: add more features 2015-10-21 19:36:10 -07:00
eql.c
geneve.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-01-11 23:55:43 -05:00
ifb.c
loopback.c sctp: Rename NETIF_F_SCTP_CSUM to NETIF_F_SCTP_CRC 2015-12-15 16:49:58 -05:00
macvlan.c net: Eliminate NETIF_F_GEN_CSUM and NETIF_F_V[46]_CSUM 2015-12-15 16:50:20 -05:00
macvtap.c net: Rename NETIF_F_ALL_CSUM to NETIF_F_CSUM_MASK 2015-12-15 16:50:08 -05:00
mdio.c
mii.c
netconsole.c netconsole: use per-attribute show and store methods 2015-10-13 22:17:51 -07:00
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
sungem_phy.c
tun.c tun: honor IFF_UP in tun_get_user() 2015-12-17 15:25:57 -05:00
veth.c veth: don’t modify ip_summed; doing so treats packets with bad checksums as good. 2015-12-22 15:15:34 -05:00
virtio_net.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2015-12-17 22:08:28 -05:00
vrf.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-01-06 22:54:18 -05:00
vxlan.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2016-01-11 23:55:43 -05:00
xen-netfront.c xen: features for 4.4-rc0 2015-11-04 17:32:42 -08:00