Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1558814 > unrolled thread

[PATCH] cxgb4: Remove redundant memset before memcpy

Started byShyam Saini <mayhs11saini@gmail.com>
First post2017-01-14 02:20 +0100
Last post2017-01-14 18:10 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] cxgb4:  Remove redundant memset before memcpy Shyam Saini <mayhs11saini@gmail.com> - 2017-01-14 02:20 +0100
    Re: [PATCH] cxgb4:  Remove redundant memset before memcpy Tobias Klauser <tklauser@distanz.ch> - 2017-01-14 13:30 +0100
    Re: [PATCH] cxgb4: Remove redundant memset before memcpy David Miller <davem@davemloft.net> - 2017-01-14 18:10 +0100

#1558814 — [PATCH] cxgb4: Remove redundant memset before memcpy

FromShyam Saini <mayhs11saini@gmail.com>
Date2017-01-14 02:20 +0100
Subject[PATCH] cxgb4: Remove redundant memset before memcpy
Message-ID<sZlaG-86Y-3@gated-at.bofh.it>
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.

Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>
---
 drivers/net/ethernet/chelsio/cxgb4/sched.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c b/drivers/net/ethernet/chelsio/cxgb4/sched.c
index cbd68a8..c902635 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
@@ -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;
 
-- 
2.7.4

[toc] | [next] | [standalone]


#1558956

FromTobias Klauser <tklauser@distanz.ch>
Date2017-01-14 13:30 +0100
Message-ID<sZvD3-5TG-1@gated-at.bofh.it>
In reply to#1558814
On 2017-01-14 at 02:17:40 +0100, Shyam Saini <mayhs11saini@gmail.com> wrote:
> 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.
> 
> Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>

Reviewed-by: Tobias Klauser <tklauser@distanz.ch>

[toc] | [prev] | [next] | [standalone]


#1559031 — Re: [PATCH] cxgb4: Remove redundant memset before memcpy

FromDavid Miller <davem@davemloft.net>
Date2017-01-14 18:10 +0100
SubjectRe: [PATCH] cxgb4: Remove redundant memset before memcpy
Message-ID<sZA02-8F-23@gated-at.bofh.it>
In reply to#1558814
From: Shyam Saini <mayhs11saini@gmail.com>
Date: Sat, 14 Jan 2017 06:47:40 +0530

> 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.
> 
> Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>

Applied to net-next, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web