Re: drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:298:38: sparse: sparse: dubious: !x | !y

From: David Laight
Date: Wed Jan 29 2025 - 17:21:55 EST


On Wed, 29 Jan 2025 22:02:59 +0800
kernel test robot <lkp@xxxxxxxxx> wrote:

> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 05dbaf8dd8bf537d4b4eb3115ab42a5fb40ff1f5
> commit: a688404b2e20f00cce6d0a2b888ef4ca9154e144 HID: intel-thc-hid: intel-thc: Add THC DMA interfaces
> date: 3 weeks ago
> config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20250129/202501292144.eFDq4ovr-lkp@xxxxxxxxx/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250129/202501292144.eFDq4ovr-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/202501292144.eFDq4ovr-lkp@xxxxxxxxx/
>
> sparse warnings: (new ones prefixed by >>)
> >> drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c:298:38: sparse: sparse: dubious: !x | !y
> drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c: note: in included file (through include/linux/mmzone.h, include/linux/gfp.h, include/linux/mm.h, ...):
> include/linux/page-flags.h:237:46: sparse: sparse: self-comparison always evaluates to false
> include/linux/page-flags.h:237:46: sparse: sparse: self-comparison always evaluates to false
>
> vim +298 drivers/hid/intel-thc-hid/intel-thc/intel-thc-dma.c
...
> 297 for (i = 0; i < config->prd_tbl_num; i++) {
> > 298 if (!config->sgls[i] | !config->sgls_nent[i])
> 299 continue;
...

If zeros are unlikely the bit-wise 'or' is pretty likely to generate better code
than a logical 'or'.

David