diff mbox

[net-next,04/10] igb: Fix for sparse warning in igb_get_i2c_client

Message ID 1360319958-10497-5-git-send-email-jeffrey.t.kirsher@intel.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Kirsher, Jeffrey T Feb. 8, 2013, 10:39 a.m. UTC
From: Carolyn Wyborny <carolyn.wyborny@intel.com>

This patch changes definition of i2c_client in igb_get_i2c_client to static
to prevent sparse warning.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ben Hutchings Feb. 11, 2013, 5:05 p.m. UTC | #1
On Fri, 2013-02-08 at 02:39 -0800, Jeff Kirsher wrote:
> From: Carolyn Wyborny <carolyn.wyborny@intel.com>
> 
> This patch changes definition of i2c_client in igb_get_i2c_client to static
> to prevent sparse warning.

So, in order to fix the warning:

drivers/net/ethernet/intel/igb/igb_main.c:7611:19: warning: symbol 'igb_get_i2c_client' was not declared. Should it be static?

you don't touch the function declaration, but instead make a local
variable static.  This doesn't fix the warning, but does introduce a
race condition...

Ben.

> Reported-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com>
> Tested-by: Aaron Brown <aaron.f.brown@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index c19a35c..ebf8384 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -7732,7 +7732,7 @@ igb_get_i2c_client(struct igb_adapter *adapter, u8 dev_addr)
>  {
>  	ulong flags;
>  	struct igb_i2c_client_list *client_list;
> -	struct i2c_client *client = NULL;
> +	static struct i2c_client *client;
>  	struct i2c_board_info client_info = {
>  		I2C_BOARD_INFO("igb", 0x00),
>  	};
Wyborny, Carolyn Feb. 11, 2013, 5:27 p.m. UTC | #2
> -----Original Message-----

> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]

> On Behalf Of Ben Hutchings

> Sent: Monday, February 11, 2013 9:06 AM

> To: Kirsher, Jeffrey T; Wyborny, Carolyn

> Cc: davem@davemloft.net; netdev@vger.kernel.org; gospo@redhat.com;

> sassmann@redhat.com

> Subject: Re: [net-next 04/10] igb: Fix for sparse warning in igb_get_i2c_client

> 

> On Fri, 2013-02-08 at 02:39 -0800, Jeff Kirsher wrote:

> > From: Carolyn Wyborny <carolyn.wyborny@intel.com>

> >

> > This patch changes definition of i2c_client in igb_get_i2c_client to

> > static to prevent sparse warning.

> 

> So, in order to fix the warning:

> 

> drivers/net/ethernet/intel/igb/igb_main.c:7611:19: warning: symbol

> 'igb_get_i2c_client' was not declared. Should it be static?

> 

> you don't touch the function declaration, but instead make a local variable

> static.  This doesn't fix the warning, but does introduce a race condition...

> 

> Ben.

> 

> > Reported-by: Fengguang Wu <fengguang.wu@intel.com>

> > Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com>

> > Tested-by: Aaron Brown <aaron.f.brown@intel.com>

> > Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

> > ---

> >  drivers/net/ethernet/intel/igb/igb_main.c | 2 +-

> >  1 file changed, 1 insertion(+), 1 deletion(-)

> >

> > diff --git a/drivers/net/ethernet/intel/igb/igb_main.c

> > b/drivers/net/ethernet/intel/igb/igb_main.c

> > index c19a35c..ebf8384 100644

> > --- a/drivers/net/ethernet/intel/igb/igb_main.c

> > +++ b/drivers/net/ethernet/intel/igb/igb_main.c

> > @@ -7732,7 +7732,7 @@ igb_get_i2c_client(struct igb_adapter *adapter,

> > u8 dev_addr)  {

> >  	ulong flags;

> >  	struct igb_i2c_client_list *client_list;

> > -	struct i2c_client *client = NULL;

> > +	static struct i2c_client *client;

> >  	struct i2c_board_info client_info = {

> >  		I2C_BOARD_INFO("igb", 0x00),

> >  	};

> 

> --

> Ben Hutchings, Staff Engineer, Solarflare Not speaking for my employer; that's

> the marketing department's job.

> They asked us to note that Solarflare product names are trademarked.

> 

> --

> 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


Yes, my mistake in taking a quick suggestion without enough evaluation.  I'm in the process of completely redoing this to not allocate clients on the fly which will fully fix this problem and the initial one.

Thanks,

Carolyn
Wyborny, Carolyn Feb. 12, 2013, 5:12 p.m. UTC | #3
> -----Original Message-----

> From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org]

> On Behalf Of Ben Hutchings

> Sent: Monday, February 11, 2013 9:06 AM

> To: Kirsher, Jeffrey T; Wyborny, Carolyn

> Cc: davem@davemloft.net; netdev@vger.kernel.org; gospo@redhat.com;

> sassmann@redhat.com

> Subject: Re: [net-next 04/10] igb: Fix for sparse warning in igb_get_i2c_client

> 

> On Fri, 2013-02-08 at 02:39 -0800, Jeff Kirsher wrote:

> > From: Carolyn Wyborny <carolyn.wyborny@intel.com>

> >

> > This patch changes definition of i2c_client in igb_get_i2c_client to

> > static to prevent sparse warning.

> 

> So, in order to fix the warning:

> 

> drivers/net/ethernet/intel/igb/igb_main.c:7611:19: warning: symbol

> 'igb_get_i2c_client' was not declared. Should it be static?

[..]

And this was not the warning I was trying to fix with the static change.  The sparse warning was "cast to 
restricted __le64."  Not sure why you are seeing that particular warning, but I will look for it in my next patch on this function.

Thanks,

Carolyn

Carolyn Wyborny 
Linux Development 
Networking Division 
Intel Corporation
diff mbox

Patch

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index c19a35c..ebf8384 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -7732,7 +7732,7 @@  igb_get_i2c_client(struct igb_adapter *adapter, u8 dev_addr)
 {
 	ulong flags;
 	struct igb_i2c_client_list *client_list;
-	struct i2c_client *client = NULL;
+	static struct i2c_client *client;
 	struct i2c_board_info client_info = {
 		I2C_BOARD_INFO("igb", 0x00),
 	};