Patchwork [16/43] drivers/net/cxgb3: fix sparse warning: symbol shadows an earlier one

login
register
mail settings
Submitter Hannes Eder
Date Feb. 14, 2009, 9:16 p.m.
Message ID <20090214211557.23489.75670.stgit@vmbox.hanneseder.net>
Download mbox | patch
Permalink /patch/23162/
State Accepted
Delegated to: David Miller
Headers show

Comments

Hannes Eder - Feb. 14, 2009, 9:16 p.m.
Impact: Move variable declaration as close to usage as possible.

Fix this sparse warning:
  drivers/net/cxgb3/cxgb3_main.c:1586:21: warning: symbol 'cap' shadows an earlier one

Signed-off-by: Hannes Eder <hannes@hanneseder.net>
---
 drivers/net/cxgb3/cxgb3_main.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
walter harms - Feb. 15, 2009, 2:14 p.m.
Hannes Eder schrieb:
> Impact: Move variable declaration as close to usage as possible.
> 
> Fix this sparse warning:
>   drivers/net/cxgb3/cxgb3_main.c:1586:21: warning: symbol 'cap' shadows an earlier one
> 
> Signed-off-by: Hannes Eder <hannes@hanneseder.net>
> ---
>  drivers/net/cxgb3/cxgb3_main.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
> index f2c7cc3..0f6062a 100644
> --- a/drivers/net/cxgb3/cxgb3_main.c
> +++ b/drivers/net/cxgb3/cxgb3_main.c
> @@ -1565,7 +1565,6 @@ static int speed_duplex_to_caps(int speed, int duplex)
>  
>  static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
>  {
> -	int cap;
>  	struct port_info *p = netdev_priv(dev);
>  	struct link_config *lc = &p->link_config;
>  
> @@ -1575,7 +1574,7 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
>  		 * being requested.
>  		 */
>  		if (cmd->autoneg == AUTONEG_DISABLE) {
> -			cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
> +			int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
>  			if (lc->supported & cap)
>  				return 0;
>  		}
> 

Hello Hannes,
it seems that "cap" can be dropped completely.

if (lc->supported & speed_duplex_to_caps(cmd->speed, cmd->duplex) )
	return 0;


re,
 wh
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hannes Eder - Feb. 15, 2009, 8:10 p.m.
On Sun, Feb 15, 2009 at 3:14 PM, walter harms <wharms@bfs.de> wrote:
> Hannes Eder schrieb:
>> Impact: Move variable declaration as close to usage as possible.
>>
>> Fix this sparse warning:
>>   drivers/net/cxgb3/cxgb3_main.c:1586:21: warning: symbol 'cap' shadows an earlier one
>>
>> Signed-off-by: Hannes Eder <hannes@hanneseder.net>
>> ---
>>  drivers/net/cxgb3/cxgb3_main.c |    3 +--
>>  1 files changed, 1 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
>> index f2c7cc3..0f6062a 100644
>> --- a/drivers/net/cxgb3/cxgb3_main.c
>> +++ b/drivers/net/cxgb3/cxgb3_main.c
>> @@ -1565,7 +1565,6 @@ static int speed_duplex_to_caps(int speed, int duplex)
>>
>>  static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
>>  {
>> -     int cap;
>>       struct port_info *p = netdev_priv(dev);
>>       struct link_config *lc = &p->link_config;
>>
>> @@ -1575,7 +1574,7 @@ static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
>>                * being requested.
>>                */
>>               if (cmd->autoneg == AUTONEG_DISABLE) {
>> -                     cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
>> +                     int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
>>                       if (lc->supported & cap)
>>                               return 0;
>>               }
>>
>
> Hello Hannes,
> it seems that "cap" can be dropped completely.
>
> if (lc->supported & speed_duplex_to_caps(cmd->speed, cmd->duplex) )
>        return 0;

Hi Walter,

You are right, but we would hit the 80 characters per line limit,
90 in this case, and a similar construct is used a few lines
below so I suggest to leave it this way.

-Hannes
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Divy Le Ray - Feb. 15, 2009, 9:30 p.m.
Hannes Eder wrote:
> Impact: Move variable declaration as close to usage as possible.
>
> Fix this sparse warning:
>   drivers/net/cxgb3/cxgb3_main.c:1586:21: warning: symbol 'cap' shadows an earlier one
>
> Signed-off-by: Hannes Eder <hannes@hanneseder.net>
>   
Acked-by: Divy Le Ray <divy@chelsio.com>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Feb. 18, 2009, 1:27 a.m.
From: Divy Le Ray <divy@chelsio.com>
Date: Sun, 15 Feb 2009 13:30:34 -0800

> Hannes Eder wrote:
> > Impact: Move variable declaration as close to usage as possible.
> >
> > Fix this sparse warning:
> >   drivers/net/cxgb3/cxgb3_main.c:1586:21: warning: symbol 'cap' shadows an earlier one
> >
> > Signed-off-by: Hannes Eder <hannes@hanneseder.net>
> >   
> Acked-by: Divy Le Ray <divy@chelsio.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c
index f2c7cc3..0f6062a 100644
--- a/drivers/net/cxgb3/cxgb3_main.c
+++ b/drivers/net/cxgb3/cxgb3_main.c
@@ -1565,7 +1565,6 @@  static int speed_duplex_to_caps(int speed, int duplex)
 
 static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	int cap;
 	struct port_info *p = netdev_priv(dev);
 	struct link_config *lc = &p->link_config;
 
@@ -1575,7 +1574,7 @@  static int set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 		 * being requested.
 		 */
 		if (cmd->autoneg == AUTONEG_DISABLE) {
-			cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
+			int cap = speed_duplex_to_caps(cmd->speed, cmd->duplex);
 			if (lc->supported & cap)
 				return 0;
 		}