clean shmem_file_setup() a bit

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2013-02-14 21:37:26 -05:00
parent 39b6525274
commit 6b4d0b2793
1 changed files with 9 additions and 10 deletions

View File

@ -2873,15 +2873,14 @@ EXPORT_SYMBOL_GPL(shmem_truncate_range);
*/ */
struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags) struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags)
{ {
int error; struct file *res;
struct file *file;
struct inode *inode; struct inode *inode;
struct path path; struct path path;
struct dentry *root; struct dentry *root;
struct qstr this; struct qstr this;
if (IS_ERR(shm_mnt)) if (IS_ERR(shm_mnt))
return (void *)shm_mnt; return ERR_CAST(shm_mnt);
if (size < 0 || size > MAX_LFS_FILESIZE) if (size < 0 || size > MAX_LFS_FILESIZE)
return ERR_PTR(-EINVAL); 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)) if (shmem_acct_size(flags, size))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
error = -ENOMEM; res = ERR_PTR(-ENOMEM);
this.name = name; this.name = name;
this.len = strlen(name); this.len = strlen(name);
this.hash = 0; /* will go */ 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; goto put_memory;
path.mnt = mntget(shm_mnt); 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); inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
if (!inode) if (!inode)
goto put_dentry; 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 */ clear_nlink(inode); /* It is unlinked */
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
error = ramfs_nommu_expand_for_mapping(inode, size); error = ramfs_nommu_expand_for_mapping(inode, size);
res = ERR_PTR(error);
if (error) if (error)
goto put_dentry; goto put_dentry;
#endif #endif
file = alloc_file(&path, FMODE_WRITE | FMODE_READ, res = alloc_file(&path, FMODE_WRITE | FMODE_READ,
&shmem_file_operations); &shmem_file_operations);
error = PTR_ERR(file); if (IS_ERR(res))
if (IS_ERR(file))
goto put_dentry; goto put_dentry;
return file; return res;
put_dentry: put_dentry:
path_put(&path); path_put(&path);
put_memory: put_memory:
shmem_unacct_size(flags, size); shmem_unacct_size(flags, size);
return ERR_PTR(error); return res;
} }
EXPORT_SYMBOL_GPL(shmem_file_setup); EXPORT_SYMBOL_GPL(shmem_file_setup);