Commit 822143ac authored by David S. Miller's avatar David S. Miller

Merge branch 'net-Use-FIELD_SIZEOF-directly-instead-of-reimplementing-its-function'

zhong jiang says:

====================
net: Use FIELD_SIZEOF directly instead of reimplementing its function

The issue is detected with the help of Coccinelle.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 18522108 a90546e8
...@@ -440,7 +440,7 @@ struct qede_fastpath { ...@@ -440,7 +440,7 @@ struct qede_fastpath {
struct qede_tx_queue *txq; struct qede_tx_queue *txq;
struct qede_tx_queue *xdp_tx; 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]; char name[VEC_NAME_SIZE];
}; };
......
...@@ -484,13 +484,13 @@ enum { ...@@ -484,13 +484,13 @@ enum {
}; };
#define CPSW_STAT(m) CPSW_STATS, \ #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) offsetof(struct cpsw_hw_stats, m)
#define CPDMA_RX_STAT(m) CPDMA_RX_STATS, \ #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) offsetof(struct cpdma_chan_stats, m)
#define CPDMA_TX_STAT(m) CPDMA_TX_STATS, \ #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) offsetof(struct cpdma_chan_stats, m)
static const struct cpsw_stats cpsw_gstrings_stats[] = { static const struct cpsw_stats cpsw_gstrings_stats[] = {
......
...@@ -382,8 +382,8 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, ...@@ -382,8 +382,8 @@ __skb_flow_dissect_gre(const struct sk_buff *skb,
offset += sizeof(struct gre_base_hdr); offset += sizeof(struct gre_base_hdr);
if (hdr->flags & GRE_CSUM) if (hdr->flags & GRE_CSUM)
offset += sizeof(((struct gre_full_hdr *) 0)->csum) + offset += FIELD_SIZEOF(struct gre_full_hdr, csum) +
sizeof(((struct gre_full_hdr *) 0)->reserved1); FIELD_SIZEOF(struct gre_full_hdr, reserved1);
if (hdr->flags & GRE_KEY) { if (hdr->flags & GRE_KEY) {
const __be32 *keyid; const __be32 *keyid;
...@@ -405,11 +405,11 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, ...@@ -405,11 +405,11 @@ __skb_flow_dissect_gre(const struct sk_buff *skb,
else else
key_keyid->keyid = *keyid & GRE_PPTP_KEY_MASK; 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) 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 (gre_ver == 0) {
if (*p_proto == htons(ETH_P_TEB)) { if (*p_proto == htons(ETH_P_TEB)) {
...@@ -436,7 +436,7 @@ __skb_flow_dissect_gre(const struct sk_buff *skb, ...@@ -436,7 +436,7 @@ __skb_flow_dissect_gre(const struct sk_buff *skb,
u8 *ppp_hdr; u8 *ppp_hdr;
if (hdr->flags & GRE_ACK) 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, ppp_hdr = __skb_header_pointer(skb, *p_nhoff + offset,
sizeof(_ppp_hdr), sizeof(_ppp_hdr),
......
...@@ -48,7 +48,7 @@ static struct iucv_interface *pr_iucv; ...@@ -48,7 +48,7 @@ static struct iucv_interface *pr_iucv;
static const u8 iprm_shutdown[8] = static const u8 iprm_shutdown[8] =
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; {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) \ #define __iucv_sock_wait(sk, condition, timeo, ret) \
do { \ do { \
......
...@@ -993,7 +993,7 @@ static int fl_init_mask_hashtable(struct fl_flow_mask *mask) ...@@ -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_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) \ #define FL_KEY_IS_MASKED(mask, member) \
memchr_inv(((char *)mask) + FL_KEY_MEMBER_OFFSET(member), \ memchr_inv(((char *)mask) + FL_KEY_MEMBER_OFFSET(member), \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment