linux-samsung-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/20] media: use semicolons rather than commas to separate statements
@ 2020-09-29 13:14 Julia Lawall
  2020-09-29 13:14 ` [PATCH 07/20] media: s3c-camif: " Julia Lawall
  2020-09-29 13:14 ` [PATCH 19/20] media: exynos4-is: " Julia Lawall
  0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2020-09-29 13:14 UTC (permalink / raw)
  To: linux-samsung-soc
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, Mauro Carvalho Chehab, linux-media,
	linux-kernel, linux-arm-kernel

These patches replace commas by semicolons.  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>

---

 drivers/media/dvb-frontends/m88ds3103.c             |    6 ++---
 drivers/media/dvb-frontends/rtl2832.c               |   14 ++++++------
 drivers/media/dvb-frontends/ts2020.c                |   10 ++++-----
 drivers/media/i2c/msp3400-kthreads.c                |   12 +++++++---
 drivers/media/pci/bt8xx/bttv-cards.c                |    6 +++--
 drivers/media/pci/saa7134/saa7134-video.c           |    7 ++++--
 drivers/media/platform/coda/coda-common.c           |    2 -
 drivers/media/platform/exynos4-is/fimc-core.c       |    6 +++--
 drivers/media/platform/s3c-camif/camif-core.c       |    6 +++--
 drivers/media/platform/sunxi/sun4i-csi/sun4i_v4l2.c |    2 -
 drivers/media/radio/radio-sf16fmr2.c                |    2 -
 drivers/media/tuners/mt2060.c                       |    2 -
 drivers/media/usb/au0828/au0828-video.c             |    2 -
 drivers/media/usb/dvb-usb-v2/dvbsky.c               |   22 ++++++++++----------
 drivers/media/usb/dvb-usb-v2/lmedm04.c              |    2 -
 drivers/media/usb/dvb-usb-v2/rtl28xxu.c             |    4 +--
 drivers/media/usb/dvb-usb/dib0700_devices.c         |    4 +--
 drivers/media/usb/em28xx/em28xx-audio.c             |   14 ++++++------
 drivers/media/usb/gspca/ov534.c                     |   12 +++++-----
 drivers/media/usb/pvrusb2/pvrusb2-devattr.c         |    2 -
 20 files changed, 75 insertions(+), 62 deletions(-)

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

* [PATCH 07/20] media: s3c-camif: use semicolons rather than commas to separate statements
  2020-09-29 13:14 [PATCH 00/20] media: use semicolons rather than commas to separate statements Julia Lawall
@ 2020-09-29 13:14 ` Julia Lawall
  2020-09-29 13:14 ` [PATCH 19/20] media: exynos4-is: " Julia Lawall
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2020-09-29 13:14 UTC (permalink / raw)
  To: Sylwester Nawrocki
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, Mauro Carvalho Chehab, linux-media,
	linux-samsung-soc, 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>

---
 drivers/media/platform/s3c-camif/camif-core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c
index 92f43c0cbc0c..02b5f933c411 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -131,11 +131,13 @@ static int camif_get_scaler_factor(u32 src, u32 tar, u32 *ratio, u32 *shift)
 	while (sh--) {
 		unsigned int tmp = 1 << sh;
 		if (src >= tar * tmp) {
-			*shift = sh, *ratio = tmp;
+			*shift = sh;
+			*ratio = tmp;
 			return 0;
 		}
 	}
-	*shift = 0, *ratio = 1;
+	*shift = 0;
+	*ratio = 1;
 	return 0;
 }
 


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

* [PATCH 19/20] media: exynos4-is: use semicolons rather than commas to separate statements
  2020-09-29 13:14 [PATCH 00/20] media: use semicolons rather than commas to separate statements Julia Lawall
  2020-09-29 13:14 ` [PATCH 07/20] media: s3c-camif: " Julia Lawall
@ 2020-09-29 13:14 ` Julia Lawall
  1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2020-09-29 13:14 UTC (permalink / raw)
  To: Kyungmin Park
  Cc: Valdis Klētnieks, Joe Perches, Thomas Gleixner,
	kernel-janitors, Sylwester Nawrocki, Mauro Carvalho Chehab,
	Kukjin Kim, Krzysztof Kozlowski, linux-media, linux-arm-kernel,
	linux-samsung-soc, 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>

---
 drivers/media/platform/exynos4-is/fimc-core.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c
index 08d1f39a914c..db6e548fe08e 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -214,11 +214,13 @@ static int fimc_get_scaler_factor(u32 src, u32 tar, u32 *ratio, u32 *shift)
 	while (sh--) {
 		u32 tmp = 1 << sh;
 		if (src >= tar * tmp) {
-			*shift = sh, *ratio = tmp;
+			*shift = sh;
+			*ratio = tmp;
 			return 0;
 		}
 	}
-	*shift = 0, *ratio = 1;
+	*shift = 0;
+	*ratio = 1;
 	return 0;
 }
 


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

end of thread, other threads:[~2020-09-29 14:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 13:14 [PATCH 00/20] media: use semicolons rather than commas to separate statements Julia Lawall
2020-09-29 13:14 ` [PATCH 07/20] media: s3c-camif: " Julia Lawall
2020-09-29 13:14 ` [PATCH 19/20] media: exynos4-is: " Julia Lawall

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