linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxgb4: Remove redundant memset before memcpy
@ 2017-01-13  9:52 Shyam Saini
  2017-01-13 15:57 ` Tobias Klauser
  0 siblings, 1 reply; 6+ messages in thread
From: Shyam Saini @ 2017-01-13  9:52 UTC (permalink / raw)
  To: hariprasad; +Cc: netdev, linux-kernel, Shyam Saini

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

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

diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c b/drivers/net/ethernet/chelsio/cxgb4/sched.c
index cbd68a8..5725693 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
@@ -398,7 +398,6 @@ static struct sched_class *t4_sched_class_lookup(struct port_info *pi,
 		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 */
@@ -409,7 +408,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 +456,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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxgb4: Remove redundant memset before memcpy
  2017-01-13  9:52 [PATCH] cxgb4: Remove redundant memset before memcpy Shyam Saini
@ 2017-01-13 15:57 ` Tobias Klauser
  2017-01-14  0:55   ` Shyam Saini
  0 siblings, 1 reply; 6+ messages in thread
From: Tobias Klauser @ 2017-01-13 15:57 UTC (permalink / raw)
  To: Shyam Saini; +Cc: hariprasad, netdev, linux-kernel

On 2017-01-13 at 10:52:49 +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
> 
> Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>
> ---
>  drivers/net/ethernet/chelsio/cxgb4/sched.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c b/drivers/net/ethernet/chelsio/cxgb4/sched.c
> index cbd68a8..5725693 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
> @@ -398,7 +398,6 @@ static struct sched_class *t4_sched_class_lookup(struct port_info *pi,
>  		struct ch_sched_params tp;
>  
>  		memset(&info, 0, sizeof(info));

This memset is also redundant because info is memcpy()'ed to before
being used in the loop (and it isn't used outside of the loop).

> -		memset(&tp, 0, sizeof(tp));
>  
>  		memcpy(&tp, p, sizeof(tp));
>  		/* Don't try to match class parameter */
> @@ -409,7 +408,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 +456,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
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxgb4: Remove redundant memset before memcpy
  2017-01-13 15:57 ` Tobias Klauser
@ 2017-01-14  0:55   ` Shyam Saini
  0 siblings, 0 replies; 6+ messages in thread
From: Shyam Saini @ 2017-01-14  0:55 UTC (permalink / raw)
  To: Tobias Klauser; +Cc: hariprasad, linux-kernel

On Fri, Jan 13, 2017 at 04:57:14PM +0100, Tobias Klauser wrote:
> On 2017-01-13 at 10:52:49 +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
> > 
> > Signed-off-by: Shyam Saini <mayhs11saini@gmail.com>
> > ---
> >  drivers/net/ethernet/chelsio/cxgb4/sched.c | 3 ---
> >  1 file changed, 3 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/chelsio/cxgb4/sched.c b/drivers/net/ethernet/chelsio/cxgb4/sched.c
> > index cbd68a8..5725693 100644
> > --- a/drivers/net/ethernet/chelsio/cxgb4/sched.c
> > +++ b/drivers/net/ethernet/chelsio/cxgb4/sched.c
> > @@ -398,7 +398,6 @@ static struct sched_class *t4_sched_class_lookup(struct port_info *pi,
> >  		struct ch_sched_params tp;
> >  
> >  		memset(&info, 0, sizeof(info));
> 
> This memset is also redundant because info is memcpy()'ed to before
> being used in the loop (and it isn't used outside of the loop).
Thanks a lot for pointing out that.

I'll remove that too and resend it.

Regards,
Shyam

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxgb4: Remove redundant memset before memcpy
  2017-01-14  1:17 Shyam Saini
  2017-01-14 12:27 ` Tobias Klauser
@ 2017-01-14 17:00 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2017-01-14 17:00 UTC (permalink / raw)
  To: mayhs11saini; +Cc: hariprasad, tklauser, netdev, linux-kernel

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cxgb4:  Remove redundant memset before memcpy
  2017-01-14  1:17 Shyam Saini
@ 2017-01-14 12:27 ` Tobias Klauser
  2017-01-14 17:00 ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: Tobias Klauser @ 2017-01-14 12:27 UTC (permalink / raw)
  To: Shyam Saini; +Cc: hariprasad, netdev, linux-kernel

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>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] cxgb4:  Remove redundant memset before memcpy
@ 2017-01-14  1:17 Shyam Saini
  2017-01-14 12:27 ` Tobias Klauser
  2017-01-14 17:00 ` David Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Shyam Saini @ 2017-01-14  1:17 UTC (permalink / raw)
  To: hariprasad; +Cc: tklauser, netdev, linux-kernel, 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.

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-14 17:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-13  9:52 [PATCH] cxgb4: Remove redundant memset before memcpy Shyam Saini
2017-01-13 15:57 ` Tobias Klauser
2017-01-14  0:55   ` Shyam Saini
2017-01-14  1:17 Shyam Saini
2017-01-14 12:27 ` Tobias Klauser
2017-01-14 17:00 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).