Skip to contentSkip to conversation

cxgb4: Remove redundant memset before memcpy

PATCH Applied Shyam Saini 3 participants 3 messages Jan 14, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cxgb4: Remove redundant memset before memcpy

The region set by the call to memset, immediately overwritten by the subsequent call to memcpy and thus makes the memset redundant.

Also remove the memset((&info, 0, sizeof(info)) on line 398 because info is memcpy()'ed to before being used in the loop and it isn't used outside of the loop.

---
 drivers/net/ethernet/chelsio/cxgb4/sched.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/sched.c +0 -5
index cbd68a8..c902635 100644
@@ -397,9 +397,6 @@ static struct sched_class *t4_sched_class_lookup(struct port_info *pi,
 		struct ch_sched_params info;
 		struct ch_sched_params tp;
 
-		memset(&info, 0, sizeof(info));
-		memset(&tp, 0, sizeof(tp));
-
 		memcpy(&tp, p, sizeof(tp));
 		/* Don't try to match class parameter */
 		tp.u.params.class = SCHED_CLS_NONE;
@@ -409,7 +406,6 @@ static struct sched_class *t4_sched_class_lookup(struct port_info *pi,
 			if (e->state == SCHED_STATE_UNUSED)
 				continue;
 
-			memset(&info, 0, sizeof(info));
 			memcpy(&info, &e->info, sizeof(info));
 			/* Don't try to match class parameter */
 			info.u.params.class = SCHED_CLS_NONE;
@@ -458,7 +454,6 @@ static struct sched_class *t4_sched_class_alloc(struct port_info *pi,
 		if (!e)
 			goto out;
 
-		memset(&np, 0, sizeof(np));
 		memcpy(&np, p, sizeof(np));
 		np.u.params.class = e->idx;
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Shyam Saini

The region set by the call to memset, immediately overwritten by the subsequent call to memcpy and thus makes the memset redundant.

Also remove the memset((&info, 0, sizeof(info)) on line 398 because info is memcpy()'ed to before being used in the loop and it isn't used outside of the loop.

maintainer Applied
#2 lore raw
In reply to Shyam Saini

From: Shyam Saini <[email protected]>
Date: Sat, 14 Jan 2017 06:47:40 +0530

Quoted 8 lines

The region set by the call to memset, immediately overwritten by the subsequent call to memcpy and thus makes the memset redundant.

Also remove the memset((&info, 0, sizeof(info)) on line 398 because info is memcpy()'ed to before being used in the loop and it isn't used outside of the loop.

Applied to net-next, thanks.