Skip to contentSkip to conversation

net: netfilter: Remove multiple assignment.

PATCH Superseded Arushi Singhal 3 participants 5 messages Mar 25, 2017 – Mar 27, 2017

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: netfilter: Remove multiple assignment.

This patch removes multiple assignments.
Done using coccinelle.
@@
identifier i1,i2;
constant c;
@@
- i1=i2=c;
+ i1=c;
+ i2=c;

---
contribution to outreachy netfilter project.

 net/netfilter/nf_conntrack_proto_sctp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nf_conntrack_proto_sctp.c +2 -1
index 33279aab583d..723386bcc2cb 100644
@@ -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) */
Signature · 1 line
2.11.0
#1 lore raw
Quoted 9 lines · Arushi Singhal

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.

#2 lore raw
Quoted 11 lines · Pablo Neira Ayuso
Quoted 9 lines · Arushi Singhal

This patch removes multiple assignments.
Done using coccinelle.
@@
identifier i1,i2;
constant c;
@@
- i1=i2=c;
+ i1=c;
+ i2=c;

Quoted 2 lines

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

#3 lore raw
Quoted 14 lines · Arushi Singhal
Quoted 11 lines · Pablo Neira Ayuso
Quoted 9 lines · Arushi Singhal

This patch removes multiple assignments.
Done using coccinelle.
@@
identifier i1,i2;
constant c;
@@
- i1=i2=c;
+ i1=c;
+ i2=c;

Quoted 6 lines
Quoted 2 lines

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!

#4 lore raw
In reply to Pablo Neira Ayuso

From: Pablo Neira Ayuso

Quoted 12 lines

Sent: 27 March 2017 13:08

Quoted 9 lines · Arushi Singhal

This patch removes multiple assignments.
Done using coccinelle.
@@
identifier i1,i2;
constant c;
@@
- i1=i2=c;
+ i1=c;
+ i2=c;

Quoted 1 line

You have to explain why this is bad.

And your substituted code isn't equivalent.
The correct replacement is:

	i2 = c;
	i1 = i2;

	David