Subject: [net-next:master 89/100] drivers/net/phy/motorcomm.c:58:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true

From: kernel test robot <[email-masked]>
Date: Sat, 22 May 2021 23:48:48 +0800

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
head:   f5120f5998803a973b1d432ed2aa7e592527aa46
commit: 48e8c6f1612b3d2dccaea2285231def830cc5b8e [89/100] net: phy: add driver for Motorcomm yt8511 phy
config: arm-randconfig-r033-20210522 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project e84a9b9bb3051c35dea993cdad7b3d2575638f85)
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 arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/commit/?id=48e8c6f1612b3d2dccaea2285231def830cc5b8e
        git remote add net-next https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git
        git fetch --no-tags net-next master
        git checkout 48e8c6f1612b3d2dccaea2285231def830cc5b8e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email-masked]>

All warnings (new ones prefixed by >>):

>> drivers/net/phy/motorcomm.c:58:6: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (oldpage < 0)
               ^~~~~~~~~~~
   drivers/net/phy/motorcomm.c:110:43: note: uninitialized use occurs here
           return phy_restore_page(phydev, oldpage, ret);
                                                    ^~~
   drivers/net/phy/motorcomm.c:58:2: note: remove the 'if' if its condition is always false
           if (oldpage < 0)
           ^~~~~~~~~~~~~~~~
   drivers/net/phy/motorcomm.c:54:9: note: initialize the variable 'ret' to silence this warning
           int ret, oldpage;
                  ^
                   = 0
>> drivers/net/phy/motorcomm.c:83:2: warning: variable 'ge' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
           default: /* leave everything alone in other modes */
           ^~~~~~~
   drivers/net/phy/motorcomm.c:87:85: note: uninitialized use occurs here
           ret = __phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge);
                                                                                              ^~
   drivers/net/phy/motorcomm.c:53:17: note: initialize the variable 'ge' to silence this warning
           unsigned int ge, fe;
                          ^
                           = 0
   2 warnings generated.

vim +58 drivers/net/phy/motorcomm.c

    50	
    51	static int yt8511_config_init(struct phy_device *phydev)
    52	{
    53		unsigned int ge, fe;
    54		int ret, oldpage;
    55	
    56		/* set clock mode to 125mhz */
    57		oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE);
  > 58		if (oldpage < 0)
    59			goto err_restore_page;
    60	
    61		ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_CLK_125M);
    62		if (ret < 0)
    63			goto err_restore_page;
    64	
    65		/* set rgmii delay mode */
    66		switch (phydev->interface) {
    67		case PHY_INTERFACE_MODE_RGMII:
    68			ge = YT8511_DELAY_GE_TX_DIS;
    69			fe = YT8511_DELAY_FE_TX_DIS;
    70			break;
    71		case PHY_INTERFACE_MODE_RGMII_RXID:
    72			ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_DIS;
    73			fe = YT8511_DELAY_FE_TX_DIS;
    74			break;
    75		case PHY_INTERFACE_MODE_RGMII_TXID:
    76			ge = YT8511_DELAY_GE_TX_EN;
    77			fe = YT8511_DELAY_FE_TX_EN;
    78			break;
    79		case PHY_INTERFACE_MODE_RGMII_ID:
    80			ge = YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN;
    81			fe = YT8511_DELAY_FE_TX_EN;
    82			break;
  > 83		default: /* leave everything alone in other modes */
    84			break;
    85		}
    86	
    87		ret = __phy_modify(phydev, YT8511_PAGE, (YT8511_DELAY_RX | YT8511_DELAY_GE_TX_EN), ge);
    88		if (ret < 0)
    89			goto err_restore_page;
    90	
    91		/* fast ethernet delay is in a separate page */
    92		ret = __phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_DELAY_DRIVE);
    93		if (ret < 0)
    94			goto err_restore_page;
    95	
    96		ret = __phy_modify(phydev, YT8511_PAGE, YT8511_DELAY_FE_TX_EN, fe);
    97		if (ret < 0)
    98			goto err_restore_page;
    99	
   100		/* leave pll enabled in sleep */
   101		ret = __phy_write(phydev, YT8511_PAGE_SELECT, YT8511_EXT_SLEEP_CTRL);
   102		if (ret < 0)
   103			goto err_restore_page;
   104	
   105		ret = __phy_modify(phydev, YT8511_PAGE, 0, YT8511_PLLON_SLP);
   106		if (ret < 0)
   107			goto err_restore_page;
   108	
   109	err_restore_page:
   110		return phy_restore_page(phydev, oldpage, ret);
   111	}
   112	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email-masked]