Use min_t to replace min, min_t is a bit fast because min use twice typeof. This patch also fix check_patch.pl warning: WARNING: min() should probably be min_t(unsigned long, num_pages, VMW_PPN_PER_REMAP) +unsigned long nr = min(num_pages, (unsigned long) VMW_PPN_PER_REMAP);
Signed-off-by: Bernard Zhao bernard@vivo.com --- drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c index 83c0d5a3e4fd..b8f6fe1a71e6 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c @@ -72,7 +72,7 @@ static int vmw_gmr2_bind(struct vmw_private *dev_priv, SVGA_REMAP_GMR2_PPN64 : SVGA_REMAP_GMR2_PPN32;
while (num_pages > 0) { - unsigned long nr = min(num_pages, (unsigned long)VMW_PPN_PER_REMAP); + unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP);
remap_cmd.offsetPages = remap_pos; remap_cmd.numPages = nr;
Hi Bernard,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on linus/master] [also build test ERROR on v5.10-rc4 next-20201118] [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]
url: https://github.com/0day-ci/linux/commits/Bernard-Zhao/drm-vmwgfx-use-min_t-t... base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0fa8ee0d9ab95c9350b8b84574824d9a384a9f7d config: i386-randconfig-a012-20201118 (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/7de055295e38f294671f936d65719c021952... git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Bernard-Zhao/drm-vmwgfx-use-min_t-to-replace-min/20201118-191834 git checkout 7de055295e38f294671f936d65719c02195251ca # save the attached .config to linux build tree make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot lkp@intel.com
All errors (new ones prefixed by >>):
drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c: In function 'vmw_gmr2_bind': include/linux/minmax.h:110:46: error: expected expression before ')' token 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^ include/linux/minmax.h:18:21: note: in definition of macro '__typecheck' 18 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) | ^ include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp' 42 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/minmax.h:110:46: error: expected expression before ')' token 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^ include/linux/minmax.h:26:48: note: in definition of macro '__is_constexpr' 26 | (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) | ^ include/linux/minmax.h:32:25: note: in expansion of macro '__no_side_effects' 32 | (__typecheck(x, y) && __no_side_effects(x, y)) | ^~~~~~~~~~~~~~~~~ include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp' 42 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/minmax.h:110:57: error: expected expression before ')' token 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^ include/linux/minmax.h:26:48: note: in definition of macro '__is_constexpr' 26 | (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8))) | ^ include/linux/minmax.h:32:25: note: in expansion of macro '__no_side_effects' 32 | (__typecheck(x, y) && __no_side_effects(x, y)) | ^~~~~~~~~~~~~~~~~ include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp' 42 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/minmax.h:110:46: error: expected expression before ')' token 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^ include/linux/minmax.h:34:27: note: in definition of macro '__cmp' 34 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y)) | ^ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/minmax.h:110:46: error: expected expression before ')' token 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^ include/linux/minmax.h:37:10: note: in definition of macro '__cmp_once' 37 | typeof(x) unique_x = (x); \ | ^ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/minmax.h:110:57: error: expected expression before ')' token 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^ include/linux/minmax.h:38:10: note: in definition of macro '__cmp_once' 38 | typeof(y) unique_y = (y); \ | ^ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/minmax.h:110:57: error: expected expression before ')' token 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^ include/linux/minmax.h:38:25: note: in definition of macro '__cmp_once' 38 | typeof(y) unique_y = (y); \ | ^ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~
include/linux/compiler-gcc.h:47:45: error: '__UNIQUE_ID___x264' undeclared (first use in this function); did you mean '__UNIQUE_ID___y265'?
47 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | ^~~~~~~~~~~~ include/linux/minmax.h:34:27: note: in definition of macro '__cmp' 34 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y)) | ^ include/linux/minmax.h:44:3: note: in expansion of macro '__cmp_once' 44 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~ include/linux/compiler_types.h:60:22: note: in expansion of macro '___PASTE' 60 | #define __PASTE(a,b) ___PASTE(a,b) | ^~~~~~~~ include/linux/compiler-gcc.h:47:29: note: in expansion of macro '__PASTE' 47 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | ^~~~~~~ include/linux/compiler_types.h:60:22: note: in expansion of macro '___PASTE' 60 | #define __PASTE(a,b) ___PASTE(a,b) | ^~~~~~~~ include/linux/compiler-gcc.h:47:37: note: in expansion of macro '__PASTE' 47 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | ^~~~~~~ include/linux/minmax.h:44:20: note: in expansion of macro '__UNIQUE_ID' 44 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~~ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/compiler-gcc.h:47:45: note: each undeclared identifier is reported only once for each function it appears in 47 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | ^~~~~~~~~~~~ include/linux/minmax.h:34:27: note: in definition of macro '__cmp' 34 | #define __cmp(x, y, op) ((x) op (y) ? (x) : (y)) | ^ include/linux/minmax.h:44:3: note: in expansion of macro '__cmp_once' 44 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~ include/linux/compiler_types.h:60:22: note: in expansion of macro '___PASTE' 60 | #define __PASTE(a,b) ___PASTE(a,b) | ^~~~~~~~ include/linux/compiler-gcc.h:47:29: note: in expansion of macro '__PASTE' 47 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | ^~~~~~~ include/linux/compiler_types.h:60:22: note: in expansion of macro '___PASTE' 60 | #define __PASTE(a,b) ___PASTE(a,b) | ^~~~~~~~ include/linux/compiler-gcc.h:47:37: note: in expansion of macro '__PASTE' 47 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) | ^~~~~~~ include/linux/minmax.h:44:20: note: in expansion of macro '__UNIQUE_ID' 44 | __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op)) | ^~~~~~~~~~~ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~ include/linux/minmax.h:42:2: error: first argument to '__builtin_choose_expr' not a constant 42 | __builtin_choose_expr(__safe_cmp(x, y), \ | ^~~~~~~~~~~~~~~~~~~~~ include/linux/minmax.h:110:27: note: in expansion of macro '__careful_cmp' 110 | #define min_t(type, x, y) __careful_cmp((type)(x), (type)(y), <) | ^~~~~~~~~~~~~ drivers/gpu/drm/vmwgfx/vmwgfx_gmr.c:75:22: note: in expansion of macro 'min_t' 75 | unsigned long nr = min_t((unsigned long), num_pages, VMW_PPN_PER_REMAP); | ^~~~~
vim +47 include/linux/compiler-gcc.h
87358710c1fb4f1 David Woodhouse 2018-02-19 46 cb984d101b30eb7 Joe Perches 2015-06-25 @47 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) cb984d101b30eb7 Joe Perches 2015-06-25 48
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
dri-devel@lists.freedesktop.org