Skip to content

Commit 7e34bc5

Browse files
Julia Lawallliewegas
authored andcommitted
fs/ceph: Use ERR_CAST
Use ERR_CAST(x) rather than ERR_PTR(PTR_ERR(x)). The former makes more clear what is the purpose of the operation, which otherwise looks like a no-op. In the case of fs/ceph/inode.c, ERR_CAST is not needed, because the type of the returned value is the same as the type of the enclosing function. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ type T; T x; identifier f; @@ T f (...) { <+... - ERR_PTR(PTR_ERR(x)) + x ...+> } @@ expression x; @@ - ERR_PTR(PTR_ERR(x)) + ERR_CAST(x) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Sage Weil <sage@newdream.net>
1 parent a41359f commit 7e34bc5

6 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎fs/ceph/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static struct dentry *ceph_lookup(struct inode *dir, struct dentry *dentry,
587587
CEPH_MDS_OP_LOOKUPSNAP : CEPH_MDS_OP_LOOKUP;
588588
req = ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS);
589589
if (IS_ERR(req))
590-
return ERR_PTR(PTR_ERR(req));
590+
return ERR_CAST(req);
591591
req->r_dentry = dget(dentry);
592592
req->r_num_caps = 2;
593593
/* we only need inode linkage */

‎fs/ceph/export.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static struct dentry *__cfh_to_dentry(struct super_block *sb,
133133
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPHASH,
134134
USE_ANY_MDS);
135135
if (IS_ERR(req))
136-
return ERR_PTR(PTR_ERR(req));
136+
return ERR_CAST(req);
137137

138138
req->r_ino1 = vino;
139139
req->r_ino2.ino = cfh->parent_ino;

‎fs/ceph/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ struct dentry *ceph_lookup_open(struct inode *dir, struct dentry *dentry,
230230
/* do the open */
231231
req = prepare_open_request(dir->i_sb, flags, mode);
232232
if (IS_ERR(req))
233-
return ERR_PTR(PTR_ERR(req));
233+
return ERR_CAST(req);
234234
req->r_dentry = dget(dentry);
235235
req->r_num_caps = 2;
236236
if (flags & O_CREAT) {

‎fs/ceph/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct inode *ceph_get_snapdir(struct inode *parent)
6969

7070
BUG_ON(!S_ISDIR(parent->i_mode));
7171
if (IS_ERR(inode))
72-
return ERR_PTR(PTR_ERR(inode));
72+
return inode;
7373
inode->i_mode = parent->i_mode;
7474
inode->i_uid = parent->i_uid;
7575
inode->i_gid = parent->i_gid;

‎fs/ceph/osdmap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end,
706706
len, *p, end);
707707
newcrush = crush_decode(*p, min(*p+len, end));
708708
if (IS_ERR(newcrush))
709-
return ERR_PTR(PTR_ERR(newcrush));
709+
return ERR_CAST(newcrush);
710710
}
711711

712712
/* new flags? */

‎fs/ceph/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ static struct dentry *open_root_dentry(struct ceph_client *client,
738738
dout("open_root_inode opening '%s'\n", path);
739739
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS);
740740
if (IS_ERR(req))
741-
return ERR_PTR(PTR_ERR(req));
741+
return ERR_CAST(req);
742742
req->r_path1 = kstrdup(path, GFP_NOFS);
743743
req->r_ino1.ino = CEPH_INO_ROOT;
744744
req->r_ino1.snap = CEPH_NOSNAP;

0 commit comments

Comments
 (0)