linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Use FIELD_SIZEOF directly instead of reimplementing its function
@ 2018-09-19 10:26 zhong jiang
  2018-09-19 10:26 ` [PATCH 1/5] net: iucv: " zhong jiang
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: zhong jiang @ 2018-09-19 10:26 UTC (permalink / raw)
  To: davem; +Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel

The issue is detected with the help of Coccinelle.

zhong jiang (5):
  net: iucv: Use FIELD_SIZEOF directly instead of reimplementing its
    function
  net: sched: Use FIELD_SIZEOF directly instead of reimplementing its
    function
  net: core: Use FIELD_SIZEOF directly instead of reimplementing its
    function
  net: qede: Use FIELD_SIZEOF directly instead of reimplementing its
    function
  net: ti: Use FIELD_SIZEOF directly instead of reimplementing its
    function

 drivers/net/ethernet/qlogic/qede/qede.h |  2 +-
 drivers/net/ethernet/ti/cpsw.c          |  6 +++---
 net/core/flow_dissector.c               | 10 +++++-----
 net/iucv/af_iucv.c                      |  2 +-
 net/sched/cls_flower.c                  |  2 +-
 5 files changed, 11 insertions(+), 11 deletions(-)

-- 
1.7.12.4


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

* [PATCH 1/5] net: iucv: Use FIELD_SIZEOF directly instead of reimplementing its function
  2018-09-19 10:26 [PATCH 0/5] Use FIELD_SIZEOF directly instead of reimplementing its function zhong jiang
@ 2018-09-19 10:26 ` zhong jiang
  2018-09-19 11:21   ` Christian Borntraeger
  2018-09-19 10:26 ` [PATCH 2/5] net: sched: " zhong jiang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 8+ messages in thread
From: zhong jiang @ 2018-09-19 10:26 UTC (permalink / raw)
  To: davem; +Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel

FIELD_SIZEOF is defined as a macro to calculate the specified value. Therefore,
We prefer to use the macro rather than calculating its value.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 net/iucv/af_iucv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index e2f16a0..5b68ee9 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -48,7 +48,7 @@
 static const u8 iprm_shutdown[8] =
 	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
 
-#define TRGCLS_SIZE	(sizeof(((struct iucv_message *)0)->class))
+#define TRGCLS_SIZE	FIELD_SIZEOF(struct iucv_message, class)
 
 #define __iucv_sock_wait(sk, condition, timeo, ret)			\
 do {									\
-- 
1.7.12.4


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

* [PATCH 2/5] net: sched: Use FIELD_SIZEOF directly instead of reimplementing its function
  2018-09-19 10:26 [PATCH 0/5] Use FIELD_SIZEOF directly instead of reimplementing its function zhong jiang
  2018-09-19 10:26 ` [PATCH 1/5] net: iucv: " zhong jiang
@ 2018-09-19 10:26 ` zhong jiang
  2018-09-19 10:26 ` [PATCH 3/5] net: core: " zhong jiang
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: zhong jiang @ 2018-09-19 10:26 UTC (permalink / raw)
  To: davem; +Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel

FIELD_SIZEOF is defined as a macro to calculate the specified value. Therefore,
We prefer to use the macro rather than calculating its value.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 net/sched/cls_flower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 4b8dd37..9aada2d 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -993,7 +993,7 @@ static int fl_init_mask_hashtable(struct fl_flow_mask *mask)
 }
 
 #define FL_KEY_MEMBER_OFFSET(member) offsetof(struct fl_flow_key, member)
-#define FL_KEY_MEMBER_SIZE(member) (sizeof(((struct fl_flow_key *) 0)->member))
+#define FL_KEY_MEMBER_SIZE(member) FIELD_SIZEOF(struct fl_flow_key, member)
 
 #define FL_KEY_IS_MASKED(mask, member)						\
 	memchr_inv(((char *)mask) + FL_KEY_MEMBER_OFFSET(member),		\
-- 
1.7.12.4


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

* [PATCH 3/5] net: core: Use FIELD_SIZEOF directly instead of reimplementing its function
  2018-09-19 10:26 [PATCH 0/5] Use FIELD_SIZEOF directly instead of reimplementing its function zhong jiang
  2018-09-19 10:26 ` [PATCH 1/5] net: iucv: " zhong jiang
  2018-09-19 10:26 ` [PATCH 2/5] net: sched: " zhong jiang
@ 2018-09-19 10:26 ` zhong jiang
  2018-09-19 10:26 ` [PATCH 4/5] net: qede: " zhong jiang
  2018-09-19 10:26 ` [PATCH 5/5] net: ti: " zhong jiang
  4 siblings, 0 replies; 8+ messages in thread
From: zhong jiang @ 2018-09-19 10:26 UTC (permalink / raw)
  To: davem; +Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel

FIELD_SIZEOF is defined as a macro to calculate the specified value. Therefore,
We prefer to use the macro rather than calculating its value.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 net/core/flow_dissector.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 5c5dd74..aeac884 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -423,8 +423,8 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
 	offset += sizeof(struct gre_base_hdr);
 
 	if (hdr->flags & GRE_CSUM)
-		offset += sizeof(((struct gre_full_hdr *) 0)->csum) +
-			  sizeof(((struct gre_full_hdr *) 0)->reserved1);
+		offset += FIELD_SIZEOF(struct gre_full_hdr, csum) +
+			  FIELD_SIZEOF(struct gre_full_hdr, reserved1);
 
 	if (hdr->flags & GRE_KEY) {
 		const __be32 *keyid;
@@ -446,11 +446,11 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
 			else
 				key_keyid->keyid = *keyid & GRE_PPTP_KEY_MASK;
 		}
-		offset += sizeof(((struct gre_full_hdr *) 0)->key);
+		offset += FIELD_SIZEOF(struct gre_full_hdr, key);
 	}
 
 	if (hdr->flags & GRE_SEQ)
-		offset += sizeof(((struct pptp_gre_header *) 0)->seq);
+		offset += FIELD_SIZEOF(struct pptp_gre_header, seq);
 
 	if (gre_ver == 0) {
 		if (*p_proto == htons(ETH_P_TEB)) {
@@ -477,7 +477,7 @@ __be32 __skb_flow_get_ports(const struct sk_buff *skb, int thoff, u8 ip_proto,
 		u8 *ppp_hdr;
 
 		if (hdr->flags & GRE_ACK)
-			offset += sizeof(((struct pptp_gre_header *) 0)->ack);
+			offset += FIELD_SIZEOF(struct pptp_gre_header, ack);
 
 		ppp_hdr = __skb_header_pointer(skb, *p_nhoff + offset,
 					       sizeof(_ppp_hdr),
-- 
1.7.12.4


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

* [PATCH 4/5] net: qede: Use FIELD_SIZEOF directly instead of reimplementing its function
  2018-09-19 10:26 [PATCH 0/5] Use FIELD_SIZEOF directly instead of reimplementing its function zhong jiang
                   ` (2 preceding siblings ...)
  2018-09-19 10:26 ` [PATCH 3/5] net: core: " zhong jiang
@ 2018-09-19 10:26 ` zhong jiang
  2018-09-19 10:26 ` [PATCH 5/5] net: ti: " zhong jiang
  4 siblings, 0 replies; 8+ messages in thread
From: zhong jiang @ 2018-09-19 10:26 UTC (permalink / raw)
  To: davem; +Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel

FIELD_SIZEOF is defined as a macro to calculate the specified value. Therefore,
We prefer to use the macro rather than calculating its value.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/net/ethernet/qlogic/qede/qede.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/qlogic/qede/qede.h b/drivers/net/ethernet/qlogic/qede/qede.h
index 6a4d266..c73839c 100644
--- a/drivers/net/ethernet/qlogic/qede/qede.h
+++ b/drivers/net/ethernet/qlogic/qede/qede.h
@@ -440,7 +440,7 @@ struct qede_fastpath {
 	struct qede_tx_queue	*txq;
 	struct qede_tx_queue	*xdp_tx;
 
-#define VEC_NAME_SIZE	(sizeof(((struct net_device *)0)->name) + 8)
+	#define VEC_NAME_SIZE  (FIELD_SIZEOF(struct net_device, name) + 8)
 	char	name[VEC_NAME_SIZE];
 };
 
-- 
1.7.12.4


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

* [PATCH 5/5] net: ti: Use FIELD_SIZEOF directly instead of reimplementing its function
  2018-09-19 10:26 [PATCH 0/5] Use FIELD_SIZEOF directly instead of reimplementing its function zhong jiang
                   ` (3 preceding siblings ...)
  2018-09-19 10:26 ` [PATCH 4/5] net: qede: " zhong jiang
@ 2018-09-19 10:26 ` zhong jiang
  4 siblings, 0 replies; 8+ messages in thread
From: zhong jiang @ 2018-09-19 10:26 UTC (permalink / raw)
  To: davem; +Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel

FIELD_SIZEOF is defined as a macro to calculate the specified value. Therefore,
We prefer to use the macro rather than calculating its value.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/net/ethernet/ti/cpsw.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 832bce0..16dcbf3 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -484,13 +484,13 @@ enum {
 };
 
 #define CPSW_STAT(m)		CPSW_STATS,				\
-				sizeof(((struct cpsw_hw_stats *)0)->m), \
+				FIELD_SIZEOF(struct cpsw_hw_stats, m), \
 				offsetof(struct cpsw_hw_stats, m)
 #define CPDMA_RX_STAT(m)	CPDMA_RX_STATS,				   \
-				sizeof(((struct cpdma_chan_stats *)0)->m), \
+				FIELD_SIZEOF(struct cpdma_chan_stats, m), \
 				offsetof(struct cpdma_chan_stats, m)
 #define CPDMA_TX_STAT(m)	CPDMA_TX_STATS,				   \
-				sizeof(((struct cpdma_chan_stats *)0)->m), \
+				FIELD_SIZEOF(struct cpdma_chan_stats, m), \
 				offsetof(struct cpdma_chan_stats, m)
 
 static const struct cpsw_stats cpsw_gstrings_stats[] = {
-- 
1.7.12.4


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

* Re: [PATCH 1/5] net: iucv: Use FIELD_SIZEOF directly instead of reimplementing its function
  2018-09-19 10:26 ` [PATCH 1/5] net: iucv: " zhong jiang
@ 2018-09-19 11:21   ` Christian Borntraeger
  2018-09-19 11:32     ` zhong jiang
  0 siblings, 1 reply; 8+ messages in thread
From: Christian Borntraeger @ 2018-09-19 11:21 UTC (permalink / raw)
  To: zhong jiang, davem
  Cc: jhs, xiyou.wangcong, jiri, netdev, linux-kernel, Ursula Braun,
	Julian Wiedmann

Can you please copy Ursula and Julian for iucv related patches?

On 09/19/2018 12:26 PM, zhong jiang wrote:
> FIELD_SIZEOF is defined as a macro to calculate the specified value. Therefore,
> We prefer to use the macro rather than calculating its value.
> 
> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
> ---
>  net/iucv/af_iucv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
> index e2f16a0..5b68ee9 100644
> --- a/net/iucv/af_iucv.c
> +++ b/net/iucv/af_iucv.c
> @@ -48,7 +48,7 @@
>  static const u8 iprm_shutdown[8] =
>  	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
>  
> -#define TRGCLS_SIZE	(sizeof(((struct iucv_message *)0)->class))
> +#define TRGCLS_SIZE	FIELD_SIZEOF(struct iucv_message, class)
>  
>  #define __iucv_sock_wait(sk, condition, timeo, ret)			\
>  do {									\
> 


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

* Re: [PATCH 1/5] net: iucv: Use FIELD_SIZEOF directly instead of reimplementing its function
  2018-09-19 11:21   ` Christian Borntraeger
@ 2018-09-19 11:32     ` zhong jiang
  0 siblings, 0 replies; 8+ messages in thread
From: zhong jiang @ 2018-09-19 11:32 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: davem, jhs, xiyou.wangcong, jiri, netdev, linux-kernel,
	Ursula Braun, Julian Wiedmann

On 2018/9/19 19:21, Christian Borntraeger wrote:
> Can you please copy Ursula and Julian for iucv related patches?
Thanks, Maybe I forget cc more maintainer. So I will resend in v2.

Sincerely,
zhong jiang
> On 09/19/2018 12:26 PM, zhong jiang wrote:
>> FIELD_SIZEOF is defined as a macro to calculate the specified value. Therefore,
>> We prefer to use the macro rather than calculating its value.
>>
>> Signed-off-by: zhong jiang <zhongjiang@huawei.com>
>> ---
>>  net/iucv/af_iucv.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
>> index e2f16a0..5b68ee9 100644
>> --- a/net/iucv/af_iucv.c
>> +++ b/net/iucv/af_iucv.c
>> @@ -48,7 +48,7 @@
>>  static const u8 iprm_shutdown[8] =
>>  	{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
>>  
>> -#define TRGCLS_SIZE	(sizeof(((struct iucv_message *)0)->class))
>> +#define TRGCLS_SIZE	FIELD_SIZEOF(struct iucv_message, class)
>>  
>>  #define __iucv_sock_wait(sk, condition, timeo, ret)			\
>>  do {									\
>>
>
>



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

end of thread, other threads:[~2018-09-19 11:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-19 10:26 [PATCH 0/5] Use FIELD_SIZEOF directly instead of reimplementing its function zhong jiang
2018-09-19 10:26 ` [PATCH 1/5] net: iucv: " zhong jiang
2018-09-19 11:21   ` Christian Borntraeger
2018-09-19 11:32     ` zhong jiang
2018-09-19 10:26 ` [PATCH 2/5] net: sched: " zhong jiang
2018-09-19 10:26 ` [PATCH 3/5] net: core: " zhong jiang
2018-09-19 10:26 ` [PATCH 4/5] net: qede: " zhong jiang
2018-09-19 10:26 ` [PATCH 5/5] net: ti: " zhong jiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).