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


Groups > linux.kernel > #1609152 > unrolled thread

[PATCH] net: netfilter: Remove multiple assignment.

Started byArushi Singhal <arushisinghal19971997@gmail.com>
First post2017-03-25 14:00 +0100
Last post2017-03-27 17:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: netfilter: Remove multiple assignment. Arushi Singhal <arushisinghal19971997@gmail.com> - 2017-03-25 14:00 +0100
    Re: [PATCH] net: netfilter: Remove multiple assignment. Pablo Neira Ayuso <pablo@netfilter.org> - 2017-03-27 14:10 +0200
      Re: [Outreachy kernel] Re: [PATCH] net: netfilter: Remove multiple  assignment. Pablo Neira Ayuso <pablo@netfilter.org> - 2017-03-27 14:30 +0200
      RE: [PATCH] net: netfilter: Remove multiple assignment. David Laight <David.Laight@ACULAB.COM> - 2017-03-27 17:20 +0200

#1609152 — [PATCH] net: netfilter: Remove multiple assignment.

FromArushi Singhal <arushisinghal19971997@gmail.com>
Date2017-03-25 14:00 +0100
Subject[PATCH] net: netfilter: Remove multiple assignment.
Message-ID<toTst-WD-3@gated-at.bofh.it>
This patch removes multiple assignments.
Done using coccinelle.
@@
identifier i1,i2;
constant c;
@@
- i1=i2=c;
+ i1=c;
+ i2=c;

Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com>
---
contribution to outreachy netfilter project.

 net/netfilter/nf_conntrack_proto_sctp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index 33279aab583d..723386bcc2cb 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -346,7 +346,8 @@ static int sctp_packet(struct nf_conn *ct,
 		goto out;
 	}
 
-	old_state = new_state = SCTP_CONNTRACK_NONE;
+	old_state = SCTP_CONNTRACK_NONE;
+	new_state = old_state;
 	spin_lock_bh(&ct->lock);
 	for_each_sctp_chunk (skb, sch, _sch, offset, dataoff, count) {
 		/* Special cases of Verification tag check (Sec 8.5.1) */
-- 
2.11.0

[toc] | [next] | [standalone]


#1609763

FromPablo Neira Ayuso <pablo@netfilter.org>
Date2017-03-27 14:10 +0200
Message-ID<tpBDc-7On-15@gated-at.bofh.it>
In reply to#1609152
On Sat, Mar 25, 2017 at 06:19:47PM +0530, Arushi Singhal wrote:
> This patch removes multiple assignments.
> Done using coccinelle.
> @@
> identifier i1,i2;
> constant c;
> @@
> - i1=i2=c;
> + i1=c;
> + i2=c;

You have to explain why this is bad.

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


#1609772 — Re: [Outreachy kernel] Re: [PATCH] net: netfilter: Remove multiple assignment.

FromPablo Neira Ayuso <pablo@netfilter.org>
Date2017-03-27 14:30 +0200
SubjectRe: [Outreachy kernel] Re: [PATCH] net: netfilter: Remove multiple assignment.
Message-ID<tpBWy-80f-27@gated-at.bofh.it>
In reply to#1609763
On Mon, Mar 27, 2017 at 05:48:41PM +0530, Arushi Singhal wrote:
> On Mon, Mar 27, 2017 at 5:38 PM, Pablo Neira Ayuso <pablo@netfilter.org>
> wrote:
> 
> > On Sat, Mar 25, 2017 at 06:19:47PM +0530, Arushi Singhal wrote:
> > > This patch removes multiple assignments.
> > > Done using coccinelle.
> > > @@
> > > identifier i1,i2;
> > > constant c;
> > > @@
> > > - i1=i2=c;
> > > + i1=c;
> > > + i2=c;
> >
> > You have to explain why this is bad.
> >
> 
> It is against the kernel coding style and we have to avoid multiple
> assignments to make the code more readable.
> This error is found using Checkpatch.pl script.

Then, please place this information in your patch description.

Thanks!

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


#1609941

FromDavid Laight <David.Laight@ACULAB.COM>
Date2017-03-27 17:20 +0200
Message-ID<tpEB3-1AA-3@gated-at.bofh.it>
In reply to#1609763
From: Pablo Neira Ayuso
> Sent: 27 March 2017 13:08
> On Sat, Mar 25, 2017 at 06:19:47PM +0530, Arushi Singhal wrote:
> > This patch removes multiple assignments.
> > Done using coccinelle.
> > @@
> > identifier i1,i2;
> > constant c;
> > @@
> > - i1=i2=c;
> > + i1=c;
> > + i2=c;
> 
> You have to explain why this is bad.

And your substituted code isn't equivalent.
The correct replacement is:
	i2 = c;
	i1 = i2;

	David

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web