diff mbox

sfc: EFX_ETHTOOL_STAT calculates the offset of the efx##source_name's field in both cases

Message ID 4B56659E.3040001@gmail.com
State Awaiting Upstream, archived
Delegated to: David Miller
Headers show

Commit Message

roel kluin Jan. 20, 2010, 2:08 a.m. UTC
EFX_ETHTOOL_STAT calculated the offset of the efx##source_name's field
Regardless of whether that field was NULL.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
This looks like a bug, but I am not sure whether I understood this correctly,
nor was it tested, was this intended?

--
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

Comments

Ben Hutchings Jan. 20, 2010, 3:12 a.m. UTC | #1
On Wed, 2010-01-20 at 03:08 +0100, Roel Kluin wrote:
> EFX_ETHTOOL_STAT calculated the offset of the efx##source_name's field
> Regardless of whether that field was NULL.
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> This looks like a bug, but I am not sure whether I understood this correctly,
> nor was it tested, was this intended?

The condition is really a type check.  The result should be the same
regardless of whether it is true.

Ben.

> diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
> index 6c0bbed..722bac7 100644
> --- a/drivers/net/sfc/ethtool.c
> +++ b/drivers/net/sfc/ethtool.c
> @@ -41,7 +41,7 @@ struct efx_ethtool_stat {
>  	.source = EFX_ETHTOOL_STAT_SOURCE_##source_name,		\
>  	.offset = ((((field_type *) 0) ==				\
>  		      &((struct efx_##source_name *)0)->field) ?	\
> -		    offsetof(struct efx_##source_name, field) :		\
> +		    offsetof(struct efx_##stat_name, field) :		\
>  		    offsetof(struct efx_##source_name, field)),		\
>  	.get_stat = get_stat_function,					\
>  }
diff mbox

Patch

diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c
index 6c0bbed..722bac7 100644
--- a/drivers/net/sfc/ethtool.c
+++ b/drivers/net/sfc/ethtool.c
@@ -41,7 +41,7 @@  struct efx_ethtool_stat {
 	.source = EFX_ETHTOOL_STAT_SOURCE_##source_name,		\
 	.offset = ((((field_type *) 0) ==				\
 		      &((struct efx_##source_name *)0)->field) ?	\
-		    offsetof(struct efx_##source_name, field) :		\
+		    offsetof(struct efx_##stat_name, field) :		\
 		    offsetof(struct efx_##source_name, field)),		\
 	.get_stat = get_stat_function,					\
 }