staging: lustre: ptlrpc: Remove unnecessary macros
PATCH 1/1 staging: lustre: ptlrpc: Remove unnecessary macros
The macros REQS_SEC_SHIFT,REQS_USEC_SHIFT declare constants 32 and 16 and their occurences have been replaced with their respective values. Also, occurences of REQS_SEQ_SHIFT have been replaced with REQS_CPT_BITS.
This was detected using Coccinelle:
@@
identifier f;
constant c;
@@
*#define f(...) c
@@
identifier a,b;
@@
*#define f(...) b(...)
--- drivers/staging/lustre/lustre/ptlrpc/events.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/staging/lustre/lustre/ptlrpc/events.c +3 -7
@@ -243,9 +243,6 @@ void client_bulk_callback(lnet_event_t *ev)#define REQS_CPT_BITS (svcpt) ((svcpt)->scp_service->srv_cpt_bits) -#define REQS_SEC_SHIFT 32 -#define REQS_USEC_SHIFT 16 -#define REQS_SEQ_SHIFT (svcpt) REQS_CPT_BITS(svcpt)static void ptlrpc_req_add_history (struct ptlrpc_service_part *svcpt,struct ptlrpc_request *req)
@@ -258,8 +255,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,* it must be called with hold svcpt::scp_lock */ - new_seq = (sec <<REQS_SEC_SHIFT ) | - (usec <<REQS_USEC_SHIFT ) | + new_seq = (sec <<32 ) | (usec <<16 ) | (svcpt->scp_cpt <0 ?0 : svcpt->scp_cpt);if (new_seq > svcpt->scp_hist_seq) {
@@ -268,14 +264,14 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,*/ svcpt->scp_hist_seq = new_seq; }else { -LASSERT (REQS_SEQ_SHIFT (svcpt) <REQS_USEC_SHIFT ); +LASSERT (REQS_CPT_BITS (svcpt) <16 );/* NB: increase sequence number in current usec bucket, * however, it's possible that we used up all bits for * sequence and jumped into the next usec bucket (future time), * then we hope there will be less RPCs per bucket at some * point, and sequence will catch up again */ - svcpt->scp_hist_seq += (1U <<REQS_SEQ_SHIFT (svcpt)); + svcpt->scp_hist_seq += (1U <<REQS_CPT_BITS (svcpt)); new_seq = svcpt->scp_hist_seq; }
--
2.1.4
Quoted 1 line · Bhaktipriya Shridhar
The macros REQS_SEC_SHIFT,REQS_USEC_SHIFT declare constants 32 and 16
Is it really an improvement? It's not so nice to just use magic numbers.
julia
Quoted 75 lines
and their occurences have been replaced with their respective values. Also, occurences of
REQS_SEQ_SHIFThave been replaced withREQS_CPT_BITS.This was detected using Coccinelle:
@@
identifier f;
constant c;
@@
*#define f(...) c@@
identifier a,b;
@@*#define f(...) b(...)
Signed-off-by Bhaktipriya Shridhar <[email protected]>--- drivers/staging/lustre/lustre/ptlrpc/events.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)drivers/staging/lustre/lustre/ptlrpc/events.c +3
-8@@ -243,9 +243,6 @@ void client_bulk_callback(lnet_event_t *ev)#define REQS_CPT_BITS (svcpt) ((svcpt)->scp_service->srv_cpt_bits) -#define REQS_SEC_SHIFT 32 -#define REQS_USEC_SHIFT 16 -#define REQS_SEQ_SHIFT (svcpt) REQS_CPT_BITS(svcpt)static void ptlrpc_req_add_history (struct ptlrpc_service_part *svcpt,struct ptlrpc_request *req)@@ -258,8 +255,7 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,* it must be called with hold svcpt::scp_lock */ - new_seq = (sec <<REQS_SEC_SHIFT ) | - (usec <<REQS_USEC_SHIFT ) | + new_seq = (sec <<32 ) | (usec <<16 ) | (svcpt->scp_cpt <0 ?0 : svcpt->scp_cpt);if (new_seq > svcpt->scp_hist_seq) {@@ -268,14 +264,14 @@ static void ptlrpc_req_add_history(struct ptlrpc_service_part *svcpt,*/ svcpt->scp_hist_seq = new_seq; }else { -LASSERT (REQS_SEQ_SHIFT (svcpt) <REQS_USEC_SHIFT ); +LASSERT (REQS_CPT_BITS (svcpt) <16 );/* NB: increase sequence number in current usec bucket, * however, it's possible that we used up all bits for * sequence and jumped into the next usec bucket (future time), * then we hope there will be less RPCs per bucket at some * point, and sequence will catch up again */ - svcpt->scp_hist_seq += (1U <<REQS_SEQ_SHIFT (svcpt)); + svcpt->scp_hist_seq += (1U <<REQS_CPT_BITS (svcpt)); new_seq = svcpt->scp_hist_seq; } --2.1.4
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160301173208.GA21310%40Karyakshetra.
For more options, visit https://groups.google.com/d/optout.