diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-14 21:37:26 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2013-02-22 23:31:33 -0500 |
commit | 6b4d0b2793337cc8943cd2948388218e2777400c (patch) | |
tree | da80347cccf78915988a2e796e681ae5450bb8ff | |
parent | 39b652527457452f09b35044fb4f8b3b0eabafdf (diff) | |
download | linux-stable-6b4d0b2793337cc8943cd2948388218e2777400c.tar.gz linux-stable-6b4d0b2793337cc8943cd2948388218e2777400c.tar.bz2 linux-stable-6b4d0b2793337cc8943cd2948388218e2777400c.zip |
clean shmem_file_setup() a bit
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | mm/shmem.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/mm/shmem.c b/mm/shmem.c index abf07f754277..8b4c198552ba 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2873,15 +2873,14 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range); */ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags) { - int error; - struct file *file; + struct file *res; struct inode *inode; struct path path; struct dentry *root; struct qstr this; if (IS_ERR(shm_mnt)) - return (void *)shm_mnt; + return ERR_CAST(shm_mnt); if (size < 0 || size > MAX_LFS_FILESIZE) return ERR_PTR(-EINVAL); @@ -2889,7 +2888,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags if (shmem_acct_size(flags, size)) return ERR_PTR(-ENOMEM); - error = -ENOMEM; + res = ERR_PTR(-ENOMEM); this.name = name; this.len = strlen(name); this.hash = 0; /* will go */ @@ -2899,7 +2898,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags goto put_memory; path.mnt = mntget(shm_mnt); - error = -ENOSPC; + res = ERR_PTR(-ENOSPC); inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); if (!inode) goto put_dentry; @@ -2909,23 +2908,23 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags clear_nlink(inode); /* It is unlinked */ #ifndef CONFIG_MMU error = ramfs_nommu_expand_for_mapping(inode, size); + res = ERR_PTR(error); if (error) goto put_dentry; #endif - file = alloc_file(&path, FMODE_WRITE | FMODE_READ, + res = alloc_file(&path, FMODE_WRITE | FMODE_READ, &shmem_file_operations); - error = PTR_ERR(file); - if (IS_ERR(file)) + if (IS_ERR(res)) goto put_dentry; - return file; + return res; put_dentry: path_put(&path); put_memory: shmem_unacct_size(flags, size); - return ERR_PTR(error); + return res; } EXPORT_SYMBOL_GPL(shmem_file_setup); |