Re: drivers/net/ethernet/micrel/ks8851_common.c:995:6: warning: variable 'ret' set but not used

From: Nathan Chancellor
Date: Wed Jun 02 2021 - 16:02:47 EST


On 6/2/2021 12:32 PM, kernel test robot wrote:
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 231bc539066760aaa44d46818c85b14ca2f56d9f
commit: 797047f875b5463719cc70ba213eb691d453c946 net: ks8851: Implement Parallel bus operations
date: 1 year ago
config: x86_64-randconfig-a004-20210601 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project d41cb6bb2607fa5c7a9df2b3dab361353657d225)
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 x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=797047f875b5463719cc70ba213eb691d453c946
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 797047f875b5463719cc70ba213eb691d453c946
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64

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/ethernet/micrel/ks8851_common.c:995:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
int ret = 0;
^
1 warning generated.

This warning is newly implemented in clang, it was not caused by the above commit. As you can see from the blame below, this has been an issue since this driver's introduction. I wonder if it was intended to return ret in the places that return 0?

Cheers,
Nathan

vim +/ret +995 drivers/net/ethernet/micrel/ks8851_common.c

3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 985
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 986 /**
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 987 * ks8851_read_selftest - read the selftest memory info.
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 988 * @ks: The device state
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 989 *
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 990 * Read and check the TX/RX memory selftest information.
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 991 */
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 992 static int ks8851_read_selftest(struct ks8851_net *ks)
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 993 {
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 994 unsigned both_done = MBIR_TXMBF | MBIR_RXMBF;
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 @995 int ret = 0;
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 996 unsigned rd;
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 997
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 998 rd = ks8851_rdreg16(ks, KS_MBIR);
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 999
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1000 if ((rd & both_done) != both_done) {
0dc7d2b3cbfcf4 drivers/net/ks8851.c Joe Perches 2010-02-27 1001 netdev_warn(ks->netdev, "Memory selftest not finished\n");
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1002 return 0;
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1003 }
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1004
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1005 if (rd & MBIR_TXMBFA) {
0dc7d2b3cbfcf4 drivers/net/ks8851.c Joe Perches 2010-02-27 1006 netdev_err(ks->netdev, "TX memory selftest fail\n");
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1007 ret |= 1;
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1008 }
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1009
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1010 if (rd & MBIR_RXMBFA) {
0dc7d2b3cbfcf4 drivers/net/ks8851.c Joe Perches 2010-02-27 1011 netdev_err(ks->netdev, "RX memory selftest fail\n");
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1012 ret |= 2;
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1013 }
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1014
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1015 return 0;
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1016 }
3ba81f3ece3cfa drivers/net/ks8851.c Ben Dooks 2009-07-16 1017

:::::: The code at line 995 was first introduced by commit
:::::: 3ba81f3ece3cfa4ffb06d21ac93b8cad7fbe6a73 net: Micrel KS8851 SPI network driver

:::::: TO: Ben Dooks <ben@xxxxxxxxxxxx>
:::::: CC: David S. Miller <davem@xxxxxxxxxxxxx>

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