linux/drivers/net/wireless
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
..
admtek adm80211: move under admtek vendor directory 2015-11-17 19:49:19 +02:00
ath Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2016-01-12 18:57:02 -08:00
atmel atmel: move under atmel vendor directory 2015-11-18 11:19:07 +02:00
broadcom brcmfmac: Do not handle link downs for ibss. 2016-01-08 10:44:48 +02:00
cisco wireless: airo: re-use mac_pton() 2015-11-30 14:59:28 +02:00
intel include/linux/kernel.h: change abs() macro so it uses consistent return type 2016-01-16 11:17:22 -08:00
intersil prism54: fix checks for dma mapping errors 2015-12-31 10:23:32 +02:00
marvell Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2016-01-12 18:57:02 -08:00
mediatek mediatek: unify Kconfig with other vendors 2015-11-18 14:28:31 +02:00
ralink rt2x00pci: Disable memory-write-invalidate when the driver exits 2016-01-07 11:22:46 +02:00
realtek rtlwifi: rtl_pci: Fix kernel panic 2015-12-30 17:36:05 +02:00
rsi rsi: bool tests do not need comparison 2015-12-30 17:34:26 +02:00
st cw1200: remove some dead code 2015-12-11 13:15:08 +02:00
ti Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2016-01-12 18:57:02 -08:00
zydas zd1211rw: move under zydas vendor directory 2015-11-18 14:28:30 +02:00
Kconfig mac80211_hwsim: move Kconfig entry for sorting alphabetically 2015-11-18 15:23:36 +02:00
Makefile ath: unify Kconfig with other vendors 2015-11-18 14:28:31 +02:00
mac80211_hwsim.c mac80211_hwsim: check ATTR_FREQ for wmediumd (netlink) packets 2015-12-04 14:43:32 +01:00
mac80211_hwsim.h
ray_cs.c
ray_cs.h
rayctl.h
rndis_wlan.c rndis_wlan: fix checking for default value 2015-09-22 16:14:32 -07:00
wl3501.h
wl3501_cs.c