Re: [PATCH 2/2] crypto: sun4i-ss: remove dependency on not 64BIT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Corentin,

I love your patch! Perhaps something to improve:

[auto build test WARNING on cryptodev/master]
[also build test WARNING on next-20191115]
[cannot apply to v5.4-rc8]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-sun4i-ss-Fix-64-bit-size_t-warnings-on-sun4i-ss-hash-c/20191114-211327
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   In file included from include/linux/clk.h:13:0,
                    from drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h:14,
                    from drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:13:
   drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_opti_poll':
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
>> drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:75:10: note: in expansion of macro 'min3'
      todo = min3(rx_cnt, ileft, (mi.length - oi) / 4);
             ^~~~
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:90:10: note: in expansion of macro 'min3'
      todo = min3(tx_cnt, oleft, (mo.length - oo) / 4);
             ^~~~
   drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:242:11: note: in expansion of macro 'min3'
       todo = min3(rx_cnt, ileft / 4, (mi.length - oi) / 4);
              ^~~~
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:256:12: note: in expansion of macro 'min3'
        todo = min3(rx_cnt * 4 - ob, ileft,
               ^~~~
   In file included from include/linux/printk.h:332:0,
                    from include/linux/kernel.h:15,
                    from include/linux/clk.h:13,
                    from drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h:14,
                    from drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:13:
>> drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:277:20: warning: format '%u' expects argument of type 'unsigned int', but argument 6 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
                       ^
   include/linux/dynamic_debug.h:125:15: note: in definition of macro '__dynamic_func_call'
      func(&id, ##__VA_ARGS__);  \
                  ^~~~~~~~~~~
   include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call'
     _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
     ^~~~~~~~~~~~~~~~~~
   include/linux/device.h:1751:2: note: in expansion of macro 'dynamic_dev_dbg'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~
   include/linux/device.h:1751:23: note: in expansion of macro 'dev_fmt'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
                          ^~~~~~~
>> drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:277:3: note: in expansion of macro 'dev_dbg'
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
      ^~~~~~~
   drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:277:20: warning: format '%u' expects argument of type 'unsigned int', but argument 11 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
                       ^
   include/linux/dynamic_debug.h:125:15: note: in definition of macro '__dynamic_func_call'
      func(&id, ##__VA_ARGS__);  \
                  ^~~~~~~~~~~
   include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call'
     _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
     ^~~~~~~~~~~~~~~~~~
   include/linux/device.h:1751:2: note: in expansion of macro 'dynamic_dev_dbg'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~
   include/linux/device.h:1751:23: note: in expansion of macro 'dev_fmt'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
                          ^~~~~~~
>> drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:277:3: note: in expansion of macro 'dev_dbg'
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
      ^~~~~~~
   In file included from include/linux/clk.h:13:0,
                    from drivers/crypto/allwinner/sun4i-ss/sun4i-ss.h:14,
                    from drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:13:
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:285:10: note: in expansion of macro 'min3'
      todo = min3(tx_cnt, oleft / 4, (mo.length - oo) / 4);
             ^~~~
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c:311:12: note: in expansion of macro 'min'
        todo = min(mo.length - oo, obl - obo);
               ^~~
--
   In file included from include/linux/clk.h:13:0,
                    from drivers/crypto//allwinner/sun4i-ss/sun4i-ss.h:14,
                    from drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:13:
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_opti_poll':
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:75:10: note: in expansion of macro 'min3'
      todo = min3(rx_cnt, ileft, (mi.length - oi) / 4);
             ^~~~
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:90:10: note: in expansion of macro 'min3'
      todo = min3(tx_cnt, oleft, (mo.length - oo) / 4);
             ^~~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c: In function 'sun4i_ss_cipher_poll':
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:242:11: note: in expansion of macro 'min3'
       todo = min3(rx_cnt, ileft / 4, (mi.length - oi) / 4);
              ^~~~
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:256:12: note: in expansion of macro 'min3'
        todo = min3(rx_cnt * 4 - ob, ileft,
               ^~~~
   In file included from include/linux/printk.h:332:0,
                    from include/linux/kernel.h:15,
                    from include/linux/clk.h:13,
                    from drivers/crypto//allwinner/sun4i-ss/sun4i-ss.h:14,
                    from drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:13:
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:277:20: warning: format '%u' expects argument of type 'unsigned int', but argument 6 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
                       ^
   include/linux/dynamic_debug.h:125:15: note: in definition of macro '__dynamic_func_call'
      func(&id, ##__VA_ARGS__);  \
                  ^~~~~~~~~~~
   include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call'
     _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
     ^~~~~~~~~~~~~~~~~~
   include/linux/device.h:1751:2: note: in expansion of macro 'dynamic_dev_dbg'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~
   include/linux/device.h:1751:23: note: in expansion of macro 'dev_fmt'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
                          ^~~~~~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:277:3: note: in expansion of macro 'dev_dbg'
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
      ^~~~~~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:277:20: warning: format '%u' expects argument of type 'unsigned int', but argument 11 has type 'size_t {aka long unsigned int}' [-Wformat=]
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
                       ^
   include/linux/dynamic_debug.h:125:15: note: in definition of macro '__dynamic_func_call'
      func(&id, ##__VA_ARGS__);  \
                  ^~~~~~~~~~~
   include/linux/dynamic_debug.h:157:2: note: in expansion of macro '_dynamic_func_call'
     _dynamic_func_call(fmt,__dynamic_dev_dbg,   \
     ^~~~~~~~~~~~~~~~~~
   include/linux/device.h:1751:2: note: in expansion of macro 'dynamic_dev_dbg'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
     ^~~~~~~~~~~~~~~
   include/linux/device.h:1751:23: note: in expansion of macro 'dev_fmt'
     dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
                          ^~~~~~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:277:3: note: in expansion of macro 'dev_dbg'
      dev_dbg(ss->dev, "%x %u/%u %u/%u cnt=%u %u/%u %u/%u cnt=%u %u\n",
      ^~~~~~~
   In file included from include/linux/clk.h:13:0,
                    from drivers/crypto//allwinner/sun4i-ss/sun4i-ss.h:14,
                    from drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:13:
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
>> include/linux/kernel.h:890:23: note: in expansion of macro 'min'
    #define min3(x, y, z) min((typeof(x))min(x, y), z)
                          ^~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:285:10: note: in expansion of macro 'min3'
      todo = min3(tx_cnt, oleft / 4, (mo.length - oo) / 4);
             ^~~~
   include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a cast
      (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
                                ^
   include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
      (__typecheck(x, y) && __no_side_effects(x, y))
       ^~~~~~~~~~~
   include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
     __builtin_choose_expr(__safe_cmp(x, y), \
                           ^~~~~~~~~~
   include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
    #define min(x, y) __careful_cmp(x, y, <)
                      ^~~~~~~~~~~~~
   drivers/crypto//allwinner/sun4i-ss/sun4i-ss-cipher.c:311:12: note: in expansion of macro 'min'
        todo = min(mo.length - oo, obl - obo);
               ^~~

vim +/min +890 include/linux/kernel.h

526211bc58c4b3 Ingo Molnar       2009-03-05  828  
^1da177e4c3f41 Linus Torvalds    2005-04-16  829  /*
3c8ba0d61d04ce Kees Cook         2018-03-30  830   * min()/max()/clamp() macros must accomplish three things:
3c8ba0d61d04ce Kees Cook         2018-03-30  831   *
3c8ba0d61d04ce Kees Cook         2018-03-30  832   * - avoid multiple evaluations of the arguments (so side-effects like
3c8ba0d61d04ce Kees Cook         2018-03-30  833   *   "x++" happen only once) when non-constant.
3c8ba0d61d04ce Kees Cook         2018-03-30  834   * - perform strict type-checking (to generate warnings instead of
3c8ba0d61d04ce Kees Cook         2018-03-30  835   *   nasty runtime surprises). See the "unnecessary" pointer comparison
3c8ba0d61d04ce Kees Cook         2018-03-30  836   *   in __typecheck().
3c8ba0d61d04ce Kees Cook         2018-03-30  837   * - retain result as a constant expressions when called with only
3c8ba0d61d04ce Kees Cook         2018-03-30  838   *   constant expressions (to avoid tripping VLA warnings in stack
3c8ba0d61d04ce Kees Cook         2018-03-30  839   *   allocation usage).
3c8ba0d61d04ce Kees Cook         2018-03-30  840   */
3c8ba0d61d04ce Kees Cook         2018-03-30  841  #define __typecheck(x, y) \
3c8ba0d61d04ce Kees Cook         2018-03-30  842  		(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
3c8ba0d61d04ce Kees Cook         2018-03-30  843  
3c8ba0d61d04ce Kees Cook         2018-03-30  844  /*
3c8ba0d61d04ce Kees Cook         2018-03-30  845   * This returns a constant expression while determining if an argument is
3c8ba0d61d04ce Kees Cook         2018-03-30  846   * a constant expression, most importantly without evaluating the argument.
3c8ba0d61d04ce Kees Cook         2018-03-30  847   * Glory to Martin Uecker <Martin.Uecker@xxxxxxxxxxxxxxxxxxxxx>
^1da177e4c3f41 Linus Torvalds    2005-04-16  848   */
3c8ba0d61d04ce Kees Cook         2018-03-30  849  #define __is_constexpr(x) \
3c8ba0d61d04ce Kees Cook         2018-03-30  850  	(sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
3c8ba0d61d04ce Kees Cook         2018-03-30  851  
3c8ba0d61d04ce Kees Cook         2018-03-30  852  #define __no_side_effects(x, y) \
3c8ba0d61d04ce Kees Cook         2018-03-30  853  		(__is_constexpr(x) && __is_constexpr(y))
3c8ba0d61d04ce Kees Cook         2018-03-30  854  
3c8ba0d61d04ce Kees Cook         2018-03-30  855  #define __safe_cmp(x, y) \
3c8ba0d61d04ce Kees Cook         2018-03-30 @856  		(__typecheck(x, y) && __no_side_effects(x, y))
3c8ba0d61d04ce Kees Cook         2018-03-30  857  
3c8ba0d61d04ce Kees Cook         2018-03-30  858  #define __cmp(x, y, op)	((x) op (y) ? (x) : (y))
3c8ba0d61d04ce Kees Cook         2018-03-30  859  
e9092d0d979611 Linus Torvalds    2018-04-09  860  #define __cmp_once(x, y, unique_x, unique_y, op) ({	\
e9092d0d979611 Linus Torvalds    2018-04-09  861  		typeof(x) unique_x = (x);		\
e9092d0d979611 Linus Torvalds    2018-04-09  862  		typeof(y) unique_y = (y);		\
e9092d0d979611 Linus Torvalds    2018-04-09  863  		__cmp(unique_x, unique_y, op); })
3c8ba0d61d04ce Kees Cook         2018-03-30  864  
3c8ba0d61d04ce Kees Cook         2018-03-30  865  #define __careful_cmp(x, y, op) \
3c8ba0d61d04ce Kees Cook         2018-03-30  866  	__builtin_choose_expr(__safe_cmp(x, y), \
e9092d0d979611 Linus Torvalds    2018-04-09  867  		__cmp(x, y, op), \
e9092d0d979611 Linus Torvalds    2018-04-09  868  		__cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
e8c97af0c1f23d Randy Dunlap      2017-10-13  869  
e8c97af0c1f23d Randy Dunlap      2017-10-13  870  /**
e8c97af0c1f23d Randy Dunlap      2017-10-13  871   * min - return minimum of two values of the same or compatible types
e8c97af0c1f23d Randy Dunlap      2017-10-13  872   * @x: first value
e8c97af0c1f23d Randy Dunlap      2017-10-13  873   * @y: second value
e8c97af0c1f23d Randy Dunlap      2017-10-13  874   */
3c8ba0d61d04ce Kees Cook         2018-03-30  875  #define min(x, y)	__careful_cmp(x, y, <)
e8c97af0c1f23d Randy Dunlap      2017-10-13  876  
e8c97af0c1f23d Randy Dunlap      2017-10-13  877  /**
e8c97af0c1f23d Randy Dunlap      2017-10-13  878   * max - return maximum of two values of the same or compatible types
e8c97af0c1f23d Randy Dunlap      2017-10-13  879   * @x: first value
e8c97af0c1f23d Randy Dunlap      2017-10-13  880   * @y: second value
e8c97af0c1f23d Randy Dunlap      2017-10-13  881   */
3c8ba0d61d04ce Kees Cook         2018-03-30  882  #define max(x, y)	__careful_cmp(x, y, >)
bdf4bbaaee3d4b Harvey Harrison   2008-04-30  883  
e8c97af0c1f23d Randy Dunlap      2017-10-13  884  /**
e8c97af0c1f23d Randy Dunlap      2017-10-13  885   * min3 - return minimum of three values
e8c97af0c1f23d Randy Dunlap      2017-10-13  886   * @x: first value
e8c97af0c1f23d Randy Dunlap      2017-10-13  887   * @y: second value
e8c97af0c1f23d Randy Dunlap      2017-10-13  888   * @z: third value
e8c97af0c1f23d Randy Dunlap      2017-10-13  889   */
2e1d06e1c05af9 Michal Nazarewicz 2014-10-09 @890  #define min3(x, y, z) min((typeof(x))min(x, y), z)
e8c97af0c1f23d Randy Dunlap      2017-10-13  891  

:::::: The code at line 890 was first introduced by commit
:::::: 2e1d06e1c05af9dbe8a3bfddeefbf041ca637fff include/linux/kernel.h: rewrite min3, max3 and clamp using min and max

:::::: TO: Michal Nazarewicz <mina86@xxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux