Whamcloud - gitweb
LU-5577 ptlrpc: fix comparison between signed and unsigned 75/12475/6
authorDmitry Eremin <dmitry.eremin@intel.com>
Wed, 29 Oct 2014 14:17:03 +0000 (17:17 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 18 Dec 2014 03:07:11 +0000 (03:07 +0000)
Change return type and size argiments of lustre_msg_hdr_size(),
lustre_msg_buf{len,count}() and req_capsule_*_size() to __u32.
Change type of req_format->rf_idx and req_format->rf_fields.nr
to size_t. Also return zero for incorrect message magic instead
of -EINVAL. This will be more robust because of few of them after
LASSERTF(0, "...") and will not be returned. In the rest places
it return zero size instead of huge number after implicit
unsigned conversion.

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: Iae8b83b4285a1ea2fa010f9de2792426c1772b2c
Reviewed-on: http://review.whamcloud.com/12475
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre_net.h
lustre/include/lustre_req_layout.h
lustre/ldlm/ldlm_request.c
lustre/ptlrpc/layout.c
lustre/ptlrpc/pack_generic.c
lustre/utils/req-layout.c

index 2bdde31..0f75bc9 100644 (file)
@@ -2250,7 +2250,7 @@ ptlrpc_rqphase2str(struct ptlrpc_request *req)
 /**
  * Debugging functions and helpers to print request structure into debug log
  * @{
- */ 
+ */
 /* Spare the preprocessor, spoil the bugs. */
 #define FLAG(field, str) (field ? str : "")
 
@@ -2406,7 +2406,7 @@ struct ptlrpc_thread {
         /**
          * service thread pid
          */
-        pid_t t_pid; 
+        pid_t t_pid;
         /**
          * put watchdog in the structure per thread b=14840
          */
@@ -3174,14 +3174,14 @@ int ptlrpc_reconnect_import(struct obd_import *imp);
 /** @} */
 
 /**
- * ptlrpc msg buffer and swab interface 
+ * ptlrpc msg buffer and swab interface
  *
  * @{
  */
 int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout,
-                         int index);
+                        __u32 index);
 void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout,
-                                int index);
+                           __u32 index);
 int ptlrpc_unpack_rep_msg(struct ptlrpc_request *req, int len);
 int ptlrpc_unpack_req_msg(struct ptlrpc_request *req, int len);
 
@@ -3201,30 +3201,30 @@ int lustre_shrink_msg(struct lustre_msg *msg, int segment,
                       unsigned int newlen, int move_data);
 void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
 int __lustre_unpack_msg(struct lustre_msg *m, int len);
-int lustre_msg_hdr_size(__u32 magic, int count);
-int lustre_msg_size(__u32 magic, int count, __u32 *lengths);
-int lustre_msg_size_v2(int count, __u32 *lengths);
-int lustre_packed_msg_size(struct lustre_msg *msg);
-int lustre_msg_early_size(void);
-void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size);
-void *lustre_msg_buf(struct lustre_msg *m, int n, int minlen);
-int lustre_msg_buflen(struct lustre_msg *m, int n);
-void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len);
-int lustre_msg_bufcount(struct lustre_msg *m);
-char *lustre_msg_string(struct lustre_msg *m, int n, int max_len);
+__u32 lustre_msg_hdr_size(__u32 magic, __u32 count);
+__u32 lustre_msg_size(__u32 magic, int count, __u32 *lengths);
+__u32 lustre_msg_size_v2(int count, __u32 *lengths);
+__u32 lustre_packed_msg_size(struct lustre_msg *msg);
+__u32 lustre_msg_early_size(void);
+void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, __u32 n, __u32 min_size);
+void *lustre_msg_buf(struct lustre_msg *m, __u32 n, __u32 minlen);
+__u32 lustre_msg_buflen(struct lustre_msg *m, __u32 n);
+void lustre_msg_set_buflen(struct lustre_msg *m, __u32 n, __u32 len);
+__u32 lustre_msg_bufcount(struct lustre_msg *m);
+char *lustre_msg_string(struct lustre_msg *m, __u32 n, __u32 max_len);
 __u32 lustre_msghdr_get_flags(struct lustre_msg *msg);
 void lustre_msghdr_set_flags(struct lustre_msg *msg, __u32 flags);
 __u32 lustre_msg_get_flags(struct lustre_msg *msg);
-void lustre_msg_add_flags(struct lustre_msg *msg, int flags);
-void lustre_msg_set_flags(struct lustre_msg *msg, int flags);
-void lustre_msg_clear_flags(struct lustre_msg *msg, int flags);
+void lustre_msg_add_flags(struct lustre_msg *msg, __u32 flags);
+void lustre_msg_set_flags(struct lustre_msg *msg, __u32 flags);
+void lustre_msg_clear_flags(struct lustre_msg *msg, __u32 flags);
 __u32 lustre_msg_get_op_flags(struct lustre_msg *msg);
-void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags);
-void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags);
+void lustre_msg_add_op_flags(struct lustre_msg *msg, __u32 flags);
+void lustre_msg_set_op_flags(struct lustre_msg *msg, __u32 flags);
 struct lustre_handle *lustre_msg_get_handle(struct lustre_msg *msg);
 __u32 lustre_msg_get_type(struct lustre_msg *msg);
 __u32 lustre_msg_get_version(struct lustre_msg *msg);
-void lustre_msg_add_version(struct lustre_msg *msg, int version);
+void lustre_msg_add_version(struct lustre_msg *msg, __u32 version);
 __u32 lustre_msg_get_opc(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_xid(struct lustre_msg *msg);
 __u64 lustre_msg_get_last_committed(struct lustre_msg *msg);
@@ -3331,7 +3331,7 @@ ptlrpc_rqphase_move(struct ptlrpc_request *req, enum rq_phase new_phase)
 }
 
 /**
- * Returns true if request \a req got early reply and hard deadline is not met 
+ * Returns true if request \a req got early reply and hard deadline is not met
  */
 static inline int
 ptlrpc_client_early(struct ptlrpc_request *req)
index fb57f19..6ec880b 100644 (file)
@@ -83,7 +83,8 @@ void req_capsule_set(struct req_capsule *pill, const struct req_format *fmt);
 void req_capsule_client_dump(struct req_capsule *pill);
 void req_capsule_server_dump(struct req_capsule *pill);
 void req_capsule_init_area(struct req_capsule *pill);
-int req_capsule_filled_sizes(struct req_capsule *pill, enum req_location loc);
+size_t req_capsule_filled_sizes(struct req_capsule *pill,
+                               enum req_location loc);
 int  req_capsule_server_pack(struct req_capsule *pill);
 
 void *req_capsule_client_get(struct req_capsule *pill,
@@ -92,30 +93,30 @@ void *req_capsule_client_swab_get(struct req_capsule *pill,
                                  const struct req_msg_field *field,
                                  void *swabber);
 void *req_capsule_client_sized_get(struct req_capsule *pill,
-                                   const struct req_msg_field *field,
-                                   int len);
+                                  const struct req_msg_field *field,
+                                  __u32 len);
 void *req_capsule_server_get(struct req_capsule *pill,
                              const struct req_msg_field *field);
 void *req_capsule_server_sized_get(struct req_capsule *pill,
-                                   const struct req_msg_field *field,
-                                   int len);
+                                  const struct req_msg_field *field,
+                                  __u32 len);
 void *req_capsule_server_swab_get(struct req_capsule *pill,
                                   const struct req_msg_field *field,
                                   void *swabber);
 void *req_capsule_server_sized_swab_get(struct req_capsule *pill,
                                        const struct req_msg_field *field,
-                                       int len, void *swabber);
+                                       __u32 len, void *swabber);
 const void *req_capsule_other_get(struct req_capsule *pill,
                                   const struct req_msg_field *field);
 
 void req_capsule_set_size(struct req_capsule *pill,
-                          const struct req_msg_field *field,
-                          enum req_location loc, int size);
-int req_capsule_get_size(const struct req_capsule *pill,
-                          const struct req_msg_field *field,
-                          enum req_location loc);
-int req_capsule_msg_size(struct req_capsule *pill, enum req_location loc);
-int req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
+                         const struct req_msg_field *field,
+                         enum req_location loc, __u32 size);
+__u32 req_capsule_get_size(const struct req_capsule *pill,
+                          const struct req_msg_field *field,
+                          enum req_location loc);
+__u32 req_capsule_msg_size(struct req_capsule *pill, enum req_location loc);
+__u32 req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
                          enum req_location loc);
 void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt);
 
@@ -126,12 +127,12 @@ int req_capsule_field_present(const struct req_capsule *pill,
                               const struct req_msg_field *field,
                               enum req_location loc);
 void req_capsule_shrink(struct req_capsule *pill,
-                        const struct req_msg_field *field,
-                        unsigned int newlen,
-                        enum req_location loc);
+                       const struct req_msg_field *field,
+                       __u32 newlen,
+                       enum req_location loc);
 int req_capsule_server_grow(struct req_capsule *pill,
-                            const struct req_msg_field *field,
-                            unsigned int newlen);
+                           const struct req_msg_field *field,
+                           __u32 newlen);
 int  req_layout_init(void);
 void req_layout_fini(void);
 
index bd33d9e..836521f 100644 (file)
@@ -745,16 +745,16 @@ static inline int ldlm_capsule_handles_avail(struct req_capsule *pill,
                                              enum req_location loc,
                                              int off)
 {
-        int size = req_capsule_msg_size(pill, loc);
-        return ldlm_req_handles_avail(size, off);
+       __u32 size = req_capsule_msg_size(pill, loc);
+       return ldlm_req_handles_avail(size, off);
 }
 
 static inline int ldlm_format_handles_avail(struct obd_import *imp,
                                             const struct req_format *fmt,
                                             enum req_location loc, int off)
 {
-        int size = req_capsule_fmt_size(imp->imp_msg_magic, fmt, loc);
-        return ldlm_req_handles_avail(size, off);
+       __u32 size = req_capsule_fmt_size(imp->imp_msg_magic, fmt, loc);
+       return ldlm_req_handles_avail(size, off);
 }
 
 /**
index 57a1e03..4a37c28 100644 (file)
@@ -1211,12 +1211,12 @@ EXPORT_SYMBOL(RMF_LFSCK_REPLY);
  */
 
 struct req_format {
-        const char *rf_name;
-        int         rf_idx;
-        struct {
-                int                          nr;
-                const struct req_msg_field **d;
-        } rf_fields[RCL_NR];
+       const char *rf_name;
+       size_t      rf_idx;
+       struct {
+               size_t                       nr;
+               const struct req_msg_field **d;
+       } rf_fields[RCL_NR];
 };
 
 #define DEFINE_REQ_FMT(name, client, client_nr, server, server_nr) {    \
@@ -1683,9 +1683,9 @@ EXPORT_SYMBOL(RQF_LFSCK_QUERY);
  */
 int req_layout_init(void)
 {
-        int i;
-        int j;
-        int k;
+       size_t i;
+       size_t j;
+       size_t k;
         struct req_format *rf = NULL;
 
         for (i = 0; i < ARRAY_SIZE(req_formats); ++i) {
@@ -1727,7 +1727,7 @@ EXPORT_SYMBOL(req_layout_fini);
  */
 void req_capsule_init_area(struct req_capsule *pill)
 {
-        int i;
+       size_t i;
 
         for (i = 0; i < ARRAY_SIZE(pill->rc_area[RCL_CLIENT]); i++) {
                 pill->rc_area[RCL_CLIENT][i] = -1;
@@ -1779,9 +1779,8 @@ EXPORT_SYMBOL(req_capsule_fini);
 
 static int __req_format_is_sane(const struct req_format *fmt)
 {
-        return
-                0 <= fmt->rf_idx && fmt->rf_idx < ARRAY_SIZE(req_formats) &&
-                req_formats[fmt->rf_idx] == fmt;
+       return fmt->rf_idx < ARRAY_SIZE(req_formats) &&
+               req_formats[fmt->rf_idx] == fmt;
 }
 
 static struct lustre_msg *__req_msg(const struct req_capsule *pill,
@@ -1814,11 +1813,11 @@ EXPORT_SYMBOL(req_capsule_set);
  * variable-sized fields.  The field sizes come from the declared \a rmf_size
  * field of a \a pill's \a rc_fmt's RMF's.
  */
-int req_capsule_filled_sizes(struct req_capsule *pill,
-                           enum req_location loc)
+size_t req_capsule_filled_sizes(struct req_capsule *pill,
+                               enum req_location loc)
 {
-        const struct req_format *fmt = pill->rc_fmt;
-        int                      i;
+       const struct req_format *fmt = pill->rc_fmt;
+       size_t                   i;
 
         LASSERT(fmt != NULL);
 
@@ -1875,9 +1874,9 @@ EXPORT_SYMBOL(req_capsule_server_pack);
  * Returns the PTLRPC request or reply (\a loc) buffer offset of a \a pill
  * corresponding to the given RMF (\a field).
  */
-static int __req_capsule_offset(const struct req_capsule *pill,
-                                const struct req_msg_field *field,
-                                enum req_location loc)
+static __u32 __req_capsule_offset(const struct req_capsule *pill,
+                                 const struct req_msg_field *field,
+                                 enum req_location loc)
 {
         int offset;
 
@@ -1985,10 +1984,10 @@ static void *__req_capsule_get(struct req_capsule *pill,
         const struct req_format *fmt;
         struct lustre_msg       *msg;
         void                    *value;
-        int                      len;
-        int                      offset;
+       __u32                    len;
+       __u32                    offset;
 
-        void *(*getter)(struct lustre_msg *m, int n, int minlen);
+       void *(*getter)(struct lustre_msg *m, __u32 n, __u32 minlen);
 
         static const char *rcl_names[RCL_NR] = {
                 [RCL_CLIENT] = "client",
@@ -2018,24 +2017,24 @@ static void *__req_capsule_get(struct req_capsule *pill,
                 len = lustre_msg_buflen(msg, offset);
                 if ((len % field->rmf_size) != 0) {
                         CERROR("%s: array field size mismatch "
-                               "%d modulo %d != 0 (%d)\n",
-                               field->rmf_name, len, field->rmf_size, loc);
+                               "%d modulo %u != 0 (%d)\n",
+                               field->rmf_name, len, field->rmf_size, loc);
                         return NULL;
                 }
         } else if (pill->rc_area[loc][offset] != -1) {
                 len = pill->rc_area[loc][offset];
         } else {
-                len = max(field->rmf_size, 0);
+               len = max_t(typeof(field->rmf_size), field->rmf_size, 0);
         }
         value = getter(msg, offset, len);
 
         if (value == NULL) {
                 DEBUG_REQ(D_ERROR, pill->rc_req,
-                          "Wrong buffer for field `%s' (%d of %d) "
-                          "in format `%s': %d vs. %d (%s)\n",
-                          field->rmf_name, offset, lustre_msg_bufcount(msg),
-                          fmt->rf_name, lustre_msg_buflen(msg, offset), len,
-                          rcl_names[loc]);
+                         "Wrong buffer for field `%s' (%u of %u) "
+                         "in format `%s': %u vs. %u (%s)\n",
+                         field->rmf_name, offset, lustre_msg_bufcount(msg),
+                         fmt->rf_name, lustre_msg_buflen(msg, offset), len,
+                         rcl_names[loc]);
         } else {
                 swabber_dumper_helper(pill, field, loc, offset, value, len,
                                       dump, swabber);
@@ -2049,10 +2048,10 @@ static void *__req_capsule_get(struct req_capsule *pill,
  */
 void __req_capsule_dump(struct req_capsule *pill, enum req_location loc)
 {
-        const struct    req_format *fmt;
-        const struct    req_msg_field *field;
-        int             len;
-        int             i;
+       const struct    req_format *fmt;
+       const struct    req_msg_field *field;
+       __u32           len;
+       size_t          i;
 
         fmt = pill->rc_fmt;
 
@@ -2065,8 +2064,8 @@ void __req_capsule_dump(struct req_capsule *pill, enum req_location loc)
                          * have a specific dumper
                          */
                         len = req_capsule_get_size(pill, field, loc);
-                        CDEBUG(D_RPCTRACE, "Field %s has no dumper function;"
-                               "field size is %d\n", field->rmf_name, len);
+                       CDEBUG(D_RPCTRACE, "Field %s has no dumper function;"
+                               "field size is %u\n", field->rmf_name, len);
                 } else {
                         /* It's the dumping side-effect that we're interested in */
                         (void) __req_capsule_get(pill, field, loc, NULL, 1);
@@ -2126,8 +2125,8 @@ EXPORT_SYMBOL(req_capsule_client_swab_get);
  * returned.
  */
 void *req_capsule_client_sized_get(struct req_capsule *pill,
-                                   const struct req_msg_field *field,
-                                   int len)
+                                  const struct req_msg_field *field,
+                                  __u32 len)
 {
         req_capsule_set_size(pill, field, RCL_CLIENT, len);
         return __req_capsule_get(pill, field, RCL_CLIENT, NULL, 0);
@@ -2167,8 +2166,8 @@ EXPORT_SYMBOL(req_capsule_server_swab_get);
  * returned.
  */
 void *req_capsule_server_sized_get(struct req_capsule *pill,
-                                   const struct req_msg_field *field,
-                                   int len)
+                                  const struct req_msg_field *field,
+                                  __u32 len)
 {
         req_capsule_set_size(pill, field, RCL_SERVER, len);
         return __req_capsule_get(pill, field, RCL_SERVER, NULL, 0);
@@ -2177,7 +2176,7 @@ EXPORT_SYMBOL(req_capsule_server_sized_get);
 
 void *req_capsule_server_sized_swab_get(struct req_capsule *pill,
                                        const struct req_msg_field *field,
-                                       int len, void *swabber)
+                                       __u32 len, void *swabber)
 {
        req_capsule_set_size(pill, field, RCL_SERVER, len);
        return __req_capsule_get(pill, field, RCL_SERVER, swabber, 0);
@@ -2207,30 +2206,31 @@ EXPORT_SYMBOL(req_capsule_other_get);
  * request or reply.
  */
 void req_capsule_set_size(struct req_capsule *pill,
-                          const struct req_msg_field *field,
-                          enum req_location loc, int size)
+                         const struct req_msg_field *field,
+                         enum req_location loc, __u32 size)
 {
-        LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
-
-        if ((size != field->rmf_size) &&
-            (field->rmf_size != -1) &&
-            !(field->rmf_flags & RMF_F_NO_SIZE_CHECK) &&
-            (size > 0)) {
-                if ((field->rmf_flags & RMF_F_STRUCT_ARRAY) &&
-                    (size % field->rmf_size != 0)) {
-                        CERROR("%s: array field size mismatch "
-                               "%d %% %d != 0 (%d)\n",
-                               field->rmf_name, size, field->rmf_size, loc);
-                        LBUG();
-                } else if (!(field->rmf_flags & RMF_F_STRUCT_ARRAY) &&
-                    size < field->rmf_size) {
-                        CERROR("%s: field size mismatch %d != %d (%d)\n",
-                               field->rmf_name, size, field->rmf_size, loc);
-                        LBUG();
-                }
-        }
-
-        pill->rc_area[loc][__req_capsule_offset(pill, field, loc)] = size;
+       LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
+
+       if ((size != (__u32)field->rmf_size) &&
+           (field->rmf_size != -1) &&
+           !(field->rmf_flags & RMF_F_NO_SIZE_CHECK) &&
+           (size > 0)) {
+               __u32 rmf_size = (__u32)field->rmf_size;
+               if ((field->rmf_flags & RMF_F_STRUCT_ARRAY) &&
+                   (size % rmf_size != 0)) {
+                       CERROR("%s: array field size mismatch "
+                               "%u %% %u != 0 (%d)\n",
+                               field->rmf_name, size, rmf_size, loc);
+                       LBUG();
+               } else if (!(field->rmf_flags & RMF_F_STRUCT_ARRAY) &&
+                          size < rmf_size) {
+                       CERROR("%s: field size mismatch %u != %u (%d)\n",
+                               field->rmf_name, size, rmf_size, loc);
+                       LBUG();
+               }
+       }
+
+       pill->rc_area[loc][__req_capsule_offset(pill, field, loc)] = size;
 }
 EXPORT_SYMBOL(req_capsule_set_size);
 
@@ -2242,7 +2242,7 @@ EXPORT_SYMBOL(req_capsule_set_size);
  * actually sets the size in pill.rc_area[loc][offset], but this function
  * returns the message buflen[offset], maybe we should use another name.
  */
-int req_capsule_get_size(const struct req_capsule *pill,
+__u32 req_capsule_get_size(const struct req_capsule *pill,
                          const struct req_msg_field *field,
                          enum req_location loc)
 {
@@ -2260,7 +2260,7 @@ EXPORT_SYMBOL(req_capsule_get_size);
  *
  * See also req_capsule_set_size().
  */
-int req_capsule_msg_size(struct req_capsule *pill, enum req_location loc)
+__u32 req_capsule_msg_size(struct req_capsule *pill, enum req_location loc)
 {
         return lustre_msg_size(pill->rc_req->rq_import->imp_msg_magic,
                                pill->rc_fmt->rf_fields[loc].nr,
@@ -2275,10 +2275,11 @@ int req_capsule_msg_size(struct req_capsule *pill, enum req_location loc)
  * This function should not be used for formats which contain variable size
  * fields.
  */
-int req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
+__u32 req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
                          enum req_location loc)
 {
-        int size, i = 0;
+       __u32 size;
+       size_t i = 0;
 
         /*
          * This function should probably LASSERT() that fmt has no fields with
@@ -2288,8 +2289,8 @@ int req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
          * we do.
          */
         size = lustre_msg_hdr_size(magic, fmt->rf_fields[loc].nr);
-        if (size < 0)
-                return size;
+       if (size == 0)
+               return size;
 
         for (; i < fmt->rf_fields[loc].nr; ++i)
                 if (fmt->rf_fields[loc].d[i]->rmf_size != -1)
@@ -2319,8 +2320,8 @@ int req_capsule_fmt_size(__u32 magic, const struct req_format *fmt,
  */
 void req_capsule_extend(struct req_capsule *pill, const struct req_format *fmt)
 {
-        int i;
-        int j;
+       int i;
+       size_t j;
 
         const struct req_format *old;
 
@@ -2378,7 +2379,7 @@ int req_capsule_field_present(const struct req_capsule *pill,
                               const struct req_msg_field *field,
                               enum req_location loc)
 {
-        int offset;
+       __u32 offset;
 
         LASSERT(loc == RCL_SERVER || loc == RCL_CLIENT);
         LASSERT(req_capsule_has_field(pill, field, loc));
@@ -2395,13 +2396,13 @@ EXPORT_SYMBOL(req_capsule_field_present);
  * This is not the opposite of req_capsule_extend().
  */
 void req_capsule_shrink(struct req_capsule *pill,
-                        const struct req_msg_field *field,
-                        unsigned int newlen,
-                        enum req_location loc)
+                       const struct req_msg_field *field,
+                       __u32 newlen,
+                       enum req_location loc)
 {
         const struct req_format *fmt;
         struct lustre_msg       *msg;
-        int                      len;
+       __u32                    len;
         int                      offset;
 
         fmt = pill->rc_fmt;
@@ -2414,7 +2415,7 @@ void req_capsule_shrink(struct req_capsule *pill,
 
         msg = __req_msg(pill, loc);
         len = lustre_msg_buflen(msg, offset);
-        LASSERTF(newlen <= len, "%s:%s, oldlen=%d, newlen=%d\n",
+       LASSERTF(newlen <= len, "%s:%s, oldlen=%u, newlen=%u\n",
                                 fmt->rf_name, field->rmf_name, len, newlen);
 
         if (loc == RCL_CLIENT)
@@ -2427,12 +2428,13 @@ void req_capsule_shrink(struct req_capsule *pill,
 EXPORT_SYMBOL(req_capsule_shrink);
 
 int req_capsule_server_grow(struct req_capsule *pill,
-                            const struct req_msg_field *field,
-                            unsigned int newlen)
+                           const struct req_msg_field *field,
+                           __u32 newlen)
 {
         struct ptlrpc_reply_state *rs = pill->rc_req->rq_reply_state, *nrs;
         char *from, *to;
-        int offset, len, rc;
+       int rc;
+       __u32 offset, len;
 
         LASSERT(pill->rc_fmt != NULL);
         LASSERT(__req_format_is_sane(pill->rc_fmt));
@@ -2441,7 +2443,7 @@ int req_capsule_server_grow(struct req_capsule *pill,
 
         len = req_capsule_get_size(pill, field, RCL_SERVER);
         offset = __req_capsule_offset(pill, field, RCL_SERVER);
-        if (pill->rc_req->rq_repbuf_len >=
+       if ((__u32)pill->rc_req->rq_repbuf_len >=
             lustre_packed_msg_size(pill->rc_req->rq_repmsg) - len + newlen)
                 CERROR("Inplace repack might be done\n");
 
index 63ec045..28dfad1 100644 (file)
 
 #include "ptlrpc_internal.h"
 
-static inline int lustre_msg_hdr_size_v2(int count)
+static inline __u32 lustre_msg_hdr_size_v2(__u32 count)
 {
         return cfs_size_round(offsetof(struct lustre_msg_v2,
                                        lm_buflens[count]));
 }
 
-int lustre_msg_hdr_size(__u32 magic, int count)
+__u32 lustre_msg_hdr_size(__u32 magic, __u32 count)
 {
         switch (magic) {
         case LUSTRE_MSG_MAGIC_V2:
                 return lustre_msg_hdr_size_v2(count);
         default:
                 LASSERTF(0, "incorrect message magic: %08x\n", magic);
-                return -EINVAL;
+               return 0;
         }
 }
 EXPORT_SYMBOL(lustre_msg_hdr_size);
 
 void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout,
-                            int index)
+                           __u32 index)
 {
         if (inout)
                 lustre_set_req_swabbed(req, index);
@@ -83,7 +83,7 @@ void ptlrpc_buf_set_swabbed(struct ptlrpc_request *req, const int inout,
 EXPORT_SYMBOL(ptlrpc_buf_set_swabbed);
 
 int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout,
-                         int index)
+                        __u32 index)
 {
         if (inout)
                 return (ptlrpc_req_need_swab(req) &&
@@ -95,7 +95,7 @@ int ptlrpc_buf_need_swab(struct ptlrpc_request *req, const int inout,
 EXPORT_SYMBOL(ptlrpc_buf_need_swab);
 
 static inline int lustre_msg_check_version_v2(struct lustre_msg_v2 *msg,
-                                              __u32 version)
+                                               __u32 version)
 {
         __u32 ver = lustre_msg_get_version(msg);
         return (ver & LUSTRE_VERSION_MASK) != version;
@@ -117,9 +117,9 @@ int lustre_msg_check_version(struct lustre_msg *msg, __u32 version)
 EXPORT_SYMBOL(lustre_msg_check_version);
 
 /* early reply size */
-int lustre_msg_early_size()
+__u32 lustre_msg_early_size()
 {
-        static int size = 0;
+       static __u32 size;
        if (!size) {
                /* Always reply old ptlrpc_body_v2 to keep interoprability
                 * with the old client (< 2.3) which doesn't have pb_jobid
@@ -131,13 +131,13 @@ int lustre_msg_early_size()
                __u32 pblen = sizeof(struct ptlrpc_body_v2);
                size = lustre_msg_size(LUSTRE_MSG_MAGIC_V2, 1, &pblen);
        }
-        return size;
+       return size;
 }
 EXPORT_SYMBOL(lustre_msg_early_size);
 
-int lustre_msg_size_v2(int count, __u32 *lengths)
+__u32 lustre_msg_size_v2(int count, __u32 *lengths)
 {
-        int size;
+       __u32 size;
         int i;
 
         size = lustre_msg_hdr_size_v2(count);
@@ -154,7 +154,7 @@ EXPORT_SYMBOL(lustre_msg_size_v2);
  *       in the form of a v2 request.  If this is a connection to a v1
  *       target then the first buffer will be stripped because the ptlrpc
  *       data is part of the lustre_msg_v1 header. b=14043 */
-int lustre_msg_size(__u32 magic, int count, __u32 *lens)
+__u32 lustre_msg_size(__u32 magic, int count, __u32 *lens)
 {
         __u32 size[] = { sizeof(struct ptlrpc_body) };
 
@@ -171,14 +171,14 @@ int lustre_msg_size(__u32 magic, int count, __u32 *lens)
                 return lustre_msg_size_v2(count, lens);
         default:
                 LASSERTF(0, "incorrect message magic: %08x\n", magic);
-                return -EINVAL;
+               return 0;
         }
 }
 EXPORT_SYMBOL(lustre_msg_size);
 
 /* This is used to determine the size of a buffer that was already packed
  * and will correctly handle the different message formats. */
-int lustre_packed_msg_size(struct lustre_msg *msg)
+__u32 lustre_packed_msg_size(struct lustre_msg *msg)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2:
@@ -408,12 +408,11 @@ int lustre_pack_reply(struct ptlrpc_request *req, int count, __u32 *lens,
 }
 EXPORT_SYMBOL(lustre_pack_reply);
 
-void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size)
+void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, __u32 n, __u32 min_size)
 {
-        int i, offset, buflen, bufcount;
+       __u32 i, offset, buflen, bufcount;
 
         LASSERT(m != NULL);
-        LASSERT(n >= 0);
 
         bufcount = m->lm_bufcount;
         if (unlikely(n >= bufcount)) {
@@ -437,7 +436,7 @@ void *lustre_msg_buf_v2(struct lustre_msg_v2 *m, int n, int min_size)
         return (char *)m + offset;
 }
 
-void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
+void *lustre_msg_buf(struct lustre_msg *m, __u32 n, __u32 min_size)
 {
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2:
@@ -449,7 +448,7 @@ void *lustre_msg_buf(struct lustre_msg *m, int n, int min_size)
 }
 EXPORT_SYMBOL(lustre_msg_buf);
 
-static int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, int segment,
+static int lustre_shrink_msg_v2(struct lustre_msg_v2 *msg, __u32 segment,
                                unsigned int newlen, int move_data)
 {
         char   *tail = NULL, *newpos;
@@ -676,7 +675,7 @@ int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset)
         }
 }
 
-static inline int lustre_msg_buflen_v2(struct lustre_msg_v2 *m, int n)
+static inline __u32 lustre_msg_buflen_v2(struct lustre_msg_v2 *m, __u32 n)
 {
         if (n >= m->lm_bufcount)
                 return 0;
@@ -691,20 +690,20 @@ static inline int lustre_msg_buflen_v2(struct lustre_msg_v2 *m, int n)
  *
  * returns zero for non-existent message indices
  */
-int lustre_msg_buflen(struct lustre_msg *m, int n)
+__u32 lustre_msg_buflen(struct lustre_msg *m, __u32 n)
 {
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2:
                 return lustre_msg_buflen_v2(m, n);
         default:
                 CERROR("incorrect message magic: %08x\n", m->lm_magic);
-                return -EINVAL;
+               return 0;
         }
 }
 EXPORT_SYMBOL(lustre_msg_buflen);
 
 static inline void
-lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, int n, int len)
+lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, __u32 n, __u32 len)
 {
         if (n >= m->lm_bufcount)
                 LBUG();
@@ -712,7 +711,7 @@ lustre_msg_set_buflen_v2(struct lustre_msg_v2 *m, int n, int len)
         m->lm_buflens[n] = len;
 }
 
-void lustre_msg_set_buflen(struct lustre_msg *m, int n, int len)
+void lustre_msg_set_buflen(struct lustre_msg *m, __u32 n, __u32 len)
 {
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2:
@@ -727,23 +726,23 @@ EXPORT_SYMBOL(lustre_msg_set_buflen);
 
 /* NB return the bufcount for lustre_msg_v2 format, so if message is packed
  * in V1 format, the result is one bigger. (add struct ptlrpc_body). */
-int lustre_msg_bufcount(struct lustre_msg *m)
+__u32 lustre_msg_bufcount(struct lustre_msg *m)
 {
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2:
                 return m->lm_bufcount;
         default:
                 CERROR("incorrect message magic: %08x\n", m->lm_magic);
-                return -EINVAL;
+               return 0;
         }
 }
 EXPORT_SYMBOL(lustre_msg_bufcount);
 
-char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
+char *lustre_msg_string(struct lustre_msg *m, __u32 index, __u32 max_len)
 {
-        /* max_len == 0 means the string should fill the buffer */
-        char *str;
-        int slen, blen;
+       /* max_len == 0 means the string should fill the buffer */
+       char *str;
+       __u32 slen, blen;
 
         switch (m->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2:
@@ -786,8 +785,8 @@ char *lustre_msg_string(struct lustre_msg *m, int index, int max_len)
 EXPORT_SYMBOL(lustre_msg_string);
 
 /* Wrap up the normal fixed length cases */
-static inline void *__lustre_swab_buf(struct lustre_msg *msg, int index,
-                                      int min_size, void *swabber)
+static inline void *__lustre_swab_buf(struct lustre_msg *msg, __u32 index,
+                                     __u32 min_size, void *swabber)
 {
         void *ptr = NULL;
 
@@ -860,7 +859,7 @@ __u32 lustre_msg_get_flags(struct lustre_msg *msg)
 }
 EXPORT_SYMBOL(lustre_msg_get_flags);
 
-void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
+void lustre_msg_add_flags(struct lustre_msg *msg, __u32 flags)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2: {
@@ -875,7 +874,7 @@ void lustre_msg_add_flags(struct lustre_msg *msg, int flags)
 }
 EXPORT_SYMBOL(lustre_msg_add_flags);
 
-void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
+void lustre_msg_set_flags(struct lustre_msg *msg, __u32 flags)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2: {
@@ -890,7 +889,7 @@ void lustre_msg_set_flags(struct lustre_msg *msg, int flags)
 }
 EXPORT_SYMBOL(lustre_msg_set_flags);
 
-void lustre_msg_clear_flags(struct lustre_msg *msg, int flags)
+void lustre_msg_clear_flags(struct lustre_msg *msg, __u32 flags)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2: {
@@ -922,7 +921,7 @@ __u32 lustre_msg_get_op_flags(struct lustre_msg *msg)
 }
 EXPORT_SYMBOL(lustre_msg_get_op_flags);
 
-void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
+void lustre_msg_add_op_flags(struct lustre_msg *msg, __u32 flags)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2: {
@@ -937,7 +936,7 @@ void lustre_msg_add_op_flags(struct lustre_msg *msg, int flags)
 }
 EXPORT_SYMBOL(lustre_msg_add_op_flags);
 
-void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags)
+void lustre_msg_set_op_flags(struct lustre_msg *msg, __u32 flags)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2: {
@@ -1006,7 +1005,7 @@ __u32 lustre_msg_get_version(struct lustre_msg *msg)
 }
 EXPORT_SYMBOL(lustre_msg_get_version);
 
-void lustre_msg_add_version(struct lustre_msg *msg, int version)
+void lustre_msg_add_version(struct lustre_msg *msg, __u32 version)
 {
         switch (msg->lm_magic) {
         case LUSTRE_MSG_MAGIC_V2: {
index 22e1972..4326efd 100644 (file)
@@ -133,7 +133,7 @@ void print_layout(const struct req_format *rf)
                 [RCL_SERVER] = "S"
         };
 
-        printf("L %s (%i/%i)\n", rf->rf_name,
+       printf("L %s (%zu/%zu)\n", rf->rf_name,
                rf->rf_fields[RCL_CLIENT].nr, rf->rf_fields[RCL_SERVER].nr);
 
         for (j = 0; j < RCL_NR; ++j) {