public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] put constant on the right of binary operator
@ 2015-08-29 17:30 Julia Lawall
  2015-08-29 17:30 ` [PATCH 1/8] staging: lustre: include: " Julia Lawall
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: joe, kernel-janitors, devel, HPDD-discuss, Greg Kroah-Hartman,
	Andreas Dilger, Oleg Drokin

Typically, constants appear to the right of binary operators.  The complete
semantic patch that performs this change is as follows
(http://coccinelle.lip6.fr/).  In particular, it doesn't change long
sequences of bit ors, or comparisons that are checking that some
expression has a value that is between two other values.

// <smpl>
@disable bitor_comm, neg_if_exp@
constant c,c1;
local idexpression i;
expression e,e1,e2;
binary operator b = {==,!=,&,|};
type t;
@@

(
c b (c1)
|
sizeof(t) b e1
|
sizeof e b e1
|
i b e1
|
c | e1 | e2 | ...
|
c | (e ? e1 : e2)
|
- c
+ e
b
- e
+ c
)

@disable gtr_lss, gtr_lss_eq, not_int2@
constant c,c1,c2;
expression e,e1,e2;
binary operator b;
binary operator b1 = {<,<=},b2 = {<,<=};
binary operator b3 = {>,>=},b4 = {>,>=};
local idexpression i;
type t;
@@

(
c b c1
|
sizeof(t) b e1
|
sizeof e b e1
|
 (e1 b1 e) && (e b2 e2)
|
 (e1 b3 e) && (e b4 e2)
|
i b e
|
- c < e
+ e > c
|
- c <= e
+ e >= c
|
- c > e
+ e < c
|
- c >= e
+ e <= c
)
// </smpl>

---

 drivers/staging/lustre/include/linux/lnet/types.h   |    2 +-
 drivers/staging/lustre/lnet/lnet/lib-ptl.c          |    4 ++--
 drivers/staging/lustre/lustre/ldlm/ldlm_flock.c     |    8 ++++----
 drivers/staging/lustre/lustre/libcfs/hash.c         |    6 +++---
 drivers/staging/lustre/lustre/llite/dir.c           |   10 +++++-----
 drivers/staging/lustre/lustre/llite/file.c          |   10 +++++-----
 drivers/staging/lustre/lustre/llite/llite_lib.c     |    2 +-
 drivers/staging/lustre/lustre/obdclass/cl_object.c  |    4 ++--
 drivers/staging/lustre/lustre/osc/osc_page.c        |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/client.c       |    2 +-
 drivers/staging/lustre/lustre/ptlrpc/import.c       |   10 +++++-----
 drivers/staging/lustre/lustre/ptlrpc/pack_generic.c |    2 +-
 12 files changed, 31 insertions(+), 31 deletions(-)

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

end of thread, other threads:[~2015-08-30 17:12 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-29 17:30 [PATCH 0/8] put constant on the right of binary operator Julia Lawall
2015-08-29 17:30 ` [PATCH 1/8] staging: lustre: include: " Julia Lawall
2015-08-29 17:30 ` [PATCH 2/8] staging: lustre: lnet: lib-ptl.c: " Julia Lawall
2015-08-29 17:30 ` [PATCH 3/8] staging: lustre: ldlm: " Julia Lawall
2015-08-29 17:30 ` [PATCH 4/8] staging: lustre: libcfs: " Julia Lawall
2015-08-29 17:30 ` [PATCH 5/8] staging: lustre: llite: " Julia Lawall
2015-08-29 17:30 ` [PATCH 6/8] Staging: lustre: obd: " Julia Lawall
2015-08-29 17:30 ` [PATCH 7/8] staging: lustre: osc: " Julia Lawall
2015-08-29 17:30 ` [PATCH 8/8] staging: lustre: " Julia Lawall
2015-08-29 23:53   ` Joe Perches
2015-08-30  8:42     ` Julia Lawall
2015-08-30 17:12     ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox