From: Andreas Dilger Date: Thu, 19 Apr 2018 18:03:18 +0000 (-0600) Subject: LU-1644 ptlrpc: fix return type of boolean functions X-Git-Tag: 2.11.52~15 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e2cac9fb9baf43f48eb58334fb5044cece5395c0;p=fs%2Flustre-release.git LU-1644 ptlrpc: fix return type of boolean functions Some functions are returning type int with values 0 or 1 when they could be returning bool. Fix up the return type of: lustre_req_swabbed() lustre_rep_swabbed() ptlrpc_req_need_swab() ptlrpc_rep_need_swab() ptlrpc_buf_need_swab() Test-Parameters: trivial Signed-off-by: Andreas Dilger Change-Id: I758afbf2d50ee9c0930d3080016803a299ecab07 Reviewed-on: https://review.whamcloud.com/32088 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre_net.h b/lustre/include/lustre_net.h index 9e655e6..6588312 100644 --- a/lustre/include/lustre_net.h +++ b/lustre/include/lustre_net.h @@ -1163,37 +1163,37 @@ static inline bool ptlrpc_nrs_req_can_move(struct ptlrpc_request *req) /** @} nrs */ /** - * Returns 1 if request buffer at offset \a index was already swabbed + * Returns true if request buffer at offset \a index was already swabbed */ -static inline int lustre_req_swabbed(struct ptlrpc_request *req, size_t index) +static inline bool lustre_req_swabbed(struct ptlrpc_request *req, size_t index) { - LASSERT(index < sizeof(req->rq_req_swab_mask) * 8); - return req->rq_req_swab_mask & (1 << index); + LASSERT(index < sizeof(req->rq_req_swab_mask) * 8); + return req->rq_req_swab_mask & (1 << index); } /** - * Returns 1 if request reply buffer at offset \a index was already swabbed + * Returns true if request reply buffer at offset \a index was already swabbed */ -static inline int lustre_rep_swabbed(struct ptlrpc_request *req, size_t index) +static inline bool lustre_rep_swabbed(struct ptlrpc_request *req, size_t index) { - LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8); - return req->rq_rep_swab_mask & (1 << index); + LASSERT(index < sizeof(req->rq_rep_swab_mask) * 8); + return req->rq_rep_swab_mask & (1 << index); } /** - * Returns 1 if request needs to be swabbed into local cpu byteorder + * Returns true if request needs to be swabbed into local cpu byteorder */ -static inline int ptlrpc_req_need_swab(struct ptlrpc_request *req) +static inline bool ptlrpc_req_need_swab(struct ptlrpc_request *req) { - return lustre_req_swabbed(req, MSG_PTLRPC_HEADER_OFF); + return lustre_req_swabbed(req, MSG_PTLRPC_HEADER_OFF); } /** - * Returns 1 if request reply needs to be swabbed into local cpu byteorder + * Returns true if request reply needs to be swabbed into local cpu byteorder */ -static inline int ptlrpc_rep_need_swab(struct ptlrpc_request *req) +static inline bool ptlrpc_rep_need_swab(struct ptlrpc_request *req) { - return lustre_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF); + return lustre_rep_swabbed(req, MSG_PTLRPC_HEADER_OFF); } /** @@ -2321,8 +2321,8 @@ int ptlrpc_reconnect_import(struct obd_import *imp); * * @{ */ -int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout, - __u32 index); +bool ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout, + __u32 index); void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout, __u32 index); int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len); diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index a66b6d4..d07c952 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -78,15 +78,14 @@ void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout, lustre_set_rep_swabbed(req, index); } -int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout, - __u32 index) +bool ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout, + __u32 index) { - if (inout) - return (ptlrpc_req_need_swab(req) && - !lustre_req_swabbed(req, index)); - else - return (ptlrpc_rep_need_swab(req) && - !lustre_rep_swabbed(req, index)); + if (inout) + return (ptlrpc_req_need_swab(req) && + !lustre_req_swabbed(req, index)); + + return (ptlrpc_rep_need_swab(req) && !lustre_rep_swabbed(req, index)); } static inline int lustre_msg_check_version_v2(struct lustre_msg_v2 *msg, diff --git a/lustre/ptlrpc/sec_plain.c b/lustre/ptlrpc/sec_plain.c index e4f2115..dea70d1 100644 --- a/lustre/ptlrpc/sec_plain.c +++ b/lustre/ptlrpc/sec_plain.c @@ -215,12 +215,12 @@ int plain_ctx_sign(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) static int plain_ctx_verify(struct ptlrpc_cli_ctx *ctx, struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_repdata; - struct plain_header *phdr; - __u32 cksum; - int swabbed; - ENTRY; + struct lustre_msg *msg = req->rq_repdata; + struct plain_header *phdr; + __u32 cksum; + bool swabbed; + ENTRY; if (msg->lm_bufcount != PLAIN_PACK_SEGMENTS) { CERROR("unexpected reply buf count %u\n", msg->lm_bufcount); RETURN(-EPROTO); @@ -723,16 +723,15 @@ static struct ptlrpc_svc_ctx plain_svc_ctx = { .sc_policy = &plain_policy, }; -static -int plain_accept(struct ptlrpc_request *req) +static int plain_accept(struct ptlrpc_request *req) { - struct lustre_msg *msg = req->rq_reqbuf; - struct plain_header *phdr; - int swabbed; - ENTRY; + struct lustre_msg *msg = req->rq_reqbuf; + struct plain_header *phdr; + bool swabbed; - LASSERT(SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) == - SPTLRPC_POLICY_PLAIN); + ENTRY; + LASSERT(SPTLRPC_FLVR_POLICY(req->rq_flvr.sf_rpc) == + SPTLRPC_POLICY_PLAIN); if (SPTLRPC_FLVR_BASE(req->rq_flvr.sf_rpc) != SPTLRPC_FLVR_BASE(SPTLRPC_FLVR_PLAIN) ||