linux/drivers/staging/dgnc
Chi Pham f7c851d424 staging:dgnc: Removed assignments from if statements.
Coccinelle was used for this patch. The script is not complete (semantically) and might raise some checkpatch warnings in terms of indentation depending on existing code.

*** IFASSIGNMENT.COCCI START ***

/* Coccinelle script to handle assignments in if statements
 * For compound statements, can so far only handle statements with the
 * assignment on either extreme */

/* This rule is for simple cases
 * e.g. just an assignment in if, possibly with unary operator */
@simple@
expression E1, E2;
statement S1, S2;
@@

+ E1 = E2;
if (
- (E1 = E2)
+ E1
 )
S1 else S2

/* This rule is for compound statements where the assignment is on the right.*/
@right@
expression E, E1, E2;
statement S1, S2;
@@

(
/* and */
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ } else S2
|
- if (E && (E1 = E2))
+ if (E) {
+ E1 = E2;
+ if (E1)
S1
+ }

/* or */
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1)
S1 else S2
+ }
+ else S1
|
- if (E || (E1 = E2))
+ if (!E) {
+ E1 = E2;
+ if (E1) S1
+ } else
S1

/* not equal */
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1 else S2
|
- if (E != (E1 = E2))
+ E1 = E2;
+ if (E != E1)
S1

/* equal */
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1 else S2
|
- if (E == (E1 = E2))
+ E1 = E2;
+ if (E == E1)
S1

/* greater than */
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1 else S2
|
- if (E > (E1 = E2))
+ E1 = E2;
+ if (E > E1)
S1

/* less than */
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1 else S2
|
- if (E < (E1 = E2))
+ E1 = E2;
+ if (E < E1)
S1

/* lesser than or equal to */
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1 else S2
|
- if (E <= (E1 = E2))
+ E1 = E2;
+ if (E <= E1)
S1

/* greater than or equal to */
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1 else S2
|
- if (E >= (E1 = E2))
+ E1 = E2;
+ if (E >= E1)
S1
)

/* This rule is for compound statements where the assignment is on the left.*/
@left@
expression E, E1, E2;
statement S1, S2;
@@

(
/* and */
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1 else S2
|
- if ((E1 = E2) && E)
+ E1 = E2;
+ if (E1 && E)
S1
|

/* or */
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1
|
- if ((E1 = E2) || E)
+ E1 = E2;
+ if (E1 || E)
S1 else S2
|

/* not equal */
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1
|
- if ((E1 = E2) != E)
+ E1 = E2;
+ if (E1 != E)
S1 else S2
|

/* equal */
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1
|
- if ((E1 = E2) == E)
+ E1 = E2;
+ if (E1 == E)
S1 else S2
|
/* greater */
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1
|
- if ((E1 = E2) > E)
+ E1 = E2;
+ if (E1 > E)
S1 else S2
|

/* less */
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1
|
- if ((E1 = E2) < E)
+ E1 = E2;
+ if (E1 < E)
S1 else S2

/* lesser than or equal to */
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1
|
- if ((E1 = E2) <= E)
+ E1 = E2;
+ if (E1 <= E)
S1 else S2

/* greater than or equal to */
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1
|
- if ((E1 = E2) >= E)
+ E1 = E2;
+ if (E1 >= E)
S1 else S2
)

*** IFASSIGNMENT.COCCI END ***

Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-17 16:42:47 -07:00
..
Kconfig staging: dgnc: Kconfig: add dependency PCI for it 2013-08-26 06:29:09 -07:00
Makefile staging: dgnc: removes proc code 2013-08-15 10:14:29 -07:00
TODO staging: dgnc: adds TODO 2013-08-30 11:28:58 -07:00
dgnc_cls.c staging: dgnc: Fix quoted string split across lines warning 2014-03-16 22:04:41 -07:00
dgnc_cls.h staging: dgnc: cls_uart_struct: adds marker and changes vars' types for sparse 2013-08-26 16:26:55 -07:00
dgnc_driver.c staging:dgnc: Replace printk by pr_warn 2014-03-08 19:21:13 -08:00
dgnc_driver.h staging: dgnc: Fix typo in staging/dgnc 2013-09-17 07:47:46 -07:00
dgnc_kcompat.h staging: dgnc: Remove KERNEL_VERSION check 2013-09-30 18:47:00 -07:00
dgnc_mgmt.c Staging: dgnc: fix indentation in dgnc_mgmt.c 2014-03-13 16:17:59 -07:00
dgnc_mgmt.h staging: dgnc: removes ifdef HAVE_UNLOCKED_IOCTL conditionals 2013-08-20 16:28:40 -07:00
dgnc_neo.c staging:dgnc: Removed assignments from if statements. 2014-03-17 16:42:47 -07:00
dgnc_neo.h staging: dgnc: Fix typo in staging/dgnc 2013-09-17 07:47:46 -07:00
dgnc_pci.h staging: dgnc: removes CVS code from files 2013-08-21 10:48:40 -07:00
dgnc_sysfs.c staging: dgnc: Remove casting the return value which is a void pointer 2013-09-26 09:26:12 -07:00
dgnc_sysfs.h staging: dgnc: renames board_t to dgnc_board 2013-09-17 07:47:43 -07:00
dgnc_trace.c drivers: dgnc: Include appropriate header file in dgnc_trace.c 2014-01-08 15:47:35 -08:00
dgnc_trace.h staging: dgnc: removes CVS code from files 2013-08-21 10:48:40 -07:00
dgnc_tty.c staging:dgnc: Removed assignments from if statements. 2014-03-17 16:42:47 -07:00
dgnc_tty.h staging: dgnc: renames board_t to dgnc_board 2013-09-17 07:47:43 -07:00
dgnc_types.h
digi.h staging: dgnc: Fix typo in staging/dgnc 2013-09-17 07:47:46 -07:00
dpacompat.h staging: dgnc: dpacompat.h: removes trailing whitespace 2013-08-21 09:44:05 -07:00