All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: David Laight <David.Laight@aculab.com>,
	"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>,
	'Andy Shevchenko' <andriy.shevchenko@linux.intel.com>,
	'Andrew Morton' <akpm@linux-foundation.org>,
	"'Matthew Wilcox (Oracle)'" <willy@infradead.org>,
	'Christoph Hellwig' <hch@infradead.org>,
	"'Jason A. Donenfeld'" <Jason@zx2c4.com>
Cc: oe-kbuild-all@lists.linux.dev,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: Re: [PATCH next resend 5/5] minmax: Relax check to allow comparison between int and small unsigned constants.
Date: Wed, 26 Jul 2023 03:36:33 +0800	[thread overview]
Message-ID: <202307260303.3ftEpZRU-lkp@intel.com> (raw)
In-Reply-To: <48c2cd0407f14859919d4fcbe526234a@AcuMS.aculab.com>

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@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230726/202307260303.3ftEpZRU-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202307260303.3ftEpZRU-lkp@intel.com/

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

  reply	other threads:[~2023-07-25 19:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25 10:00 [PATCH next 0/5] minmax: Relax type checks in min() and max() David Laight
2023-07-25 10:38 ` 'Andy Shevchenko'
2023-07-25 11:17   ` David Laight
2023-07-25 11:48 ` [PATCH next resend 1/5] minmax: Add min_unsigned(a, b) and max_unsigned(a, b) David Laight
2023-07-25 12:38   ` Matthew Wilcox
2023-07-25 13:20     ` David Laight
2023-07-25 11:51 ` [PATCH next resend 2/5] minmax: Allow min()/max()/clamp() if the arguments have the same signedness David Laight
2023-07-25 18:02   ` kernel test robot
2023-07-25 18:33   ` kernel test robot
2023-07-26  9:19     ` David Laight
2023-07-26  9:50       ` Marc Zyngier
2023-07-26 10:25         ` David Laight
2023-07-25 11:52 ` [PATCH next resend 3/5] minmax: Fix indentation of __cmp_once() and __clamp_once() David Laight
2023-07-25 11:53 ` [PATCH next resend 4/5] minmax: Allow comparisons of 'int' against 'unsigned char/short' David Laight
2023-07-25 11:54 ` [PATCH next resend 5/5] minmax: Relax check to allow comparison between int and small unsigned constants David Laight
2023-07-25 19:36   ` kernel test robot [this message]
2023-07-26  9:29     ` David Laight
2023-07-27  5:20   ` kernel test robot
2023-07-28  7:15   ` kernel test robot
2023-07-28  8:08   ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2023-07-30  1:59 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202307260303.3ftEpZRU-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=David.Laight@aculab.com \
    --cc=Jason@zx2c4.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.