netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] net: use semicolons rather than commas to separate statements
@ 2020-10-11 10:34 Julia Lawall
  2020-10-11 10:34 ` [PATCH 1/5] rxrpc: " Julia Lawall
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Julia Lawall @ 2020-10-11 10:34 UTC (permalink / raw)
  To: linux-security-module
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, linux-wireless, linux-kernel, netdev,
	David S. Miller, Jakub Kicinski, linux-afs

These patches replace commas by semicolons.  Commas introduce
unnecessary variability in the code structure and are hard to see.
This was done using the Coccinelle semantic patch
(http://coccinelle.lip6.fr/) shown below.

This semantic patch ensures that commas inside for loop headers will
not be transformed.  It also doesn't touch macro definitions.

Coccinelle ensures that braces are added as needed when a
single-statement branch turns into a multi-statement one.

This semantic patch has a few false positives, for variable
delcarations such as:

LIST_HEAD(x), *y;

The semantic patch could be improved to avoid these, but for the
moment they have been removed manually (2 occurrences).

// <smpl>
@initialize:ocaml@
@@

let infunction p =
  (* avoid macros *)
  (List.hd p).current_element <> "something_else"

let combined p1 p2 =
  (List.hd p1).line_end = (List.hd p2).line ||
  (((List.hd p1).line_end < (List.hd p2).line) &&
   ((List.hd p1).col < (List.hd p2).col))

@bad@
statement S;
declaration d;
position p;
@@

S@p
d

// special cases where newlines are needed (hope for no more than 5)
@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@@
expression e1,e2;
statement S;
position p != bad.p;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && combined p1 p2 };
@@

- e1@p1,@S@p e2@p2;
+ e1; e2;

@r@
expression e1,e2;
statement S;
position p != bad.p;
@@

e1 ,@S@p e2;

@@
expression e1,e2;
position p1;
position p2 :
    script:ocaml(p1) { infunction p1 && not(combined p1 p2) };
statement S;
position r.p;
@@

e1@p1
-,@S@p
+;
e2@p2
... when any
// </smpl>

---

 net/ipv4/tcp_input.c       |    3 ++-
 net/ipv4/tcp_vegas.c       |    8 ++++----
 net/ipv6/calipso.c         |    2 +-
 net/mac80211/debugfs_sta.c |    2 +-
 net/rxrpc/recvmsg.c        |    2 +-
 net/tls/tls_main.c         |    2 +-
 6 files changed, 10 insertions(+), 9 deletions(-)

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

* [PATCH 1/5] rxrpc: use semicolons rather than commas to separate statements
  2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
@ 2020-10-11 10:34 ` Julia Lawall
  2020-10-11 10:34 ` [PATCH 2/5] mac80211: " Julia Lawall
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2020-10-11 10:34 UTC (permalink / raw)
  To: David Howells
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, David S. Miller, Jakub Kicinski, linux-afs,
	netdev, linux-kernel

Replace commas with semicolons.  Commas introduce unnecessary
variability in the code structure and are hard to see.  What is done
is essentially described by the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 net/rxrpc/recvmsg.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
index c4684dde1f16..acc4660cfa5b 100644
--- a/net/rxrpc/recvmsg.c
+++ b/net/rxrpc/recvmsg.c
@@ -69,7 +69,7 @@ bool __rxrpc_set_call_completion(struct rxrpc_call *call,
 	if (call->state < RXRPC_CALL_COMPLETE) {
 		call->abort_code = abort_code;
 		call->error = error;
-		call->completion = compl,
+		call->completion = compl;
 		call->state = RXRPC_CALL_COMPLETE;
 		trace_rxrpc_call_complete(call);
 		wake_up(&call->waitq);


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

* [PATCH 2/5] mac80211: use semicolons rather than commas to separate statements
  2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
  2020-10-11 10:34 ` [PATCH 1/5] rxrpc: " Julia Lawall
@ 2020-10-11 10:34 ` Julia Lawall
  2020-10-11 10:34 ` [PATCH 3/5] tcp: " Julia Lawall
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2020-10-11 10:34 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, David S. Miller, Jakub Kicinski, linux-wireless,
	netdev, linux-kernel

Replace commas with semicolons.  Commas introduce unnecessary
variability in the code structure and are hard to see.  What is done
is essentially described by the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 net/mac80211/debugfs_sta.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/debugfs_sta.c b/net/mac80211/debugfs_sta.c
index 829dcad69c2c..6a51b8b58f9e 100644
--- a/net/mac80211/debugfs_sta.c
+++ b/net/mac80211/debugfs_sta.c
@@ -274,7 +274,7 @@ static ssize_t sta_aql_read(struct file *file, char __user *userbuf,
 		"Q limit[low/high]: VO: %u/%u VI: %u/%u BE: %u/%u BK: %u/%u\n",
 		q_depth[0], q_depth[1], q_depth[2], q_depth[3],
 		q_limit_l[0], q_limit_h[0], q_limit_l[1], q_limit_h[1],
-		q_limit_l[2], q_limit_h[2], q_limit_l[3], q_limit_h[3]),
+		q_limit_l[2], q_limit_h[2], q_limit_l[3], q_limit_h[3]);
 
 	rv = simple_read_from_buffer(userbuf, count, ppos, buf, p - buf);
 	kfree(buf);


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

* [PATCH 3/5] tcp: use semicolons rather than commas to separate statements
  2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
  2020-10-11 10:34 ` [PATCH 1/5] rxrpc: " Julia Lawall
  2020-10-11 10:34 ` [PATCH 2/5] mac80211: " Julia Lawall
@ 2020-10-11 10:34 ` Julia Lawall
  2020-10-11 10:34 ` [PATCH 4/5] net/ipv6: " Julia Lawall
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2020-10-11 10:34 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski, netdev, linux-kernel

Replace commas with semicolons.  Commas introduce unnecessary
variability in the code structure and are hard to see.  What is done
is essentially described by the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 net/ipv4/tcp_input.c |    3 ++-
 net/ipv4/tcp_vegas.c |    8 ++++----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 02d0e2fb77c0..7ff9be52c061 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4418,7 +4418,8 @@ static void tcp_sack_maybe_coalesce(struct tcp_sock *tp)
 				sp[i] = sp[i + 1];
 			continue;
 		}
-		this_sack++, swalk++;
+		this_sack++;
+		swalk++;
 	}
 }
 
diff --git a/net/ipv4/tcp_vegas.c b/net/ipv4/tcp_vegas.c
index 3f51e781562a..c8003c8aad2c 100644
--- a/net/ipv4/tcp_vegas.c
+++ b/net/ipv4/tcp_vegas.c
@@ -293,10 +293,10 @@ size_t tcp_vegas_get_info(struct sock *sk, u32 ext, int *attr,
 	const struct vegas *ca = inet_csk_ca(sk);
 
 	if (ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
-		info->vegas.tcpv_enabled = ca->doing_vegas_now,
-		info->vegas.tcpv_rttcnt = ca->cntRTT,
-		info->vegas.tcpv_rtt = ca->baseRTT,
-		info->vegas.tcpv_minrtt = ca->minRTT,
+		info->vegas.tcpv_enabled = ca->doing_vegas_now;
+		info->vegas.tcpv_rttcnt = ca->cntRTT;
+		info->vegas.tcpv_rtt = ca->baseRTT;
+		info->vegas.tcpv_minrtt = ca->minRTT;
 
 		*attr = INET_DIAG_VEGASINFO;
 		return sizeof(struct tcpvegas_info);


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

* [PATCH 4/5] net/ipv6: use semicolons rather than commas to separate statements
  2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
                   ` (2 preceding siblings ...)
  2020-10-11 10:34 ` [PATCH 3/5] tcp: " Julia Lawall
@ 2020-10-11 10:34 ` Julia Lawall
  2020-10-11 20:05   ` Paul Moore
  2020-10-11 10:34 ` [PATCH 5/5] net/tls: " Julia Lawall
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Julia Lawall @ 2020-10-11 10:34 UTC (permalink / raw)
  To: Paul Moore
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski, netdev, linux-security-module,
	linux-kernel

Replace commas with semicolons.  Commas introduce unnecessary
variability in the code structure and are hard to see.  What is done
is essentially described by the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 net/ipv6/calipso.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index 8d3f66c310db..78f766019b7e 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -761,7 +761,7 @@ static int calipso_genopt(unsigned char *buf, u32 start, u32 buf_len,
 	calipso[1] = len - 2;
 	*(__be32 *)(calipso + 2) = htonl(doi_def->doi);
 	calipso[6] = (len - CALIPSO_HDR_LEN) / 4;
-	calipso[7] = secattr->attr.mls.lvl,
+	calipso[7] = secattr->attr.mls.lvl;
 	crc = ~crc_ccitt(0xffff, calipso, len);
 	calipso[8] = crc & 0xff;
 	calipso[9] = (crc >> 8) & 0xff;


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

* [PATCH 5/5] net/tls: use semicolons rather than commas to separate statements
  2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
                   ` (3 preceding siblings ...)
  2020-10-11 10:34 ` [PATCH 4/5] net/ipv6: " Julia Lawall
@ 2020-10-11 10:34 ` Julia Lawall
  2020-10-12  7:00 ` [PATCH 1/5] rxrpc: " David Howells
  2020-10-14  0:15 ` [PATCH 0/5] net: " Jakub Kicinski
  6 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2020-10-11 10:34 UTC (permalink / raw)
  To: Boris Pismenny
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, Aviad Yehezkel, John Fastabend, Daniel Borkmann,
	Jakub Kicinski, David S. Miller, netdev, linux-kernel

Replace commas with semicolons.  Commas introduce unnecessary
variability in the code structure and are hard to see.  What is done
is essentially described by the following Coccinelle semantic patch
(http://coccinelle.lip6.fr/):

// <smpl>
@@ expression e1,e2; @@
e1
-,
+;
e2
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>

---
 net/tls/tls_main.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 002b0859fed5..8d93cea99f2c 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -869,7 +869,7 @@ static int __init tls_register(void)
 
 	tls_sw_proto_ops = inet_stream_ops;
 	tls_sw_proto_ops.splice_read = tls_sw_splice_read;
-	tls_sw_proto_ops.sendpage_locked   = tls_sw_sendpage_locked,
+	tls_sw_proto_ops.sendpage_locked   = tls_sw_sendpage_locked;
 
 	tls_device_init();
 	tcp_register_ulp(&tcp_tls_ulp_ops);


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

* Re: [PATCH 4/5] net/ipv6: use semicolons rather than commas to separate statements
  2020-10-11 10:34 ` [PATCH 4/5] net/ipv6: " Julia Lawall
@ 2020-10-11 20:05   ` Paul Moore
  0 siblings, 0 replies; 10+ messages in thread
From: Paul Moore @ 2020-10-11 20:05 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, David S. Miller, Alexey Kuznetsov,
	Hideaki YOSHIFUJI, Jakub Kicinski, netdev, linux-security-module,
	linux-kernel

On Sun, Oct 11, 2020 at 7:18 AM Julia Lawall <Julia.Lawall@inria.fr> wrote:
>
> Replace commas with semicolons.  Commas introduce unnecessary
> variability in the code structure and are hard to see.  What is done
> is essentially described by the following Coccinelle semantic patch
> (http://coccinelle.lip6.fr/):
>
> // <smpl>
> @@ expression e1,e2; @@
> e1
> -,
> +;
> e2
> ... when any
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
>
> ---
>  net/ipv6/calipso.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks Julia.

Acked-by: Paul Moore <paul@paul-moore.com>

> diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
> index 8d3f66c310db..78f766019b7e 100644
> --- a/net/ipv6/calipso.c
> +++ b/net/ipv6/calipso.c
> @@ -761,7 +761,7 @@ static int calipso_genopt(unsigned char *buf, u32 start, u32 buf_len,
>         calipso[1] = len - 2;
>         *(__be32 *)(calipso + 2) = htonl(doi_def->doi);
>         calipso[6] = (len - CALIPSO_HDR_LEN) / 4;
> -       calipso[7] = secattr->attr.mls.lvl,
> +       calipso[7] = secattr->attr.mls.lvl;
>         crc = ~crc_ccitt(0xffff, calipso, len);
>         calipso[8] = crc & 0xff;
>         calipso[9] = (crc >> 8) & 0xff;

-- 
paul moore
www.paul-moore.com

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

* Re: [PATCH 1/5] rxrpc: use semicolons rather than commas to separate statements
  2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
                   ` (4 preceding siblings ...)
  2020-10-11 10:34 ` [PATCH 5/5] net/tls: " Julia Lawall
@ 2020-10-12  7:00 ` David Howells
  2020-10-12  7:03   ` Julia Lawall
  2020-10-14  0:15 ` [PATCH 0/5] net: " Jakub Kicinski
  6 siblings, 1 reply; 10+ messages in thread
From: David Howells @ 2020-10-12  7:00 UTC (permalink / raw)
  To: Julia Lawall
  Cc: dhowells, Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, David S. Miller, Jakub Kicinski, linux-afs,
	netdev, linux-kernel

Julia Lawall <Julia.Lawall@inria.fr> wrote:

> -		call->completion = compl,
> +		call->completion = compl;

Looks good.  Do you want me to pick up the patch or send it yourself?

If the latter:

Acked-by: David Howells <dhowells@redhat.com>


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

* Re: [PATCH 1/5] rxrpc: use semicolons rather than commas to separate statements
  2020-10-12  7:00 ` [PATCH 1/5] rxrpc: " David Howells
@ 2020-10-12  7:03   ` Julia Lawall
  0 siblings, 0 replies; 10+ messages in thread
From: Julia Lawall @ 2020-10-12  7:03 UTC (permalink / raw)
  To: David Howells
  Cc: Julia Lawall, Valdis Klētnieks, Joe Perches,
	Thomas Gleixner, kernel-janitors, David S. Miller,
	Jakub Kicinski, linux-afs, netdev, linux-kernel



On Mon, 12 Oct 2020, David Howells wrote:

> Julia Lawall <Julia.Lawall@inria.fr> wrote:
>
> > -		call->completion = compl,
> > +		call->completion = compl;
>
> Looks good.  Do you want me to pick up the patch or send it yourself?

Please pick it up.  Thanks.

julia

>
> If the latter:
>
> Acked-by: David Howells <dhowells@redhat.com>
>
>

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

* Re: [PATCH 0/5] net: use semicolons rather than commas to separate statements
  2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
                   ` (5 preceding siblings ...)
  2020-10-12  7:00 ` [PATCH 1/5] rxrpc: " David Howells
@ 2020-10-14  0:15 ` Jakub Kicinski
  6 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2020-10-14  0:15 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-security-module, Valdis Klētnieks, Joe Perches,
	Thomas Gleixner, kernel-janitors, linux-wireless, linux-kernel,
	netdev, David S. Miller, linux-afs

On Sun, 11 Oct 2020 12:34:53 +0200 Julia Lawall wrote:
> These patches replace commas by semicolons.  Commas introduce
> unnecessary variability in the code structure and are hard to see.
> This was done using the Coccinelle semantic patch
> (http://coccinelle.lip6.fr/) shown below.

Applied 3-5 to net-next, thanks!

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

end of thread, other threads:[~2020-10-14  0:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-11 10:34 [PATCH 0/5] net: use semicolons rather than commas to separate statements Julia Lawall
2020-10-11 10:34 ` [PATCH 1/5] rxrpc: " Julia Lawall
2020-10-11 10:34 ` [PATCH 2/5] mac80211: " Julia Lawall
2020-10-11 10:34 ` [PATCH 3/5] tcp: " Julia Lawall
2020-10-11 10:34 ` [PATCH 4/5] net/ipv6: " Julia Lawall
2020-10-11 20:05   ` Paul Moore
2020-10-11 10:34 ` [PATCH 5/5] net/tls: " Julia Lawall
2020-10-12  7:00 ` [PATCH 1/5] rxrpc: " David Howells
2020-10-12  7:03   ` Julia Lawall
2020-10-14  0:15 ` [PATCH 0/5] net: " Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).