diff mbox

[5/14] drivers/net/sb1000.c: delete double assignment

Message ID 1288088743-3725-6-git-send-email-julia@diku.dk
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Julia Lawall Oct. 26, 2010, 10:25 a.m. UTC
From: Julia Lawall <julia@diku.dk>

The other code around these duplicated assignments initializes the 0 1 2
and 3 elements of an array, so change the initialization of the
rx_session_id array to do the same.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@@
expression i;
@@

*i = ...;
 i = ...;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
This changes the semantics and has not been tested.

 drivers/net/sb1000.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Walter Harms Oct. 26, 2010, 11:58 a.m. UTC | #1
Julia Lawall schrieb:
> From: Julia Lawall <julia@diku.dk>
> 
> The other code around these duplicated assignments initializes the 0 1 2
> and 3 elements of an array, so change the initialization of the
> rx_session_id array to do the same.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression i;
> @@
> 
> *i = ...;
>  i = ...;
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 
> ---
> This changes the semantics and has not been tested.
> 
>  drivers/net/sb1000.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
> index a9ae505..66c2f1a 100644
> --- a/drivers/net/sb1000.c
> +++ b/drivers/net/sb1000.c
> @@ -961,9 +961,9 @@ sb1000_open(struct net_device *dev)
>  	lp->rx_error_count = 0;
>  	lp->rx_error_dpc_count = 0;
>  	lp->rx_session_id[0] = 0x50;
> -	lp->rx_session_id[0] = 0x48;
> -	lp->rx_session_id[0] = 0x44;
> -	lp->rx_session_id[0] = 0x42;
> +	lp->rx_session_id[1] = 0x48;
> +	lp->rx_session_id[2] = 0x44;
> +	lp->rx_session_id[3] = 0x42;
>  	lp->rx_frame_id[0] = 0;
>  	lp->rx_frame_id[1] = 0;
>  	lp->rx_frame_id[2] = 0;
> 

/me is surprised that this did not cause more problems.
Is it needed at all ?

re,
 wh

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Julia Lawall Oct. 26, 2010, 12:25 p.m. UTC | #2
On Tue, 26 Oct 2010, walter harms wrote:

> 
> 
> Julia Lawall schrieb:
> > From: Julia Lawall <julia@diku.dk>
> > 
> > The other code around these duplicated assignments initializes the 0 1 2
> > and 3 elements of an array, so change the initialization of the
> > rx_session_id array to do the same.
> > 
> > A simplified version of the semantic match that finds this problem is as
> > follows: (http://coccinelle.lip6.fr/)
> > 
> > // <smpl>
> > @@
> > expression i;
> > @@
> > 
> > *i = ...;
> >  i = ...;
> > // </smpl>
> > 
> > Signed-off-by: Julia Lawall <julia@diku.dk>
> > 
> > ---
> > This changes the semantics and has not been tested.
> > 
> >  drivers/net/sb1000.c |    6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
> > index a9ae505..66c2f1a 100644
> > --- a/drivers/net/sb1000.c
> > +++ b/drivers/net/sb1000.c
> > @@ -961,9 +961,9 @@ sb1000_open(struct net_device *dev)
> >  	lp->rx_error_count = 0;
> >  	lp->rx_error_dpc_count = 0;
> >  	lp->rx_session_id[0] = 0x50;
> > -	lp->rx_session_id[0] = 0x48;
> > -	lp->rx_session_id[0] = 0x44;
> > -	lp->rx_session_id[0] = 0x42;
> > +	lp->rx_session_id[1] = 0x48;
> > +	lp->rx_session_id[2] = 0x44;
> > +	lp->rx_session_id[3] = 0x42;
> >  	lp->rx_frame_id[0] = 0;
> >  	lp->rx_frame_id[1] = 0;
> >  	lp->rx_frame_id[2] = 0;
> > 
> 
> /me is surprised that this did not cause more problems.
> Is it needed at all ?

The field appears to be useful.  However, there is an ioctl that also 
initializes the elements of this field with these values and that is 
implemented correctly.  Perhaps that was sufficient to hide the problem in 
practice.

julia
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller Oct. 27, 2010, 7:23 p.m. UTC | #3
From: Julia Lawall <julia@diku.dk>
Date: Tue, 26 Oct 2010 12:25:34 +0200

> From: Julia Lawall <julia@diku.dk>
> 
> The other code around these duplicated assignments initializes the 0 1 2
> and 3 elements of an array, so change the initialization of the
> rx_session_id array to do the same.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://coccinelle.lip6.fr/)
 ...
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c
index a9ae505..66c2f1a 100644
--- a/drivers/net/sb1000.c
+++ b/drivers/net/sb1000.c
@@ -961,9 +961,9 @@  sb1000_open(struct net_device *dev)
 	lp->rx_error_count = 0;
 	lp->rx_error_dpc_count = 0;
 	lp->rx_session_id[0] = 0x50;
-	lp->rx_session_id[0] = 0x48;
-	lp->rx_session_id[0] = 0x44;
-	lp->rx_session_id[0] = 0x42;
+	lp->rx_session_id[1] = 0x48;
+	lp->rx_session_id[2] = 0x44;
+	lp->rx_session_id[3] = 0x42;
 	lp->rx_frame_id[0] = 0;
 	lp->rx_frame_id[1] = 0;
 	lp->rx_frame_id[2] = 0;