All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: macb: Fix build warning
@ 2013-12-11  4:57 Soren Brinkmann
  2013-12-11  8:07 ` Nicolas Ferre
  0 siblings, 1 reply; 2+ messages in thread
From: Soren Brinkmann @ 2013-12-11  4:57 UTC (permalink / raw)
  To: Nicolas Ferre, David Miller
  Cc: linux-kernel, netdev, Sören Brinkmann, kbuild test robot

When adjusting the link speed, the target frequency is determined by a
'swith (LINK_SPEED)' statement, that assigns the target rate only for
valid and expected LINK_SPEED values. This incomplete switch statement
leads to the following build warning:
     drivers/net/ethernet/cadence/macb.c: In function 'macb_handle_link_change':
  >> drivers/net/ethernet/cadence/macb.c:241:14: warning: 'rate' may be used uninitialized in this function [-Wmaybe-uninitialized]
        netdev_warn(dev, "unable to generate target frequency: %ld Hz\n",
                   ^
     drivers/net/ethernet/cadence/macb.c:215:13: note: 'rate' was declared here
       long ferr, rate, rate_rounded;

Fixing this by bailing out of that function in the switch's default case
before the rate variable is used.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
---
 drivers/net/ethernet/cadence/macb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
index 419529a9309d..3190d38e16fb 100644
--- a/drivers/net/ethernet/cadence/macb.c
+++ b/drivers/net/ethernet/cadence/macb.c
@@ -225,7 +225,7 @@ static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
 		rate = 125000000;
 		break;
 	default:
-		break;
+		return;
 	}
 
 	rate_rounded = clk_round_rate(clk, rate);
-- 
1.8.5.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: macb: Fix build warning
  2013-12-11  4:57 [PATCH] net: macb: Fix build warning Soren Brinkmann
@ 2013-12-11  8:07 ` Nicolas Ferre
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Ferre @ 2013-12-11  8:07 UTC (permalink / raw)
  To: Soren Brinkmann, David Miller; +Cc: linux-kernel, netdev, kbuild test robot

On 11/12/2013 05:57, Soren Brinkmann :
> When adjusting the link speed, the target frequency is determined by a
> 'swith (LINK_SPEED)' statement, that assigns the target rate only for
> valid and expected LINK_SPEED values. This incomplete switch statement
> leads to the following build warning:
>       drivers/net/ethernet/cadence/macb.c: In function 'macb_handle_link_change':
>    >> drivers/net/ethernet/cadence/macb.c:241:14: warning: 'rate' may be used uninitialized in this function [-Wmaybe-uninitialized]
>          netdev_warn(dev, "unable to generate target frequency: %ld Hz\n",
>                     ^
>       drivers/net/ethernet/cadence/macb.c:215:13: note: 'rate' was declared here
>         long ferr, rate, rate_rounded;
>
> Fixing this by bailing out of that function in the switch's default case
> before the rate variable is used.
>
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Soren Brinkmann <soren.brinkmann@xilinx.com>

Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>

> ---
>   drivers/net/ethernet/cadence/macb.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb.c b/drivers/net/ethernet/cadence/macb.c
> index 419529a9309d..3190d38e16fb 100644
> --- a/drivers/net/ethernet/cadence/macb.c
> +++ b/drivers/net/ethernet/cadence/macb.c
> @@ -225,7 +225,7 @@ static void macb_set_tx_clk(struct clk *clk, int speed, struct net_device *dev)
>   		rate = 125000000;
>   		break;
>   	default:
> -		break;
> +		return;
>   	}
>
>   	rate_rounded = clk_round_rate(clk, rate);
>


-- 
Nicolas Ferre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-11  8:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11  4:57 [PATCH] net: macb: Fix build warning Soren Brinkmann
2013-12-11  8:07 ` Nicolas Ferre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.