Whamcloud - gitweb
LU-1644 ptlrpc: fix return type of boolean functions 88/32088/4
authorAndreas Dilger <andreas.dilger@intel.com>
Thu, 19 Apr 2018 18:03:18 +0000 (12:03 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 12 May 2018 03:52:10 +0000 (03:52 +0000)
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 <andreas.dilger@intel.com>
Change-Id: I758afbf2d50ee9c0930d3080016803a299ecab07
Reviewed-on: https://review.whamcloud.com/32088
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre_net.h
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/sec_plain.c

index 9e655e6..6588312 100644 (file)
@@ -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);
index a66b6d4..d07c952 100644 (file)
@@ -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,
index e4f2115..dea70d1 100644 (file)
@@ -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) ||