Whamcloud - gitweb
LU-4067 osd: apply PTR_ERR() to right pointer 87/7887/2
authorJohn L. Hammond <john.hammond@intel.com>
Tue, 8 Oct 2013 23:23:15 +0000 (18:23 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 25 Oct 2013 03:05:23 +0000 (03:05 +0000)
In ofd_precreate_objects(), osd_index_ea_insert(), and
osd_object_create() ensure that PTR_ERR() is applied to the right
pointer. Also convert some explicit casts of ERR_PTRs to ERR_CAST()
calls.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I846b10543ae426652ad72c277d2c0f0bc259fd6e
Reviewed-on: http://review.whamcloud.com/7887
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/ofd/ofd_objects.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_object.c

index 00226cb..22c6580 100644 (file)
@@ -84,7 +84,8 @@ struct ofd_object *ofd_object_find(const struct lu_env *env,
        if (likely(!IS_ERR(o)))
                fo = ofd_obj(o);
        else
-               fo = (struct ofd_object *)o; /* return error */
+               fo = ERR_CAST(o); /* return error */
+
        RETURN(fo);
 }
 
@@ -103,7 +104,7 @@ struct ofd_object *ofd_object_find_or_create(const struct lu_env *env,
 
        dto = dt_find_or_create(env, ofd->ofd_osd, fid, &info->fti_dof, attr);
        if (IS_ERR(dto))
-               RETURN((struct ofd_object *)dto);
+               RETURN(ERR_CAST(dto));
 
        fo_obj = lu_object_locate(dto->do_lu.lo_header,
                                  ofd->ofd_dt_dev.dd_lu_dev.ld_type);
@@ -200,7 +201,7 @@ int ofd_precreate_objects(const struct lu_env *env, struct ofd_device *ofd,
                rc = ostid_to_fid(&info->fti_fid, &info->fti_ostid, 0);
                if (rc) {
                        if (i == 0)
-                               GOTO(out, rc = PTR_ERR(fo));
+                               GOTO(out, rc);
 
                        nr = i;
                        break;
index 46d6c77..241fc19 100644 (file)
@@ -4062,10 +4062,11 @@ struct osd_object *osd_object_find(const struct lu_env *env,
                        lu_object_put(env, luch);
                         child = ERR_PTR(-ENOENT);
                 }
-        } else
-                child = (void *)luch;
+       } else {
+               child = ERR_CAST(luch);
+       }
 
-        return child;
+       return child;
 }
 
 /**
@@ -4214,8 +4215,8 @@ static int osd_index_ea_insert(const struct lu_env *env, struct dt_object *dt,
                        CERROR("%s: Can not find object "DFID"%u:%u: rc = %d\n",
                               osd_name(osd), PFID(fid),
                               id->oii_ino, id->oii_gen,
-                              (int)PTR_ERR(child_inode));
-                       RETURN(PTR_ERR(child_inode));
+                              (int)PTR_ERR(child));
+                       RETURN(PTR_ERR(child));
                }
                child_inode = igrab(child->oo_inode);
        }
index 31180c6..8c2aba6 100644 (file)
@@ -1491,7 +1491,7 @@ static int osd_object_create(const struct lu_env *env, struct dt_object *dt,
 
        db = osd_create_type_f(dof->dof_type)(env, osd, attr, zapid, oh);
        if (IS_ERR(db))
-               GOTO(out, rc = PTR_ERR(th));
+               GOTO(out, rc = PTR_ERR(db));
 
        zde->zde_pad = 0;
        zde->zde_dnode = db->db_object;