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


Groups > linux.kernel > #1215824

[PATCH 8/8] staging: lustre: put constant on the right of binary operator

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

Show all headers | View raw


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;
 }
 

--
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 | NextPrevious in thread | Next 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