Commit c5b2ce24 authored by Markus Elfring's avatar Markus Elfring Committed by David S. Miller

net: mvpp2: Improve 27 size determinations

Replace the specification of data structures by references to
a local variable as the parameter for the operator "sizeof"
to make the corresponding size determination a bit safer.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 37df25e8
...@@ -1689,7 +1689,7 @@ static void mvpp2_prs_mac_drop_all_set(struct mvpp2 *priv, int port, bool add) ...@@ -1689,7 +1689,7 @@ static void mvpp2_prs_mac_drop_all_set(struct mvpp2 *priv, int port, bool add)
mvpp2_prs_hw_read(priv, &pe); mvpp2_prs_hw_read(priv, &pe);
} else { } else {
/* Entry doesn't exist - create new */ /* Entry doesn't exist - create new */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC);
pe.index = MVPP2_PE_DROP_ALL; pe.index = MVPP2_PE_DROP_ALL;
...@@ -1726,7 +1726,7 @@ static void mvpp2_prs_mac_promisc_set(struct mvpp2 *priv, int port, bool add) ...@@ -1726,7 +1726,7 @@ static void mvpp2_prs_mac_promisc_set(struct mvpp2 *priv, int port, bool add)
mvpp2_prs_hw_read(priv, &pe); mvpp2_prs_hw_read(priv, &pe);
} else { } else {
/* Entry doesn't exist - create new */ /* Entry doesn't exist - create new */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC);
pe.index = MVPP2_PE_MAC_PROMISCUOUS; pe.index = MVPP2_PE_MAC_PROMISCUOUS;
...@@ -1772,7 +1772,7 @@ static void mvpp2_prs_mac_multi_set(struct mvpp2 *priv, int port, int index, ...@@ -1772,7 +1772,7 @@ static void mvpp2_prs_mac_multi_set(struct mvpp2 *priv, int port, int index,
mvpp2_prs_hw_read(priv, &pe); mvpp2_prs_hw_read(priv, &pe);
} else { } else {
/* Entry doesn't exist - create new */ /* Entry doesn't exist - create new */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MAC);
pe.index = index; pe.index = index;
...@@ -1824,7 +1824,7 @@ static void mvpp2_prs_dsa_tag_set(struct mvpp2 *priv, int port, bool add, ...@@ -1824,7 +1824,7 @@ static void mvpp2_prs_dsa_tag_set(struct mvpp2 *priv, int port, bool add,
mvpp2_prs_hw_read(priv, &pe); mvpp2_prs_hw_read(priv, &pe);
} else { } else {
/* Entry doesn't exist - create new */ /* Entry doesn't exist - create new */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA);
pe.index = tid; pe.index = tid;
...@@ -1887,7 +1887,7 @@ static void mvpp2_prs_dsa_tag_ethertype_set(struct mvpp2 *priv, int port, ...@@ -1887,7 +1887,7 @@ static void mvpp2_prs_dsa_tag_ethertype_set(struct mvpp2 *priv, int port,
mvpp2_prs_hw_read(priv, &pe); mvpp2_prs_hw_read(priv, &pe);
} else { } else {
/* Entry doesn't exist - create new */ /* Entry doesn't exist - create new */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA);
pe.index = tid; pe.index = tid;
...@@ -2212,7 +2212,7 @@ static int mvpp2_prs_ip4_proto(struct mvpp2 *priv, unsigned short proto, ...@@ -2212,7 +2212,7 @@ static int mvpp2_prs_ip4_proto(struct mvpp2 *priv, unsigned short proto,
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
pe.index = tid; pe.index = tid;
...@@ -2270,7 +2270,7 @@ static int mvpp2_prs_ip4_cast(struct mvpp2 *priv, unsigned short l3_cast) ...@@ -2270,7 +2270,7 @@ static int mvpp2_prs_ip4_cast(struct mvpp2 *priv, unsigned short l3_cast)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
pe.index = tid; pe.index = tid;
...@@ -2326,7 +2326,7 @@ static int mvpp2_prs_ip6_proto(struct mvpp2 *priv, unsigned short proto, ...@@ -2326,7 +2326,7 @@ static int mvpp2_prs_ip6_proto(struct mvpp2 *priv, unsigned short proto,
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
pe.index = tid; pe.index = tid;
...@@ -2365,7 +2365,7 @@ static int mvpp2_prs_ip6_cast(struct mvpp2 *priv, unsigned short l3_cast) ...@@ -2365,7 +2365,7 @@ static int mvpp2_prs_ip6_cast(struct mvpp2 *priv, unsigned short l3_cast)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
pe.index = tid; pe.index = tid;
...@@ -2425,7 +2425,7 @@ static void mvpp2_prs_def_flow_init(struct mvpp2 *priv) ...@@ -2425,7 +2425,7 @@ static void mvpp2_prs_def_flow_init(struct mvpp2 *priv)
int port; int port;
for (port = 0; port < MVPP2_MAX_PORTS; port++) { for (port = 0; port < MVPP2_MAX_PORTS; port++) {
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_FLOWS); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_FLOWS);
pe.index = MVPP2_PE_FIRST_DEFAULT_FLOW - port; pe.index = MVPP2_PE_FIRST_DEFAULT_FLOW - port;
...@@ -2447,7 +2447,7 @@ static void mvpp2_prs_mh_init(struct mvpp2 *priv) ...@@ -2447,7 +2447,7 @@ static void mvpp2_prs_mh_init(struct mvpp2 *priv)
{ {
struct mvpp2_prs_entry pe; struct mvpp2_prs_entry pe;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
pe.index = MVPP2_PE_MH_DEFAULT; pe.index = MVPP2_PE_MH_DEFAULT;
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MH); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_MH);
...@@ -2470,7 +2470,7 @@ static void mvpp2_prs_mac_init(struct mvpp2 *priv) ...@@ -2470,7 +2470,7 @@ static void mvpp2_prs_mac_init(struct mvpp2 *priv)
{ {
struct mvpp2_prs_entry pe; struct mvpp2_prs_entry pe;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
/* Non-promiscuous mode for all ports - DROP unknown packets */ /* Non-promiscuous mode for all ports - DROP unknown packets */
pe.index = MVPP2_PE_MAC_NON_PROMISCUOUS; pe.index = MVPP2_PE_MAC_NON_PROMISCUOUS;
...@@ -2531,7 +2531,7 @@ static void mvpp2_prs_dsa_init(struct mvpp2 *priv) ...@@ -2531,7 +2531,7 @@ static void mvpp2_prs_dsa_init(struct mvpp2 *priv)
MVPP2_PRS_TAGGED, MVPP2_PRS_DSA); MVPP2_PRS_TAGGED, MVPP2_PRS_DSA);
/* Set default entry, in case DSA or EDSA tag not found */ /* Set default entry, in case DSA or EDSA tag not found */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_DSA);
pe.index = MVPP2_PE_DSA_DEFAULT; pe.index = MVPP2_PE_DSA_DEFAULT;
mvpp2_prs_sram_next_lu_set(&pe, MVPP2_PRS_LU_VLAN); mvpp2_prs_sram_next_lu_set(&pe, MVPP2_PRS_LU_VLAN);
...@@ -2561,7 +2561,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv) ...@@ -2561,7 +2561,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
pe.index = tid; pe.index = tid;
...@@ -2587,7 +2587,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv) ...@@ -2587,7 +2587,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
pe.index = tid; pe.index = tid;
...@@ -2617,7 +2617,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv) ...@@ -2617,7 +2617,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
pe.index = tid; pe.index = tid;
...@@ -2651,7 +2651,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv) ...@@ -2651,7 +2651,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
pe.index = tid; pe.index = tid;
...@@ -2716,7 +2716,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv) ...@@ -2716,7 +2716,7 @@ static int mvpp2_prs_etype_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_L2);
pe.index = tid; pe.index = tid;
...@@ -2813,7 +2813,7 @@ static int mvpp2_prs_vlan_init(struct platform_device *pdev, struct mvpp2 *priv) ...@@ -2813,7 +2813,7 @@ static int mvpp2_prs_vlan_init(struct platform_device *pdev, struct mvpp2 *priv)
return err; return err;
/* Set default double vlan entry */ /* Set default double vlan entry */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_VLAN); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_VLAN);
pe.index = MVPP2_PE_VLAN_DBL; pe.index = MVPP2_PE_VLAN_DBL;
...@@ -2833,7 +2833,7 @@ static int mvpp2_prs_vlan_init(struct platform_device *pdev, struct mvpp2 *priv) ...@@ -2833,7 +2833,7 @@ static int mvpp2_prs_vlan_init(struct platform_device *pdev, struct mvpp2 *priv)
mvpp2_prs_hw_write(priv, &pe); mvpp2_prs_hw_write(priv, &pe);
/* Set default vlan none entry */ /* Set default vlan none entry */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_VLAN); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_VLAN);
pe.index = MVPP2_PE_VLAN_NONE; pe.index = MVPP2_PE_VLAN_NONE;
...@@ -2863,7 +2863,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv) ...@@ -2863,7 +2863,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE);
pe.index = tid; pe.index = tid;
...@@ -2913,7 +2913,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv) ...@@ -2913,7 +2913,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE);
pe.index = tid; pe.index = tid;
...@@ -2940,7 +2940,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv) ...@@ -2940,7 +2940,7 @@ static int mvpp2_prs_pppoe_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_PPPOE);
pe.index = tid; pe.index = tid;
...@@ -2998,7 +2998,7 @@ static int mvpp2_prs_ip4_init(struct mvpp2 *priv) ...@@ -2998,7 +2998,7 @@ static int mvpp2_prs_ip4_init(struct mvpp2 *priv)
return err; return err;
/* Default IPv4 entry for unknown protocols */ /* Default IPv4 entry for unknown protocols */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
pe.index = MVPP2_PE_IP4_PROTO_UN; pe.index = MVPP2_PE_IP4_PROTO_UN;
...@@ -3023,7 +3023,7 @@ static int mvpp2_prs_ip4_init(struct mvpp2 *priv) ...@@ -3023,7 +3023,7 @@ static int mvpp2_prs_ip4_init(struct mvpp2 *priv)
mvpp2_prs_hw_write(priv, &pe); mvpp2_prs_hw_write(priv, &pe);
/* Default IPv4 entry for unicast address */ /* Default IPv4 entry for unicast address */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP4);
pe.index = MVPP2_PE_IP4_ADDR_UN; pe.index = MVPP2_PE_IP4_ADDR_UN;
...@@ -3091,7 +3091,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv) ...@@ -3091,7 +3091,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv)
if (tid < 0) if (tid < 0)
return tid; return tid;
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
pe.index = tid; pe.index = tid;
...@@ -3112,7 +3112,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv) ...@@ -3112,7 +3112,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv)
mvpp2_prs_hw_write(priv, &pe); mvpp2_prs_hw_write(priv, &pe);
/* Default IPv6 entry for unknown protocols */ /* Default IPv6 entry for unknown protocols */
memset(&pe, 0, sizeof(struct mvpp2_prs_entry)); memset(&pe, 0, sizeof(pe));
mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6); mvpp2_prs_tcam_lu_set(&pe, MVPP2_PRS_LU_IP6);
pe.index = MVPP2_PE_IP6_PROTO_UN; pe.index = MVPP2_PE_IP6_PROTO_UN;
......
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