drivers/net/dsa/sja1105/sja1105_main.c:3418:38: warning: address of array 'match->compatible' will always evaluate to 'true'

From: kernel test robot
Date: Fri Aug 07 2020 - 08:18:22 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 86cfccb66937dd6cbf26ed619958b9e587e6a115
commit: 0b0e299720bb99428892a23ecbd2b4b7f61ccf6d net: dsa: sja1105: use detected device id instead of DT one on mismatch
date: 2 days ago
config: riscv-randconfig-r034-20200807 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project aa57cabae2fc5abc08ab3e17b45f2890fc7c9e42)
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
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
git checkout 0b0e299720bb99428892a23ecbd2b4b7f61ccf6d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv

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/net/dsa/sja1105/sja1105_main.c:3418:38: warning: address of array 'match->compatible' will always evaluate to 'true' [-Wpointer-bool-conversion]
for (match = sja1105_dt_ids; match->compatible; match++) {
~~~ ~~~~~~~^~~~~~~~~~
1 warning generated.

vim +3418 drivers/net/dsa/sja1105/sja1105_main.c

3395
3396 static int sja1105_check_device_id(struct sja1105_private *priv)
3397 {
3398 const struct sja1105_regs *regs = priv->info->regs;
3399 u8 prod_id[SJA1105_SIZE_DEVICE_ID] = {0};
3400 struct device *dev = &priv->spidev->dev;
3401 const struct of_device_id *match;
3402 u32 device_id;
3403 u64 part_no;
3404 int rc;
3405
3406 rc = sja1105_xfer_u32(priv, SPI_READ, regs->device_id, &device_id,
3407 NULL);
3408 if (rc < 0)
3409 return rc;
3410
3411 rc = sja1105_xfer_buf(priv, SPI_READ, regs->prod_id, prod_id,
3412 SJA1105_SIZE_DEVICE_ID);
3413 if (rc < 0)
3414 return rc;
3415
3416 sja1105_unpack(prod_id, &part_no, 19, 4, SJA1105_SIZE_DEVICE_ID);
3417
> 3418 for (match = sja1105_dt_ids; match->compatible; match++) {
3419 const struct sja1105_info *info = match->data;
3420
3421 /* Is what's been probed in our match table at all? */
3422 if (info->device_id != device_id || info->part_no != part_no)
3423 continue;
3424
3425 /* But is it what's in the device tree? */
3426 if (priv->info->device_id != device_id ||
3427 priv->info->part_no != part_no) {
3428 dev_warn(dev, "Device tree specifies chip %s but found %s, please fix it!\n",
3429 priv->info->name, info->name);
3430 /* It isn't. No problem, pick that up. */
3431 priv->info = info;
3432 }
3433
3434 return 0;
3435 }
3436
3437 dev_err(dev, "Unexpected {device ID, part number}: 0x%x 0x%llx\n",
3438 device_id, part_no);
3439
3440 return -ENODEV;
3441 }
3442

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

Attachment: .config.gz
Description: application/gzip