Subject: Re: [PATCH net-next v2 5/6] net: txgbe: Implement phylink pcs

From: Simon Horman <[email-masked]>
Date: Tue, 11 Apr 2023 13:03:27 +0200

On Tue, Apr 11, 2023 at 05:27:24PM +0800, Jiawen Wu wrote:
> Register MDIO bus for PCS layer, support 10GBASE-R and 1000BASE-X
> interfaces to the controller.

...

> diff --git a/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c b/drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c

...

> +static int txgbe_pcs_config(struct phylink_pcs *pcs, unsigned int mode,
> +			    phy_interface_t interface,
> +			    const unsigned long *advertising,
> +			    bool permit_pause_to_mac)
> +{
> +	struct txgbe *txgbe = container_of(pcs, struct txgbe, pcs);
> +	struct wx *wx = txgbe->wx;
> +	int ret, val;
> +
> +	if (interface == txgbe->interface)
> +		goto out;

Hi Jiawen,

The out label returns 'ret', but it is not initialised here.

Reported by clang-16 as:

drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:270:6: error: variable 'ret' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]
        if (interface == txgbe->interface)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:326:9: note: uninitialized use occurs here
        return ret;
               ^~~
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:270:2: note: remove the 'if' if its condition is always false
        if (interface == txgbe->interface)
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/wangxun/txgbe/txgbe_phy.c:268:9: note: initialize the variable 'ret' to silence this warning
        int ret, val;
               ^
                = 0
1 error generated.

...