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

From: David Laight
Date: Sun Jul 30 2023 - 12:56:04 EST


From: kernel test robot
> Sent: 28 July 2023 22:43
>
> kernel test robot noticed the following build warnings:
>
> [auto build test WARNING on akpm-mm/mm-everything]
> [also build test WARNING on linus/master crng-random/master v6.5-rc3 next-20230728]
> [cannot apply to next-20230728]
> [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-Add-min_unsigned-a-b-and-
> max_unsigned-a-b/20230728-225439
> base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
> patch link: https://lore.kernel.org/r/b4ce9dad748e489f9314a2dc95615033%40AcuMS.aculab.com
> patch subject: [PATCH next v2 5/5] minmax: Relax check to allow comparison between int and small
> unsigned constants.
> config: alpha-randconfig-r024-20230727 (https://download.01.org/0day-
> ci/archive/20230729/202307290538.EtRKfGgC-lkp@xxxxxxxxx/config)
> compiler: alpha-linux-gcc (GCC) 12.3.0
> reproduce: (https://download.01.org/0day-ci/archive/20230729/202307290538.EtRKfGgC-
> 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/202307290538.EtRKfGgC-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/mm_types_task.h:14,
> from include/linux/mm_types.h:5,
> from include/linux/buildid.h:5,
> from include/linux/module.h:14,
> from net/ceph/osdmap.c:5:
> net/ceph/osdmap.c: In function 'osdmap_decode':
> >> include/linux/minmax.h:26:22: warning: ordered comparison of pointer with null pointer [-Wextra]
> 26 | ((x) >= (typeof(x))0 && (x) <= (typeof((x) + 0))(long)__INT_MAX__))

I have a cunning plan to fix this (and warnings about testing 'unsigned >= 0').
Basically replace the first test with:
__builtin_choose_expr(is_signed(x), x, 1) >= 0

(Also fixes the build with clang < 16.)

Hopefully that v3 will keep the build robert happy :-)

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)