[jens-wiklander-tee:testing/tuxbuild 5/13] drivers/tee/tee_shm_pool.c:17:13: warning: comparison of distinct pointer types ('typeof (align) *' (aka 'unsigned int *') and 'typeof (((((1UL))) << (genpool->min_alloc_order))) *' (aka 'unsigned long *'))

From: kernel test robot
Date: Fri Jan 14 2022 - 01:43:34 EST


tree: http://git.linaro.org/people/jens.wiklander/linux-tee testing/tuxbuild
head: 9ea0d125d4c9a4144b8641c454e97406b483722d
commit: 5b552e1bc3780894781030500c0216a9e0bef3f8 [5/13] tee: simplify shm pool handling
config: hexagon-randconfig-r041-20220113 (https://download.01.org/0day-ci/archive/20220114/202201141423.k7Z21dOm-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 82c8aca93488730ce8f66101e0f3538f14b551dd)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git remote add jens-wiklander-tee http://git.linaro.org/people/jens.wiklander/linux-tee
git fetch --no-tags jens-wiklander-tee testing/tuxbuild
git checkout 5b552e1bc3780894781030500c0216a9e0bef3f8
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/tee/

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

All warnings (new ones prefixed by >>):

>> drivers/tee/tee_shm_pool.c:17:13: warning: comparison of distinct pointer types ('typeof (align) *' (aka 'unsigned int *') and 'typeof (((((1UL))) << (genpool->min_alloc_order))) *' (aka 'unsigned long *')) [-Wcompare-distinct-pointer-types]
size_t a = max(align, BIT(genpool->min_alloc_order));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:52:19: note: expanded from macro 'max'
#define max(x, y) __careful_cmp(x, y, >)
^~~~~~~~~~~~~~~~~~~~~~
include/linux/minmax.h:36:24: note: expanded from macro '__careful_cmp'
__builtin_choose_expr(__safe_cmp(x, y), \
^~~~~~~~~~~~~~~~
include/linux/minmax.h:26:4: note: expanded from macro '__safe_cmp'
(__typecheck(x, y) && __no_side_effects(x, y))
^~~~~~~~~~~~~~~~~
include/linux/minmax.h:20:28: note: expanded from macro '__typecheck'
(!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
1 warning generated.


vim +17 drivers/tee/tee_shm_pool.c

11
12 static int pool_op_gen_alloc(struct tee_shm_pool *pool, struct tee_shm *shm,
13 size_t size, size_t align)
14 {
15 unsigned long va;
16 struct gen_pool *genpool = pool->private_data;
> 17 size_t a = max(align, BIT(genpool->min_alloc_order));
18 struct genpool_data_align data = { .align = a };
19 size_t s = roundup(size, a);
20
21 va = gen_pool_alloc_algo(genpool, s, gen_pool_first_fit_align, &data);
22 if (!va)
23 return -ENOMEM;
24
25 memset((void *)va, 0, s);
26 shm->kaddr = (void *)va;
27 shm->paddr = gen_pool_virt_to_phys(genpool, va);
28 shm->size = s;
29 /*
30 * This is from a static shared memory pool so no need to register
31 * each chunk, and no need to unregister later either.
32 */
33 shm->flags &= ~TEE_SHM_REGISTER;
34 return 0;
35 }
36

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx