include/linux/kernel.h:744:28: note: in expansion of macro 'min'
A message that is not in the archive (sent off-list or not yet received): 53a3c359.yUYVC7fzjYpZLyLq%[email protected]
PATCH 141/230 include/linux/kernel.h:744:28: note: in expansion of macro 'min'
tree: git://git.cmpxchg.org/linux-mmotm.git master head: df25ba7db0775d87018e2cd92f26b9b087093840 commit: 99c369839f847d2cc4b8e759a9c57c925592efa2 [141/230] include/linux/kernel.h: rewrite min3, max3 and clamp using min and max config: make ARCH=x86_64 allmodconfig
All warnings:
drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1901:25: sparse: incompatible types in comparison expression (different type sizes) In file included from arch/x86/include/asm/percpu.h:44:0,
from arch/x86/include/asm/preempt.h:5,
from include/linux/preempt.h:18,
from include/linux/spinlock.h:50,
from include/linux/wait.h:8,
from include/linux/fs.h:6,
from drivers/net/ethernet/intel/i40e/i40e_debugfs.c:29:
drivers/net/ethernet/intel/i40e/i40e_debugfs.c: In function 'i40e_dbg_command_write':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^Quoted 1 line
Quoted 1 line
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1901:11: note: in expansion of macro 'clamp'
bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE);
^
--
drivers/net/wireless/rtlwifi/rtl8723ae/dm.c:269:21: sparse: incompatible types in comparison expression (different type sizes)
In file included from include/linux/sched.h:17:0,
from drivers/net/wireless/rtlwifi/rtl8723ae/../wifi.h:35,
from drivers/net/wireless/rtlwifi/rtl8723ae/dm.c:31:
drivers/net/wireless/rtlwifi/rtl8723ae/dm.c: In function 'rtl92c_dm_ctrl_initgain_by_fa':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^Quoted 1 line
Quoted 1 line
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^Quoted 1 line
Quoted 1 line
drivers/net/wireless/rtlwifi/rtl8723ae/dm.c:269:14: note: in expansion of macro 'clamp'
value_igi = clamp(value_igi, (u8)DM_DIG_FA_LOWER, (u8)DM_DIG_FA_UPPER);
^--
drivers/staging/iio/impedance-analyzer/ad5933.c:241:17: sparse: incorrect type in assignment (different base types)
drivers/staging/iio/impedance-analyzer/ad5933.c:241:17: expected unsigned int [unsigned] [usertype] d32
drivers/staging/iio/impedance-analyzer/ad5933.c:241:17: got restricted __be32 [usertype] <noident>
drivers/staging/iio/impedance-analyzer/ad5933.c:263:13: sparse: incorrect type in assignment (different base types)
drivers/staging/iio/impedance-analyzer/ad5933.c:263:13: expected unsigned short [unsigned] dat
drivers/staging/iio/impedance-analyzer/ad5933.c:263:13: got restricted __be16 [usertype] <noident>
drivers/staging/iio/impedance-analyzer/ad5933.c:271:13: sparse: incorrect type in assignment (different base types)
drivers/staging/iio/impedance-analyzer/ad5933.c:271:13: expected unsigned short [unsigned] [addressable] dat
drivers/staging/iio/impedance-analyzer/ad5933.c:271:13: got restricted __be16 [usertype] <noident>
drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:437:23: sparse: incompatible types in comparison expression (different type sizes) drivers/staging/iio/impedance-analyzer/ad5933.c:451:23: sparse: incompatible types in comparison expression (different type sizes) In file included from include/linux/interrupt.h:5:0,
from drivers/staging/iio/impedance-analyzer/ad5933.c:9:
drivers/staging/iio/impedance-analyzer/ad5933.c: In function 'ad5933_store':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^Quoted 1 line
Quoted 1 line
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^Quoted 1 line
Quoted 1 line
drivers/staging/iio/impedance-analyzer/ad5933.c:437:9: note: in expansion of macro 'clamp'
val = clamp(val, (u16)0, (u16)0x7FF);
^
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^Quoted 1 line
Quoted 1 line
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^Quoted 1 line
Quoted 1 line
drivers/staging/iio/impedance-analyzer/ad5933.c:451:9: note: in expansion of macro 'clamp'
val = clamp(val, (u16)0, (u16)511);
^sparse warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1901:25: sparse: incompatible types in comparison expression (different type sizes)
In file included from arch/x86/include/asm/percpu.h:44:0,
from arch/x86/include/asm/preempt.h:5,
from include/linux/preempt.h:18,
from include/linux/spinlock.h:50,
from include/linux/wait.h:8,
from include/linux/fs.h:6,
from drivers/net/ethernet/intel/i40e/i40e_debugfs.c:29:
drivers/net/ethernet/intel/i40e/i40e_debugfs.c: In function 'i40e_dbg_command_write':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^
drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1901:11: note: in expansion of macro 'clamp'
bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE);
^--
Quoted 1 line
Quoted 1 line
drivers/net/wireless/rtlwifi/rtl8723ae/dm.c:269:21: sparse: incompatible types in comparison expression (different type sizes)
In file included from include/linux/sched.h:17:0,
from drivers/net/wireless/rtlwifi/rtl8723ae/../wifi.h:35,
from drivers/net/wireless/rtlwifi/rtl8723ae/dm.c:31:
drivers/net/wireless/rtlwifi/rtl8723ae/dm.c: In function 'rtl92c_dm_ctrl_initgain_by_fa':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^
drivers/net/wireless/rtlwifi/rtl8723ae/dm.c:269:14: note: in expansion of macro 'clamp'
value_igi = clamp(value_igi, (u8)DM_DIG_FA_LOWER, (u8)DM_DIG_FA_UPPER);
^--
drivers/staging/iio/impedance-analyzer/ad5933.c:241:17: sparse: incorrect type in assignment (different base types)
drivers/staging/iio/impedance-analyzer/ad5933.c:241:17: expected unsigned int [unsigned] [usertype] d32
drivers/staging/iio/impedance-analyzer/ad5933.c:241:17: got restricted __be32 [usertype] <noident>
drivers/staging/iio/impedance-analyzer/ad5933.c:263:13: sparse: incorrect type in assignment (different base types)
drivers/staging/iio/impedance-analyzer/ad5933.c:263:13: expected unsigned short [unsigned] dat
drivers/staging/iio/impedance-analyzer/ad5933.c:263:13: got restricted __be16 [usertype] <noident>
drivers/staging/iio/impedance-analyzer/ad5933.c:271:13: sparse: incorrect type in assignment (different base types)
drivers/staging/iio/impedance-analyzer/ad5933.c:271:13: expected unsigned short [unsigned] [addressable] dat
drivers/staging/iio/impedance-analyzer/ad5933.c:271:13: got restricted __be16 [usertype] <noident>
drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32 drivers/staging/iio/impedance-analyzer/ad5933.c:310:19: sparse: cast to restricted __be32
Quoted 2 lines
Quoted 2 lines
drivers/staging/iio/impedance-analyzer/ad5933.c:437:23: sparse: incompatible types in comparison expression (different type sizes)drivers/staging/iio/impedance-analyzer/ad5933.c:451:23: sparse: incompatible types in comparison expression (different type sizes)
In file included from include/linux/interrupt.h:5:0,
from drivers/staging/iio/impedance-analyzer/ad5933.c:9:
drivers/staging/iio/impedance-analyzer/ad5933.c: In function 'ad5933_store':
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^
drivers/staging/iio/impedance-analyzer/ad5933.c:437:9: note: in expansion of macro 'clamp'
val = clamp(val, (u16)0, (u16)0x7FF);
^
include/linux/kernel.h:713:17: warning: comparison of distinct pointer types lacks a cast [enabled by default]
(void) (&_min1 == &_min2); \
^
include/linux/kernel.h:744:28: note: in expansion of macro 'min'
#define clamp(val, lo, hi) min(max(val, lo), hi)
^
drivers/staging/iio/impedance-analyzer/ad5933.c:451:9: note: in expansion of macro 'clamp'
val = clamp(val, (u16)0, (u16)511);
^vim +/min +744 include/linux/kernel.h
^1da177e Linus Torvalds 2005-04-16 707 * strict type-checking.. See the
^1da177e Linus Torvalds 2005-04-16 708 * "unnecessary" pointer comparison.
^1da177e Linus Torvalds 2005-04-16 709 */
bdf4bbaa Harvey Harrison 2008-04-30 710 #define min(x, y) ({ \
bdf4bbaa Harvey Harrison 2008-04-30 711 typeof(x) _min1 = (x); \
bdf4bbaa Harvey Harrison 2008-04-30 712 typeof(y) _min2 = (y); \
bdf4bbaa Harvey Harrison 2008-04-30 @713 (void) (&_min1 == &_min2); \
bdf4bbaa Harvey Harrison 2008-04-30 714 _min1 < _min2 ? _min1 : _min2; })
bdf4bbaa Harvey Harrison 2008-04-30 715
bdf4bbaa Harvey Harrison 2008-04-30 716 #define max(x, y) ({ \
bdf4bbaa Harvey Harrison 2008-04-30 717 typeof(x) _max1 = (x); \
bdf4bbaa Harvey Harrison 2008-04-30 718 typeof(y) _max2 = (y); \
bdf4bbaa Harvey Harrison 2008-04-30 719 (void) (&_max1 == &_max2); \
bdf4bbaa Harvey Harrison 2008-04-30 720 _max1 > _max2 ? _max1 : _max2; })
bdf4bbaa Harvey Harrison 2008-04-30 721
99c36983 Michal Nazarewicz 2014-06-20 722 #define min3(x, y, z) min(min(x, y), z)
99c36983 Michal Nazarewicz 2014-06-20 723 #define max3(x, y, z) max(max(x, y), z)
f27c85c5 Hagen Paul Pfeifer 2010-10-26 724
bdf4bbaa Harvey Harrison 2008-04-30 725 /**
c8bf1336 Martin K. Petersen 2010-09-10 726 * min_not_zero - return the minimum that is _not_ zero, unless both are zero
c8bf1336 Martin K. Petersen 2010-09-10 727 * @x: value1
c8bf1336 Martin K. Petersen 2010-09-10 728 * @y: value2
c8bf1336 Martin K. Petersen 2010-09-10 729 */
c8bf1336 Martin K. Petersen 2010-09-10 730 #define min_not_zero(x, y) ({ \
c8bf1336 Martin K. Petersen 2010-09-10 731 typeof(x) __x = (x); \
c8bf1336 Martin K. Petersen 2010-09-10 732 typeof(y) __y = (y); \
c8bf1336 Martin K. Petersen 2010-09-10 733 __x == 0 ? __y : ((__y == 0) ? __x : min(__x, __y)); })
c8bf1336 Martin K. Petersen 2010-09-10 734
c8bf1336 Martin K. Petersen 2010-09-10 735 /**
bdf4bbaa Harvey Harrison 2008-04-30 736 * clamp - return a value clamped to a given range with strict typechecking
bdf4bbaa Harvey Harrison 2008-04-30 737 * @val: current value
99c36983 Michal Nazarewicz 2014-06-20 738 * @lo: lowest allowable value
99c36983 Michal Nazarewicz 2014-06-20 739 * @hi: highest allowable value
bdf4bbaa Harvey Harrison 2008-04-30 740 *
bdf4bbaa Harvey Harrison 2008-04-30 741 * This macro does strict typechecking of min/max to make sure they are of the
bdf4bbaa Harvey Harrison 2008-04-30 742 * same type as val. See the unnecessary pointer comparisons.
bdf4bbaa Harvey Harrison 2008-04-30 743 */
99c36983 Michal Nazarewicz 2014-06-20 @744 #define clamp(val, lo, hi) min(max(val, lo), hi)
^1da177e Linus Torvalds 2005-04-16 745
^1da177e Linus Torvalds 2005-04-16 746 /*
^1da177e Linus Torvalds 2005-04-16 747 * ..and if you can't take the strict---
0-DAY kernel build testing backend Open Source Technology Center
http://lists.01.org/mailman/listinfo/kbuild Intel Corporation
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Fengguang Wu
Quoted 1 line
Quoted 1 line
include/linux/kernel.h:744:28: note: in expansion of macro 'min'#define clamp(val, lo, hi) min(max(val, lo), hi) ^Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1901:11: note: in expansion of macro 'clamp'bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE); ^
The obvious fix:
----------- >8 --------------------------------------------------------------
include/linux/kernel.h +3 -3
@@ -719,8 +719,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } (void ) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) -#define min3 (x, y, z) min(min(x, y), z) -#define max3 (x, y, z) max(max(x, y), z) +#define min3 (x, y, z) min((typeof(x))min(x, y), z) +#define max3 (x, y, z) max((typeof(x))max(x, y), z)/** * min_not_zero - return the minimum that is _not_ zero, unless both are zero
@@ -741,7 +741,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }* This macro does strict typechecking of min/max to make sure they are of the * same type as val. See the unnecessary pointer comparisons. */ -#define clamp (val, lo, hi) min(max(val, lo), hi) +#define clamp (val, lo, hi) min((typeof(val))max(val, lo), hi)/* * ..and if you can't take the strict
----------- >8 --------------------------------------------------------------
increases size of the kernel:
-rwx------ 1 mpn eng 437026785 Jun 20 15:45 vmlinux.before -rwx------ 1 mpn eng 437026881 Jun 20 15:30 vmlinux.after
even though it's still slightly smaller than w/o the patch all together:
-rwx------ 1 mpn eng 437027411 Jun 20 16:04 vmlinux.before.before
Signature · 10 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Andrew Morton
maintainerQuoted 16 lines · On Fri, 20 Jun 2014 17:19:55 +0200 Michal Nazarewicz <[email protected]> wrote:
Quoted 6 lines · Fengguang Wu
Quoted 1 line
Quoted 1 line
include/linux/kernel.h:744:28: note: in expansion of macro 'min'#define clamp(val, lo, hi) min(max(val, lo), hi) ^Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1901:11: note: in expansion of macro 'clamp'bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE); ^The obvious fix:
----------- >8 --------------------------------------------------------------
include/linux/kernel.h +0
-0
include/linux/kernel.h static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } · line 723
Quoted 7 lines
include/linux/kernel.h +2
-2@@ -719,8 +719,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } (void ) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) -#define min3 (x, y, z) min(min(x, y), z) -#define max3 (x, y, z) max(max(x, y), z) +#define min3 (x, y, z) min((typeof(x))min(x, y), z) +#define max3 (x, y, z) max((typeof(x))max(x, y), z)
I don't get it. All the types are u16 so we should be good.
What is the return type of
_max1 > _max2 ? _max1 : _max2;
when both _max1 and _max2 are u16? Something other than u16 apparently
- I never knew that.
Maybe we should be fixing min() and max()?
include/linux/kernel.h renamed from include/linux/kernel.h~a +2 -2
@@ -711,13 +711,13 @@ static inline void ftrace_dump(enum ftratypeof (x) _min1 = (x); \typeof (y) _min2 = (y); \ (void ) (&_min1 == &_min2); \ - _min1 < _min2 ? _min1 : _min2; }) + (typeof(x))(_min1 < _min2 ? _min1 : _min2); })#define max (x, y) ({ \ typeof(x) _max1 = (x); \ typeof(y) _max2 = (y); \ (void) (&_max1 == &_max2); \ - _max1 > _max2 ? _max1 : _max2; }) + (typeof(x))(_max1 > _max2 ? _max1 : _max2); })#define min3 (x, y, z) min(min(x, y), z)#define max3 (x, y, z) max(max(x, y), z)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 28 lines · Andrew Morton
Quoted 16 lines · On Fri, 20 Jun 2014 17:19:55 +0200 Michal Nazarewicz <[email protected]> wrote:
Quoted 6 lines · Fengguang Wu
Quoted 1 line
Quoted 1 line
include/linux/kernel.h:744:28: note: in expansion of macro 'min'#define clamp(val, lo, hi) min(max(val, lo), hi) ^Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_debugfs.c:1901:11: note: in expansion of macro 'clamp'bytes = clamp(bytes, (u16)1024, (u16)I40E_MAX_AQ_BUF_SIZE); ^The obvious fix:
----------- >8 --------------------------------------------------------------
include/linux/kernel.h +0
-0include/linux/kernel.h static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } · line 723
Quoted 7 lines
include/linux/kernel.h +2
-2@@ -719,8 +719,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } (void ) (&_max1 == &_max2); \ _max1 > _max2 ? _max1 : _max2; }) -#define min3 (x, y, z) min(min(x, y), z) -#define max3 (x, y, z) max(max(x, y), z) +#define min3 (x, y, z) min((typeof(x))min(x, y), z) +#define max3 (x, y, z) max((typeof(x))max(x, y), z)I don't get it. All the types are u16 so we should be good.
Quoted 3 lines
What is the return type of
_max1 > _max2 ? _max1 : _max2;
int… Since C promotes it. (Or unsigned, I never remember, but I think int if the possible values fit in signed int).
Quoted 4 lines
when both
_max1and_max2are u16? Something other than u16 apparently
- I never knew that.Maybe we should be fixing
min()andmax()?
This is also an option. It would make min() and max() behave more like a function which takes arguments of type T and returns value of type T. Currently it behaves as a C operation which undergoes all the promotion rules other arithmetic operations undergo (i.e. all types smaller than int get promoted to int). I don't have opinion either way.
Quoted 19 lines
include/linux/kernel.h renamed from include/linux/kernel.h~a +2
-2@@ -711,13 +711,13 @@ static inline void ftrace_dump(enum ftratypeof (x) _min1 = (x); \typeof (y) _min2 = (y); \ (void ) (&_min1 == &_min2); \ - _min1 < _min2 ? _min1 : _min2; }) + (typeof(x))(_min1 < _min2 ? _min1 : _min2); })#define max (x, y) ({ \ typeof(x) _max1 = (x); \ typeof(y) _max2 = (y); \ (void) (&_max1 == &_max2); \ - _max1 > _max2 ? _max1 : _max2; }) + (typeof(x))(_max1 > _max2 ? _max1 : _max2); })#define min3 (x, y, z) min(min(x, y), z)#define max3 (x, y, z) max(max(x, y), z)
Signature · 10 lines
Best regards, _ _ .o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o ..o | Computer Science, Michał “mina86” Nazarewicz (o o) ooo +--<[email protected]>--<xmpp:[email protected]>--ooO--(_)--Ooo-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>