summaryrefslogtreecommitdiffstats
path: root/net/ncsi
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-06-16 14:29:19 +0200
committerDavid S. Miller <davem@davemloft.net>2017-06-16 11:48:35 -0400
commitb080db585384b9f037e015c0c28d1ad33be41dfc (patch)
treeea9cc5c3161d776b948283a3d4f483cbf578e043 /net/ncsi
parent61f73d1ea4c68544b959228ead7ef5c021791b14 (diff)
downloadlinux-b080db585384b9f037e015c0c28d1ad33be41dfc.tar.bz2
networking: convert many more places to skb_put_zero()
There were many places that my previous spatch didn't find, as pointed out by yuan linyu in various patches. The following spatch found many more and also removes the now unnecessary casts: @@ identifier p, p2; expression len; expression skb; type t, t2; @@ ( -p = skb_put(skb, len); +p = skb_put_zero(skb, len); | -p = (t)skb_put(skb, len); +p = skb_put_zero(skb, len); ) ... when != p ( p2 = (t2)p; -memset(p2, 0, len); | -memset(p, 0, len); ) @@ type t, t2; identifier p, p2; expression skb; @@ t *p; ... ( -p = skb_put(skb, sizeof(t)); +p = skb_put_zero(skb, sizeof(t)); | -p = (t *)skb_put(skb, sizeof(t)); +p = skb_put_zero(skb, sizeof(t)); ) ... when != p ( p2 = (t2)p; -memset(p2, 0, sizeof(*p)); | -memset(p, 0, sizeof(*p)); ) @@ expression skb, len; @@ -memset(skb_put(skb, len), 0, len); +skb_put_zero(skb, len); Apply it to the tree (with one manual fixup to keep the comment in vxlan.c, which spatch removed.) Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ncsi')
-rw-r--r--net/ncsi/ncsi-cmd.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/net/ncsi/ncsi-cmd.c b/net/ncsi/ncsi-cmd.c
index db7083bfd476..b010ae94175b 100644
--- a/net/ncsi/ncsi-cmd.c
+++ b/net/ncsi/ncsi-cmd.c
@@ -66,8 +66,7 @@ static int ncsi_cmd_handler_default(struct sk_buff *skb,
{
struct ncsi_cmd_pkt *cmd;
- cmd = (struct ncsi_cmd_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
ncsi_cmd_build_header(&cmd->cmd.common, nca);
return 0;
@@ -78,8 +77,7 @@ static int ncsi_cmd_handler_sp(struct sk_buff *skb,
{
struct ncsi_cmd_sp_pkt *cmd;
- cmd = (struct ncsi_cmd_sp_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->hw_arbitration = nca->bytes[0];
ncsi_cmd_build_header(&cmd->cmd.common, nca);
@@ -91,8 +89,7 @@ static int ncsi_cmd_handler_dc(struct sk_buff *skb,
{
struct ncsi_cmd_dc_pkt *cmd;
- cmd = (struct ncsi_cmd_dc_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->ald = nca->bytes[0];
ncsi_cmd_build_header(&cmd->cmd.common, nca);
@@ -104,8 +101,7 @@ static int ncsi_cmd_handler_rc(struct sk_buff *skb,
{
struct ncsi_cmd_rc_pkt *cmd;
- cmd = (struct ncsi_cmd_rc_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
ncsi_cmd_build_header(&cmd->cmd.common, nca);
return 0;
@@ -116,8 +112,7 @@ static int ncsi_cmd_handler_ae(struct sk_buff *skb,
{
struct ncsi_cmd_ae_pkt *cmd;
- cmd = (struct ncsi_cmd_ae_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->mc_id = nca->bytes[0];
cmd->mode = htonl(nca->dwords[1]);
ncsi_cmd_build_header(&cmd->cmd.common, nca);
@@ -130,8 +125,7 @@ static int ncsi_cmd_handler_sl(struct sk_buff *skb,
{
struct ncsi_cmd_sl_pkt *cmd;
- cmd = (struct ncsi_cmd_sl_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->mode = htonl(nca->dwords[0]);
cmd->oem_mode = htonl(nca->dwords[1]);
ncsi_cmd_build_header(&cmd->cmd.common, nca);
@@ -144,8 +138,7 @@ static int ncsi_cmd_handler_svf(struct sk_buff *skb,
{
struct ncsi_cmd_svf_pkt *cmd;
- cmd = (struct ncsi_cmd_svf_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->vlan = htons(nca->words[0]);
cmd->index = nca->bytes[2];
cmd->enable = nca->bytes[3];
@@ -159,8 +152,7 @@ static int ncsi_cmd_handler_ev(struct sk_buff *skb,
{
struct ncsi_cmd_ev_pkt *cmd;
- cmd = (struct ncsi_cmd_ev_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->mode = nca->bytes[0];
ncsi_cmd_build_header(&cmd->cmd.common, nca);
@@ -173,8 +165,7 @@ static int ncsi_cmd_handler_sma(struct sk_buff *skb,
struct ncsi_cmd_sma_pkt *cmd;
int i;
- cmd = (struct ncsi_cmd_sma_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
for (i = 0; i < 6; i++)
cmd->mac[i] = nca->bytes[i];
cmd->index = nca->bytes[6];
@@ -189,8 +180,7 @@ static int ncsi_cmd_handler_ebf(struct sk_buff *skb,
{
struct ncsi_cmd_ebf_pkt *cmd;
- cmd = (struct ncsi_cmd_ebf_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->mode = htonl(nca->dwords[0]);
ncsi_cmd_build_header(&cmd->cmd.common, nca);
@@ -202,8 +192,7 @@ static int ncsi_cmd_handler_egmf(struct sk_buff *skb,
{
struct ncsi_cmd_egmf_pkt *cmd;
- cmd = (struct ncsi_cmd_egmf_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->mode = htonl(nca->dwords[0]);
ncsi_cmd_build_header(&cmd->cmd.common, nca);
@@ -215,8 +204,7 @@ static int ncsi_cmd_handler_snfc(struct sk_buff *skb,
{
struct ncsi_cmd_snfc_pkt *cmd;
- cmd = (struct ncsi_cmd_snfc_pkt *)skb_put(skb, sizeof(*cmd));
- memset(cmd, 0, sizeof(*cmd));
+ cmd = skb_put_zero(skb, sizeof(*cmd));
cmd->mode = nca->bytes[0];
ncsi_cmd_build_header(&cmd->cmd.common, nca);