Re: [PATCH next resend 5/5] minmax: Relax check to allow comparison between int and small unsigned constants.

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

 



Hi David,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on linus/master v6.5-rc3 next-20230725]
[cannot apply to next-20230725]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/David-Laight/minmax-Allow-min-max-clamp-if-the-arguments-have-the-same-signedness/20230725-204940
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/48c2cd0407f14859919d4fcbe526234a%40AcuMS.aculab.com
patch subject: [PATCH next resend 5/5] minmax: Relax check to allow comparison between int and small unsigned constants.
config: riscv-randconfig-r024-20230725 (https://download.01.org/0day-ci/archive/20230726/202307260303.3ftEpZRU-lkp@xxxxxxxxx/config)
compiler: riscv32-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230726/202307260303.3ftEpZRU-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307260303.3ftEpZRU-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:27,
                    from include/linux/cpumask.h:10,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/mutex.h:17,
                    from include/linux/notifier.h:14,
                    from include/linux/kprobes.h:21,
                    from include/linux/kgdb.h:19,
                    from include/linux/fb.h:6,
                    from drivers/gpu/drm/drm_modes.c:35:
   drivers/gpu/drm/drm_modes.c: In function 'drm_mode_parse_command_line_for_connector':
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/minmax.h:36:27: note: in definition of macro '__cmp'
      36 | #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
         |                           ^
   include/linux/minmax.h:25:47: note: in expansion of macro '__is_noneg_int'
      25 | #define __int_const(x)  __builtin_choose_expr(__is_noneg_int(x), (int)(long)(x), (x))
         |                                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:47:27: note: in expansion of macro '__int_const'
      47 |                 __cmp(op, __int_const(x), __int_const(y)),      \
         |                           ^~~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/minmax.h:36:45: note: in definition of macro '__cmp'
      36 | #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
         |                                             ^
   include/linux/minmax.h:25:47: note: in expansion of macro '__is_noneg_int'
      25 | #define __int_const(x)  __builtin_choose_expr(__is_noneg_int(x), (int)(long)(x), (x))
         |                                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:47:43: note: in expansion of macro '__int_const'
      47 |                 __cmp(op, __int_const(x), __int_const(y)),      \
         |                                           ^~~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/minmax.h:36:51: note: in definition of macro '__cmp'
      36 | #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
         |                                                   ^
   include/linux/minmax.h:25:47: note: in expansion of macro '__is_noneg_int'
      25 | #define __int_const(x)  __builtin_choose_expr(__is_noneg_int(x), (int)(long)(x), (x))
         |                                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:47:27: note: in expansion of macro '__int_const'
      47 |                 __cmp(op, __int_const(x), __int_const(y)),      \
         |                           ^~~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/minmax.h:36:57: note: in definition of macro '__cmp'
      36 | #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
         |                                                         ^
   include/linux/minmax.h:25:47: note: in expansion of macro '__is_noneg_int'
      25 | #define __int_const(x)  __builtin_choose_expr(__is_noneg_int(x), (int)(long)(x), (x))
         |                                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:47:43: note: in expansion of macro '__int_const'
      47 |                 __cmp(op, __int_const(x), __int_const(y)),      \
         |                                           ^~~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/minmax.h:25:47: note: in expansion of macro '__is_noneg_int'
      25 | #define __int_const(x)  __builtin_choose_expr(__is_noneg_int(x), (int)(long)(x), (x))
         |                                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:39:16: note: in expansion of macro '__int_const'
      39 |         typeof(__int_const(x)) unique_x = (x);          \
         |                ^~~~~~~~~~~
   include/linux/minmax.h:48:17: note: in expansion of macro '__cmp_once'
      48 |                 __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
         |                 ^~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/minmax.h:25:47: note: in expansion of macro '__is_noneg_int'
      25 | #define __int_const(x)  __builtin_choose_expr(__is_noneg_int(x), (int)(long)(x), (x))
         |                                               ^~~~~~~~~~~~~~
   include/linux/minmax.h:40:16: note: in expansion of macro '__int_const'
      40 |         typeof(__int_const(y)) unique_y = (y);          \
         |                ^~~~~~~~~~~
   include/linux/minmax.h:48:17: note: in expansion of macro '__cmp_once'
      48 |                 __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
         |                 ^~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~
   In file included from include/linux/init.h:5,
                    from include/linux/printk.h:6,
                    from include/asm-generic/bug.h:22,
                    from arch/riscv/include/asm/bug.h:83,
                    from include/linux/bug.h:5,
                    from arch/riscv/include/asm/cmpxchg.h:9,
                    from arch/riscv/include/asm/atomic.h:19,
                    from include/linux/atomic.h:7,
                    from include/linux/refcount.h:95,
                    from include/linux/fb.h:5:
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/minmax.h:41:9: note: in expansion of macro 'static_assert'
      41 |         static_assert(__types_ok(x, y),                 \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:31:17: note: in expansion of macro '__is_noneg_int'
      31 |                 __is_noneg_int(x) || __is_noneg_int(y))
         |                 ^~~~~~~~~~~~~~
   include/linux/minmax.h:41:23: note: in expansion of macro '__types_ok'
      41 |         static_assert(__types_ok(x, y),                 \
         |                       ^~~~~~~~~~
   include/linux/minmax.h:48:17: note: in expansion of macro '__cmp_once'
      48 |                 __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
         |                 ^~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~
>> include/linux/minmax.h:23:22: warning: ordered comparison of pointer with integer zero [-Wextra]
      23 |                 ((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
         |                      ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
      78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
         |                                                        ^~~~
   include/linux/minmax.h:41:9: note: in expansion of macro 'static_assert'
      41 |         static_assert(__types_ok(x, y),                 \
         |         ^~~~~~~~~~~~~
   include/linux/minmax.h:31:38: note: in expansion of macro '__is_noneg_int'
      31 |                 __is_noneg_int(x) || __is_noneg_int(y))
         |                                      ^~~~~~~~~~~~~~
   include/linux/minmax.h:41:23: note: in expansion of macro '__types_ok'
      41 |         static_assert(__types_ok(x, y),                 \
         |                       ^~~~~~~~~~
   include/linux/minmax.h:48:17: note: in expansion of macro '__cmp_once'
      48 |                 __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
         |                 ^~~~~~~~~~
   include/linux/minmax.h:81:25: note: in expansion of macro '__careful_cmp'
      81 | #define max(x, y)       __careful_cmp(max, x, y)
         |                         ^~~~~~~~~~~~~
   drivers/gpu/drm/drm_modes.c:2474:29: note: in expansion of macro 'max'
    2474 |                 extra_ptr = max(bpp_end_ptr, refresh_end_ptr);
         |                             ^~~


vim +23 include/linux/minmax.h

     6	
     7	/*
     8	 * min()/max()/clamp() macros must accomplish three things:
     9	 *
    10	 * - Avoid multiple evaluations of the arguments (so side-effects like
    11	 *   "x++" happen only once) when non-constant.
    12	 * - Perform signed v unsigned type-checking (to generate compile
    13	 *   errors instead of nasty runtime surprises).
    14	 *   Constants from 0 to INT_MAX are cast to (int) so can be used
    15	 *   in comparisons with signed types.
    16	 * - Retain result as a constant expressions when called with only
    17	 *   constant expressions (to avoid tripping VLA warnings in stack
    18	 *   allocation usage).
    19	 */
    20	
    21	#define __is_noneg_int(x)					\
    22		__builtin_choose_expr(!__is_constexpr(x), false, 	\
  > 23			((x) >= 0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))
    24	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux