Skip to contentSkip to conversation

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

PATCH In review Roel Kluin 2 participants 2 messages Jan 20, 2010

Subsystems (2)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

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

EFX_ETHTOOL_STAT calculated the offset of the efx##source_name's field Regardless of whether that field was NULL.

---
This looks like a bug, but I am not sure whether I understood this correctly, nor was it tested, was this intended?

drivers/net/sfc/ethtool.c +1 -1
index 6c0bbed..722bac7 100644
@@ -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,					\
 }
#1 lore raw
Quoted 7 lines · Roel Kluin

EFX_ETHTOOL_STAT calculated the offset of the efx##source_name's field Regardless of whether that field was NULL.

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

Quoted 13 lines
drivers/net/sfc/ethtool.c +1 -1
index 6c0bbed..722bac7 100644
@@ -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,					\
 }
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.