2010-01-16 15:58:46

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 4/9] net/sctp: Eliminate useless code

From: Julia Lawall <[email protected]>

The variable newinet is initialized twice to the same (side effect-free)
expression. Drop one initialization.

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

// <smpl>
@forall@
idexpression *x;
identifier f!=ERR_PTR;
@@

x = f(...)
... when != x
(
x = f(...,<+...x...+>,...)
|
* x = f(...)
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
net/sctp/socket.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 67fdac9..f6d1e59 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6359,7 +6359,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
struct sctp_association *asoc)
{
struct inet_sock *inet = inet_sk(sk);
- struct inet_sock *newinet = inet_sk(newsk);
+ struct inet_sock *newinet;

newsk->sk_type = sk->sk_type;
newsk->sk_bound_dev_if = sk->sk_bound_dev_if;


2010-01-20 18:10:21

by Vlad Yasevich

[permalink] [raw]
Subject: Re: [PATCH 4/9] net/sctp: Eliminate useless code



Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> The variable newinet is initialized twice to the same (side effect-free)
> expression. Drop one initialization.
>
> A simplified version of the semantic match that finds this problem is:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @forall@
> idexpression *x;
> identifier f!=ERR_PTR;
> @@
>
> x = f(...)
> ... when != x
> (
> x = f(...,<+...x...+>,...)
> |
> * x = f(...)
> )
> // </smpl>
>
> Signed-off-by: Julia Lawall <[email protected]>

Acked-by: Vlad Yasevich <[email protected]>


>
> ---
> net/sctp/socket.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 67fdac9..f6d1e59 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -6359,7 +6359,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
> struct sctp_association *asoc)
> {
> struct inet_sock *inet = inet_sk(sk);
> - struct inet_sock *newinet = inet_sk(newsk);
> + struct inet_sock *newinet;
>
> newsk->sk_type = sk->sk_type;
> newsk->sk_bound_dev_if = sk->sk_bound_dev_if;
>

2010-01-20 23:03:35

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 4/9] net/sctp: Eliminate useless code

From: Vlad Yasevich <[email protected]>
Date: Wed, 20 Jan 2010 13:10:10 -0500

>
>
> Julia Lawall wrote:
>> From: Julia Lawall <[email protected]>
>>
>> The variable newinet is initialized twice to the same (side effect-free)
>> expression. Drop one initialization.
>>
>> A simplified version of the semantic match that finds this problem is:
>> (http://coccinelle.lip6.fr/)
>>
>> // <smpl>
>> @forall@
>> idexpression *x;
>> identifier f!=ERR_PTR;
>> @@
>>
>> x = f(...)
>> ... when != x
>> (
>> x = f(...,<+...x...+>,...)
>> |
>> * x = f(...)
>> )
>> // </smpl>
>>
>> Signed-off-by: Julia Lawall <[email protected]>
>
> Acked-by: Vlad Yasevich <[email protected]>

Julia, just like patch #3 this one had the missing final
line of the patch corrupting it, so you'll need to resubmit.

2010-01-21 10:21:53

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 4/9] net/sctp: Eliminate useless code

From: Julia Lawall <[email protected]>

The variable newinet is initialized twice to the same (side effect-free)
expression. Drop one initialization.

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

// <smpl>
@forall@
idexpression *x;
identifier f!=ERR_PTR;
@@

x = f(...)
... when != x
(
x = f(...,<+...x...+>,...)
|
* x = f(...)
)
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>

---
net/sctp/socket.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 67fdac9..f6d1e59 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -6359,7 +6359,7 @@ void sctp_copy_sock(struct sock *newsk, struct sock *sk,
struct sctp_association *asoc)
{
struct inet_sock *inet = inet_sk(sk);
- struct inet_sock *newinet = inet_sk(newsk);
+ struct inet_sock *newinet;

newsk->sk_type = sk->sk_type;
newsk->sk_bound_dev_if = sk->sk_bound_dev_if;

2010-01-21 10:22:43

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 4/9] net/sctp: Eliminate useless code

On Wed, 20 Jan 2010, David Miller wrote:

> From: Vlad Yasevich <[email protected]>
> Date: Wed, 20 Jan 2010 13:10:10 -0500
>
> >
> >
> > Julia Lawall wrote:
> >> From: Julia Lawall <[email protected]>
> >>
> >> The variable newinet is initialized twice to the same (side effect-free)
> >> expression. Drop one initialization.
> >>
> >> A simplified version of the semantic match that finds this problem is:
> >> (http://coccinelle.lip6.fr/)
> >>
> >> // <smpl>
> >> @forall@
> >> idexpression *x;
> >> identifier f!=ERR_PTR;
> >> @@
> >>
> >> x = f(...)
> >> ... when != x
> >> (
> >> x = f(...,<+...x...+>,...)
> >> |
> >> * x = f(...)
> >> )
> >> // </smpl>
> >>
> >> Signed-off-by: Julia Lawall <[email protected]>
> >
> > Acked-by: Vlad Yasevich <[email protected]>
>
> Julia, just like patch #3 this one had the missing final
> line of the patch corrupting it, so you'll need to resubmit.

I have generated and sent it again, but this time I don't see the problem.
If there is still a problem, perhaps you could send me back the patch you
received?

thanks,
julia

2010-01-21 10:43:32

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 4/9] net/sctp: Eliminate useless code

From: Julia Lawall <[email protected]>
Date: Thu, 21 Jan 2010 11:22:38 +0100 (CET)

> On Wed, 20 Jan 2010, David Miller wrote:
>
>> From: Vlad Yasevich <[email protected]>
>> Date: Wed, 20 Jan 2010 13:10:10 -0500
>>
>> >
>> >
>> > Julia Lawall wrote:
>> >> From: Julia Lawall <[email protected]>
>> >>
>> >> The variable newinet is initialized twice to the same (side effect-free)
>> >> expression. Drop one initialization.
>> >>
>> >> A simplified version of the semantic match that finds this problem is:
>> >> (http://coccinelle.lip6.fr/)
>> >>
>> >> // <smpl>
>> >> @forall@
>> >> idexpression *x;
>> >> identifier f!=ERR_PTR;
>> >> @@
>> >>
>> >> x = f(...)
>> >> ... when != x
>> >> (
>> >> x = f(...,<+...x...+>,...)
>> >> |
>> >> * x = f(...)
>> >> )
>> >> // </smpl>
>> >>
>> >> Signed-off-by: Julia Lawall <[email protected]>
>> >
>> > Acked-by: Vlad Yasevich <[email protected]>
>>
>> Julia, just like patch #3 this one had the missing final
>> line of the patch corrupting it, so you'll need to resubmit.
>
> I have generated and sent it again, but this time I don't see the problem.
> If there is still a problem, perhaps you could send me back the patch you
> received?

You dropped Vlad' ACK in your re-submission.

I'll fix it up this time, but please accumulate ACK's when
resubmitting patches merely for the purpose of fixing some
technical submission problem.

Thanks.

2010-01-21 10:49:15

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 4/9] net/sctp: Eliminate useless code

On Thu, 21 Jan 2010, David Miller wrote:

> From: Julia Lawall <[email protected]>
> Date: Thu, 21 Jan 2010 11:22:38 +0100 (CET)
>
> > On Wed, 20 Jan 2010, David Miller wrote:
> >
> >> From: Vlad Yasevich <[email protected]>
> >> Date: Wed, 20 Jan 2010 13:10:10 -0500
> >>
> >> >
> >> >
> >> > Julia Lawall wrote:
> >> >> From: Julia Lawall <[email protected]>
> >> >>
> >> >> The variable newinet is initialized twice to the same (side effect-free)
> >> >> expression. Drop one initialization.
> >> >>
> >> >> A simplified version of the semantic match that finds this problem is:
> >> >> (http://coccinelle.lip6.fr/)
> >> >>
> >> >> // <smpl>
> >> >> @forall@
> >> >> idexpression *x;
> >> >> identifier f!=ERR_PTR;
> >> >> @@
> >> >>
> >> >> x = f(...)
> >> >> ... when != x
> >> >> (
> >> >> x = f(...,<+...x...+>,...)
> >> >> |
> >> >> * x = f(...)
> >> >> )
> >> >> // </smpl>
> >> >>
> >> >> Signed-off-by: Julia Lawall <[email protected]>
> >> >
> >> > Acked-by: Vlad Yasevich <[email protected]>
> >>
> >> Julia, just like patch #3 this one had the missing final
> >> line of the patch corrupting it, so you'll need to resubmit.
> >
> > I have generated and sent it again, but this time I don't see the problem.
> > If there is still a problem, perhaps you could send me back the patch you
> > received?
>
> You dropped Vlad' ACK in your re-submission.
>
> I'll fix it up this time, but please accumulate ACK's when
> resubmitting patches merely for the purpose of fixing some
> technical submission problem.
>
> Thanks.

OK, I will keep that in mind.

Is the new one better than the old one? Because in my local copies, they
are the same...

julia

2010-01-21 13:08:13

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 4/9] net/sctp: Eliminate useless code

From: Julia Lawall <[email protected]>
Date: Thu, 21 Jan 2010 11:49:10 +0100 (CET)

> Is the new one better than the old one? Because in my local copies, they
> are the same...

The new one worked and I applied it.