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

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).