Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1215821

[PATCH 0/8] put constant on the right of binary operator

From Julia Lawall <Julia.Lawall@lip6.fr>
Newsgroups linux.kernel
Subject [PATCH 0/8] put constant on the right of binary operator
Date 2015-08-29 19:50 +0200
Message-ID <q2Sql-ob-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 0/8] put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
  [PATCH 7/8] staging: lustre: osc: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
  [PATCH 1/8] staging: lustre: include: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
  [PATCH 8/8] staging: lustre: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
    Re: [PATCH 8/8] staging: lustre: put constant on the right of  binary operator Joe Perches <joe@perches.com> - 2015-08-30 02:00 +0200
      Re: [PATCH 8/8] staging: lustre: put constant on the right of binary  operator Julia Lawall <julia.lawall@lip6.fr> - 2015-08-30 10:50 +0200
      Re: [PATCH 8/8] staging: lustre: put constant on the right of binary  operator Julia Lawall <julia.lawall@lip6.fr> - 2015-08-30 19:20 +0200
  [PATCH 6/8] Staging: lustre: obd: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
  [PATCH 3/8] staging: lustre: ldlm: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
  [PATCH 2/8] staging: lustre: lnet: lib-ptl.c: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
  [PATCH 5/8] staging: lustre: llite: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200
  [PATCH 4/8] staging: lustre: libcfs: put constant on the right of binary operator Julia Lawall <Julia.Lawall@lip6.fr> - 2015-08-29 19:50 +0200

csiph-web