All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: netfilter: Remove multiple assignment.
@ 2017-03-25 12:49 Arushi Singhal
  2017-03-27 12:08 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 6+ messages in thread
From: Arushi Singhal @ 2017-03-25 12:49 UTC (permalink / raw)
  To: pablo
  Cc: Jozsef Kadlecsik, David S. Miller, netfilter-devel, coreteam,
	netdev, linux-kernel, outreachy-kernel

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



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

* Re: [PATCH] net: netfilter: Remove multiple assignment.
  2017-03-25 12:49 [PATCH] net: netfilter: Remove multiple assignment Arushi Singhal
@ 2017-03-27 12:08 ` Pablo Neira Ayuso
  2017-03-27 12:18   ` Arushi Singhal
  2017-03-27 15:09     ` David Laight
  0 siblings, 2 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2017-03-27 12:08 UTC (permalink / raw)
  To: Arushi Singhal
  Cc: Jozsef Kadlecsik, David S. Miller, netfilter-devel, coreteam,
	netdev, linux-kernel, outreachy-kernel

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.


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

* Re: [PATCH] net: netfilter: Remove multiple assignment.
  2017-03-27 12:08 ` Pablo Neira Ayuso
@ 2017-03-27 12:18   ` Arushi Singhal
  2017-03-27 12:21     ` [Outreachy kernel] " Pablo Neira Ayuso
  2017-03-27 15:09     ` David Laight
  1 sibling, 1 reply; 6+ messages in thread
From: Arushi Singhal @ 2017-03-27 12:18 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, David S. Miller, netfilter-devel, coreteam,
	netdev, LKML, outreachy-kernel

[-- Attachment #1: Type: text/plain, Size: 529 bytes --]

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.

Thanks
Arushi

[-- Attachment #2: Type: text/html, Size: 999 bytes --]

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

* Re: [Outreachy kernel] Re: [PATCH] net: netfilter: Remove multiple assignment.
  2017-03-27 12:18   ` Arushi Singhal
@ 2017-03-27 12:21     ` Pablo Neira Ayuso
  0 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2017-03-27 12:21 UTC (permalink / raw)
  To: Arushi Singhal
  Cc: Jozsef Kadlecsik, David S. Miller, netfilter-devel, coreteam,
	netdev, LKML, outreachy-kernel

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!


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

* RE: [PATCH] net: netfilter: Remove multiple assignment.
  2017-03-27 12:08 ` Pablo Neira Ayuso
@ 2017-03-27 15:09     ` David Laight
  2017-03-27 15:09     ` David Laight
  1 sibling, 0 replies; 6+ messages in thread
From: David Laight @ 2017-03-27 15:09 UTC (permalink / raw)
  To: 'Pablo Neira Ayuso', Arushi Singhal
  Cc: Jozsef Kadlecsik, David S. Miller, netfilter-devel, coreteam,
	netdev, linux-kernel, outreachy-kernel

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



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

* RE: [PATCH] net: netfilter: Remove multiple assignment.
@ 2017-03-27 15:09     ` David Laight
  0 siblings, 0 replies; 6+ messages in thread
From: David Laight @ 2017-03-27 15:09 UTC (permalink / raw)
  To: 'Pablo Neira Ayuso', Arushi Singhal
  Cc: Jozsef Kadlecsik, David S. Miller, netfilter-devel, coreteam,
	netdev, linux-kernel, outreachy-kernel

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



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

end of thread, other threads:[~2017-03-28 15:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-25 12:49 [PATCH] net: netfilter: Remove multiple assignment Arushi Singhal
2017-03-27 12:08 ` Pablo Neira Ayuso
2017-03-27 12:18   ` Arushi Singhal
2017-03-27 12:21     ` [Outreachy kernel] " Pablo Neira Ayuso
2017-03-27 15:09   ` David Laight
2017-03-27 15:09     ` David Laight

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.