* [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
* [PATCH 1/8] staging: lustre: include: put constant on the right of binary operator
2015-08-29 17:30 [PATCH 0/8] put constant on the right of binary operator Julia Lawall
@ 2015-08-29 17:30 ` Julia Lawall
2015-08-29 17:30 ` [PATCH 2/8] staging: lustre: lnet: lib-ptl.c: " Julia Lawall
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/staging/lustre/include/linux/lnet/types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/include/linux/lnet/types.h b/drivers/staging/lustre/include/linux/lnet/types.h
index 940f73f..1163018 100644
--- a/drivers/staging/lustre/include/linux/lnet/types.h
+++ b/drivers/staging/lustre/include/linux/lnet/types.h
@@ -303,7 +303,7 @@ static inline int LNetHandleIsEqual(lnet_handle_any_t h1, lnet_handle_any_t h2)
*/
static inline int LNetHandleIsInvalid(lnet_handle_any_t h)
{
- return LNET_WIRE_HANDLE_COOKIE_NONE = h.cookie;
+ return h.cookie = LNET_WIRE_HANDLE_COOKIE_NONE;
}
/**
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 2/8] staging: lustre: lnet: lib-ptl.c: put constant on the right of binary operator
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 ` Julia Lawall
2015-08-29 17:30 ` [PATCH 3/8] staging: lustre: ldlm: " Julia Lawall
` (5 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/staging/lustre/lnet/lnet/lib-ptl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
index 84707c5..b4f573a 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
@@ -420,9 +420,9 @@ lnet_mt_match_md(struct lnet_match_table *mtable,
if (info->mi_opc = LNET_MD_OP_GET ||
!lnet_ptl_is_lazy(the_lnet.ln_portals[info->mi_portal]))
- return LNET_MATCHMD_DROP | exhausted;
+ return exhausted | LNET_MATCHMD_DROP;
- return LNET_MATCHMD_NONE | exhausted;
+ return exhausted | LNET_MATCHMD_NONE;
}
static int
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 3/8] staging: lustre: ldlm: put constant on the right of binary operator
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 ` Julia Lawall
2015-08-29 17:30 ` [PATCH 4/8] staging: lustre: libcfs: " Julia Lawall
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
index a4c252f..ab670fc 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c
@@ -602,7 +602,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
(LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) {
if (lock->l_req_mode = lock->l_granted_mode &&
lock->l_granted_mode != LCK_NL &&
- NULL = data)
+ data = NULL)
ldlm_lock_decref_internal(lock, lock->l_req_mode);
/* Need to wake up the waiter if we were evicted */
@@ -614,7 +614,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED |
LDLM_FL_BLOCK_CONV))) {
- if (NULL = data)
+ if (data = NULL)
/* mds granted the lock in the reply */
goto granted;
/* CP AST RPC: lock get granted, wake it up */
@@ -627,10 +627,10 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
obd = class_exp2obd(lock->l_conn_export);
/* if this is a local lock, there is no import */
- if (NULL != obd)
+ if (obd != NULL)
imp = obd->u.cli.cl_import;
- if (NULL != imp) {
+ if (imp != NULL) {
spin_lock(&imp->imp_lock);
fwd.fwd_generation = imp->imp_generation;
spin_unlock(&imp->imp_lock);
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 4/8] staging: lustre: libcfs: put constant on the right of binary operator
2015-08-29 17:30 [PATCH 0/8] put constant on the right of binary operator Julia Lawall
` (2 preceding siblings ...)
2015-08-29 17:30 ` [PATCH 3/8] staging: lustre: ldlm: " Julia Lawall
@ 2015-08-29 17:30 ` Julia Lawall
2015-08-29 17:30 ` [PATCH 5/8] staging: lustre: llite: " Julia Lawall
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/staging/lustre/lustre/libcfs/hash.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/hash.c b/drivers/staging/lustre/lustre/libcfs/hash.c
index 0ed0631..08f0b48 100644
--- a/drivers/staging/lustre/lustre/libcfs/hash.c
+++ b/drivers/staging/lustre/lustre/libcfs/hash.c
@@ -677,8 +677,8 @@ cfs_hash_bd_findadd_locked(struct cfs_hash *hs, struct cfs_hash_bd *bd,
int noref)
{
return cfs_hash_bd_lookup_intent(hs, bd, key, hnode,
- CFS_HS_LOOKUP_IT_ADD |
- (!noref * CFS_HS_LOOKUP_MASK_REF));
+ (!noref * CFS_HS_LOOKUP_MASK_REF) |
+ CFS_HS_LOOKUP_IT_ADD);
}
EXPORT_SYMBOL(cfs_hash_bd_findadd_locked);
@@ -756,7 +756,7 @@ cfs_hash_multi_bd_findadd_locked(struct cfs_hash *hs,
unsigned i;
LASSERT(hnode != NULL);
- intent = CFS_HS_LOOKUP_IT_PEEK | (!noref * CFS_HS_LOOKUP_MASK_REF);
+ intent = (!noref * CFS_HS_LOOKUP_MASK_REF) | CFS_HS_LOOKUP_IT_PEEK;
cfs_hash_for_each_bd(bds, n, i) {
ehnode = cfs_hash_bd_lookup_intent(hs, &bds[i], key,
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 5/8] staging: lustre: llite: put constant on the right of binary operator
2015-08-29 17:30 [PATCH 0/8] put constant on the right of binary operator Julia Lawall
` (3 preceding siblings ...)
2015-08-29 17:30 ` [PATCH 4/8] staging: lustre: libcfs: " Julia Lawall
@ 2015-08-29 17:30 ` Julia Lawall
2015-08-29 17:30 ` [PATCH 6/8] Staging: lustre: obd: " Julia Lawall
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
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 +-
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index b4ed6c8..fcad241 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -2201,7 +2201,7 @@ struct md_op_data *ll_prep_md_op_data(struct md_op_data *op_data,
}
/* When called by ll_setattr_raw, file is i1. */
- if (LLIF_DATA_MODIFIED & ll_i2info(i1)->lli_flags)
+ if (ll_i2info(i1)->lli_flags & LLIF_DATA_MODIFIED)
op_data->op_bias |= MDS_DATA_MODIFIED;
return op_data;
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index dcd0c6d..eaf35e2 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -94,7 +94,7 @@ void ll_pack_inode2opdata(struct inode *inode, struct md_op_data *op_data,
op_data->op_handle = *fh;
op_data->op_capa1 = ll_mdscapa_get(inode);
- if (LLIF_DATA_MODIFIED & ll_i2info(inode)->lli_flags)
+ if (ll_i2info(inode)->lli_flags & LLIF_DATA_MODIFIED)
op_data->op_bias |= MDS_DATA_MODIFIED;
}
@@ -1433,7 +1433,7 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
* little endian. We convert it to host endian before
* passing it to userspace.
*/
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC)) {
+ if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC) {
int stripe_count;
stripe_count = le16_to_cpu(lmm->lmm_stripe_count);
@@ -2494,8 +2494,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
default: {
int err;
- if (LLIOC_STOP =
- ll_iocontrol_call(inode, file, cmd, arg, &err))
+ if (ll_iocontrol_call(inode, file, cmd, arg, &err) =
+ LLIOC_STOP)
return err;
return obd_iocontrol(cmd, ll_i2dtexp(inode), 0, NULL,
@@ -2850,7 +2850,7 @@ ldlm_mode_t ll_take_md_lock(struct inode *inode, __u64 bits,
fid = &ll_i2info(inode)->lli_fid;
CDEBUG(D_INFO, "trying to match res "DFID"\n", PFID(fid));
- rc = md_lock_match(ll_i2mdexp(inode), LDLM_FL_BLOCK_GRANTED|flags,
+ rc = md_lock_match(ll_i2mdexp(inode), flags | LDLM_FL_BLOCK_GRANTED,
fid, LDLM_IBITS, &policy, mode, lockh);
return rc;
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 769b611..d407fcc 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -660,7 +660,7 @@ static int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump,
int mode;
int err;
- mode = (0755 & ~current_umask()) | S_IFDIR;
+ mode = (~current_umask() & 0755) | S_IFDIR;
op_data = ll_prep_md_op_data(NULL, dir, NULL, filename,
strlen(filename), mode, LUSTRE_OPC_MKDIR,
lump);
@@ -838,11 +838,11 @@ int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
/* We don't swab objects for directories */
switch (le32_to_cpu(lmm->lmm_magic)) {
case LOV_MAGIC_V1:
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))
+ if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC)
lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm);
break;
case LOV_MAGIC_V3:
- if (LOV_MAGIC != cpu_to_le32(LOV_MAGIC))
+ if (cpu_to_le32(LOV_MAGIC) != LOV_MAGIC)
lustre_swab_lov_user_md_v3((struct lov_user_md_v3 *)lmm);
break;
default:
@@ -1554,7 +1554,7 @@ out_req:
switch (lmm->lmm_magic) {
case LOV_USER_MAGIC_V1:
- if (LOV_USER_MAGIC_V1 = cpu_to_le32(LOV_USER_MAGIC_V1))
+ if (cpu_to_le32(LOV_USER_MAGIC_V1) = LOV_USER_MAGIC_V1)
break;
/* swab objects first so that stripes num will be sane */
lustre_swab_lov_user_md_objects(
@@ -1563,7 +1563,7 @@ out_req:
lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lmm);
break;
case LOV_USER_MAGIC_V3:
- if (LOV_USER_MAGIC_V3 = cpu_to_le32(LOV_USER_MAGIC_V3))
+ if (cpu_to_le32(LOV_USER_MAGIC_V3) = LOV_USER_MAGIC_V3)
break;
/* swab objects first so that stripes num will be sane */
lustre_swab_lov_user_md_objects(
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 6/8] Staging: lustre: obd: put constant on the right of binary operator
2015-08-29 17:30 [PATCH 0/8] put constant on the right of binary operator Julia Lawall
` (4 preceding siblings ...)
2015-08-29 17:30 ` [PATCH 5/8] staging: lustre: llite: " Julia Lawall
@ 2015-08-29 17:30 ` 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
7 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/staging/lustre/lustre/obdclass/cl_object.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c
index 163fe0c..9f4fa41 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c
@@ -693,10 +693,10 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)
INIT_LIST_HEAD(&cle->ce_linkage);
cle->ce_magic = &cl_env_init0;
env = &cle->ce_lu;
- rc = lu_env_init(env, LCT_CL_THREAD|ctx_tags);
+ rc = lu_env_init(env, ctx_tags | LCT_CL_THREAD);
if (rc = 0) {
rc = lu_context_init(&cle->ce_ses,
- LCT_SESSION | ses_tags);
+ ses_tags | LCT_SESSION);
if (rc = 0) {
lu_context_enter(&cle->ce_ses);
env->le_ses = &cle->ce_ses;
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 7/8] staging: lustre: osc: put constant on the right of binary operator
2015-08-29 17:30 [PATCH 0/8] put constant on the right of binary operator Julia Lawall
` (5 preceding siblings ...)
2015-08-29 17:30 ` [PATCH 6/8] Staging: lustre: obd: " Julia Lawall
@ 2015-08-29 17:30 ` Julia Lawall
2015-08-29 17:30 ` [PATCH 8/8] staging: lustre: " Julia Lawall
7 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
drivers/staging/lustre/lustre/osc/osc_page.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lustre/osc/osc_page.c b/drivers/staging/lustre/lustre/osc/osc_page.c
index f9cf5ce..856d859 100644
--- a/drivers/staging/lustre/lustre/osc/osc_page.c
+++ b/drivers/staging/lustre/lustre/osc/osc_page.c
@@ -553,7 +553,7 @@ void osc_page_submit(const struct lu_env *env, struct osc_page *opg,
oap->oap_cmd = crt = CRT_WRITE ? OBD_BRW_WRITE : OBD_BRW_READ;
oap->oap_page_off = opg->ops_from;
oap->oap_count = opg->ops_to - opg->ops_from;
- oap->oap_brw_flags = OBD_BRW_SYNC | brw_flags;
+ oap->oap_brw_flags = brw_flags | OBD_BRW_SYNC;
if (!client_is_remote(osc_export(obj)) &&
capable(CFS_CAP_SYS_RESOURCE)) {
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH 8/8] staging: lustre: put constant on the right of binary operator
2015-08-29 17:30 [PATCH 0/8] put constant on the right of binary operator Julia Lawall
` (6 preceding siblings ...)
2015-08-29 17:30 ` [PATCH 7/8] staging: lustre: osc: " Julia Lawall
@ 2015-08-29 17:30 ` Julia Lawall
2015-08-29 23:53 ` Joe Perches
7 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-08-29 17:30 UTC (permalink / raw)
To: Oleg Drokin
Cc: joe, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
Move constants to the right of binary operators.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
constant c;
expression e;
binary operator b = {=,!=,&,|};
@@
(
- c
+ e
b
- e
+ c
|
- c < e
+ e > c
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
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 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
index 84937ad..e9f8aa0 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pack_generic.c
@@ -883,7 +883,7 @@ void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
case LUSTRE_MSG_MAGIC_V2: {
struct ptlrpc_body *pb = lustre_msg_ptlrpc_body(msg);
LASSERTF(pb, "invalid msg %p: no ptlrpc body!\n", msg);
- pb->pb_flags &= ~(MSG_GEN_FLAG_MASK & flags);
+ pb->pb_flags &= ~(flags & MSG_GEN_FLAG_MASK);
return;
}
default:
diff --git a/drivers/staging/lustre/lustre/ptlrpc/import.c b/drivers/staging/lustre/lustre/ptlrpc/import.c
index 1eae389..6c00748 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/import.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/import.c
@@ -906,7 +906,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
}
/* Determine what recovery state to move the import to. */
- if (MSG_CONNECT_RECONNECT & msg_flags) {
+ if (msg_flags & MSG_CONNECT_RECONNECT) {
memset(&old_hdl, 0, sizeof(old_hdl));
if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg),
sizeof(old_hdl))) {
@@ -931,7 +931,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
* eviction. If it is in recovery - we are safe to
* participate since we can reestablish all of our state
* with server again */
- if ((MSG_CONNECT_RECOVERING & msg_flags)) {
+ if ((msg_flags & MSG_CONNECT_RECOVERING)) {
CDEBUG(level, "%s@%s changed server handle from %#llx to %#llx but is still in recovery\n",
obd2cli_tgt(imp->imp_obd),
imp->imp_connection->c_remote_uuid.uuid,
@@ -952,7 +952,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
imp->imp_remote_handle *lustre_msg_get_handle(request->rq_repmsg);
- if (!(MSG_CONNECT_RECOVERING & msg_flags)) {
+ if (!(msg_flags & MSG_CONNECT_RECOVERING)) {
IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
rc = 0;
goto finish;
@@ -968,7 +968,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
CDEBUG(D_HA, "%s: reconnected but import is invalid; marking evicted\n",
imp->imp_obd->obd_name);
IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
- } else if (MSG_CONNECT_RECOVERING & msg_flags) {
+ } else if (msg_flags & MSG_CONNECT_RECOVERING) {
CDEBUG(D_HA, "%s: reconnected to %s during replay\n",
imp->imp_obd->obd_name,
obd2cli_tgt(imp->imp_obd));
@@ -981,7 +981,7 @@ static int ptlrpc_connect_interpret(const struct lu_env *env,
} else {
IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
}
- } else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) {
+ } else if ((msg_flags & MSG_CONNECT_RECOVERING) && !imp->imp_invalid) {
LASSERT(imp->imp_replayable);
imp->imp_remote_handle *lustre_msg_get_handle(request->rq_repmsg);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index c83a34a..865c8a2 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -2954,7 +2954,7 @@ void ptlrpc_init_xid(void)
}
/* Always need to be aligned to a power-of-two for multi-bulk BRW */
- CLASSERT((PTLRPC_BULK_OPS_COUNT & (PTLRPC_BULK_OPS_COUNT - 1)) = 0);
+ CLASSERT(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) = 0);
ptlrpc_last_xid &= PTLRPC_BULK_OPS_MASK;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH 8/8] staging: lustre: put constant on the right of binary operator
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
0 siblings, 2 replies; 12+ messages in thread
From: Joe Perches @ 2015-08-29 23:53 UTC (permalink / raw)
To: Julia Lawall
Cc: Oleg Drokin, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
On Sat, 2015-08-29 at 19:30 +0200, Julia Lawall wrote:
> Move constants to the right of binary operators.
[]
> diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
[]
> @@ -2954,7 +2954,7 @@ void ptlrpc_init_xid(void)
> }
>
> /* Always need to be aligned to a power-of-two for multi-bulk BRW */
> - CLASSERT((PTLRPC_BULK_OPS_COUNT & (PTLRPC_BULK_OPS_COUNT - 1)) = 0);
> + CLASSERT(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) = 0);
This one would probably be better as
CLASSERT(is_power_of_2(PTLRPC_BULK_OPS_COUNT));
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 8/8] staging: lustre: put constant on the right of binary operator
2015-08-29 23:53 ` Joe Perches
@ 2015-08-30 8:42 ` Julia Lawall
2015-08-30 17:12 ` Julia Lawall
1 sibling, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-30 8:42 UTC (permalink / raw)
To: Joe Perches
Cc: Julia Lawall, Oleg Drokin, kernel-janitors, Andreas Dilger,
Greg Kroah-Hartman, HPDD-discuss, devel, linux-kernel
On Sat, 29 Aug 2015, Joe Perches wrote:
> On Sat, 2015-08-29 at 19:30 +0200, Julia Lawall wrote:
> > Move constants to the right of binary operators.
> []
> > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> []
> > @@ -2954,7 +2954,7 @@ void ptlrpc_init_xid(void)
> > }
> >
> > /* Always need to be aligned to a power-of-two for multi-bulk BRW */
> > - CLASSERT((PTLRPC_BULK_OPS_COUNT & (PTLRPC_BULK_OPS_COUNT - 1)) = 0);
> > + CLASSERT(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) = 0);
>
> This one would probably be better as
>
> CLASSERT(is_power_of_2(PTLRPC_BULK_OPS_COUNT));
Thanks for the suggestion. I'll send a patch, and check for it elsewhere.
julia
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 8/8] staging: lustre: put constant on the right of binary operator
2015-08-29 23:53 ` Joe Perches
2015-08-30 8:42 ` Julia Lawall
@ 2015-08-30 17:12 ` Julia Lawall
1 sibling, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-08-30 17:12 UTC (permalink / raw)
To: Joe Perches
Cc: Oleg Drokin, kernel-janitors, Andreas Dilger, Greg Kroah-Hartman,
HPDD-discuss, devel, linux-kernel
On Sat, 29 Aug 2015, Joe Perches wrote:
> On Sat, 2015-08-29 at 19:30 +0200, Julia Lawall wrote:
> > Move constants to the right of binary operators.
> []
> > diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
> []
> > @@ -2954,7 +2954,7 @@ void ptlrpc_init_xid(void)
> > }
> >
> > /* Always need to be aligned to a power-of-two for multi-bulk BRW */
> > - CLASSERT((PTLRPC_BULK_OPS_COUNT & (PTLRPC_BULK_OPS_COUNT - 1)) = 0);
> > + CLASSERT(((PTLRPC_BULK_OPS_COUNT - 1) & PTLRPC_BULK_OPS_COUNT) = 0);
>
> This one would probably be better as
>
> CLASSERT(is_power_of_2(PTLRPC_BULK_OPS_COUNT));
Actually not. CLASSERT requires that the expression is considered to be a
constant by the compiler, such that there will be a compiler error, and
the result of is_power_of_2 is not constant enough.
julia
^ 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;
as well as URLs for NNTP newsgroup(s).