Whamcloud - gitweb
LU-5577 obdclass: do_body_ops->dbo_{read,write} return ssize_t 88/12388/4
authorDmitry Eremin <dmitry.eremin@intel.com>
Mon, 13 Oct 2014 17:22:00 +0000 (21:22 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 18 Dec 2014 00:24:13 +0000 (00:24 +0000)
Fix warnings when use return value from do_body_ops->dbo_{read,write}.

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I6f3324e0799eff699b44e7b2b09ee4b3d2298c0d
Reviewed-on: http://review.whamcloud.com/12388
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/dt_object.c

index 83cf4fb..f05c809 100644 (file)
@@ -472,35 +472,33 @@ EXPORT_SYMBOL(dt_read);
 int dt_record_read(const struct lu_env *env, struct dt_object *dt,
                    struct lu_buf *buf, loff_t *pos)
 {
 int dt_record_read(const struct lu_env *env, struct dt_object *dt,
                    struct lu_buf *buf, loff_t *pos)
 {
-        int rc;
+       ssize_t size;
 
 
-        LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
+       LASSERTF(dt != NULL, "dt is NULL when we want to read record\n");
 
 
-        rc = dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
+       size = dt->do_body_ops->dbo_read(env, dt, buf, pos, BYPASS_CAPA);
 
 
-        if (rc == buf->lb_len)
-                rc = 0;
-        else if (rc >= 0)
-                rc = -EFAULT;
-        return rc;
+       if (size < 0)
+               return size;
+       return (size == (ssize_t)buf->lb_len) ? 0 : -EFAULT;
 }
 EXPORT_SYMBOL(dt_record_read);
 
 int dt_record_write(const struct lu_env *env, struct dt_object *dt,
                     const struct lu_buf *buf, loff_t *pos, struct thandle *th)
 {
 }
 EXPORT_SYMBOL(dt_record_read);
 
 int dt_record_write(const struct lu_env *env, struct dt_object *dt,
                     const struct lu_buf *buf, loff_t *pos, struct thandle *th)
 {
-        int rc;
+       ssize_t size;
 
 
-        LASSERTF(dt != NULL, "dt is NULL when we want to write record\n");
-        LASSERT(th != NULL);
-        LASSERT(dt->do_body_ops);
-        LASSERT(dt->do_body_ops->dbo_write);
-        rc = dt->do_body_ops->dbo_write(env, dt, buf, pos, th, BYPASS_CAPA, 1);
-        if (rc == buf->lb_len)
-                rc = 0;
-        else if (rc >= 0)
-                rc = -EFAULT;
-        return rc;
+       LASSERTF(dt != NULL, "dt is NULL when we want to write record\n");
+       LASSERT(th != NULL);
+       LASSERT(dt->do_body_ops);
+       LASSERT(dt->do_body_ops->dbo_write);
+
+       size = dt->do_body_ops->dbo_write(env, dt, buf, pos, th, BYPASS_CAPA, 1);
+
+       if (size < 0)
+               return size;
+       return (size == (ssize_t)buf->lb_len) ? 0 : -EFAULT;
 }
 EXPORT_SYMBOL(dt_record_write);
 
 }
 EXPORT_SYMBOL(dt_record_write);