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 /mm | |
parent | 39b652527457452f09b35044fb4f8b3b0eabafdf (diff) |
clean shmem_file_setup() a bit
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'mm')
-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); | |||
2873 | */ | 2873 | */ |
2874 | struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags) | 2874 | struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags) |
2875 | { | 2875 | { |
2876 | int error; | 2876 | struct file *res; |
2877 | struct file *file; | ||
2878 | struct inode *inode; | 2877 | struct inode *inode; |
2879 | struct path path; | 2878 | struct path path; |
2880 | struct dentry *root; | 2879 | struct dentry *root; |
2881 | struct qstr this; | 2880 | struct qstr this; |
2882 | 2881 | ||
2883 | if (IS_ERR(shm_mnt)) | 2882 | if (IS_ERR(shm_mnt)) |
2884 | return (void *)shm_mnt; | 2883 | return ERR_CAST(shm_mnt); |
2885 | 2884 | ||
2886 | if (size < 0 || size > MAX_LFS_FILESIZE) | 2885 | if (size < 0 || size > MAX_LFS_FILESIZE) |
2887 | return ERR_PTR(-EINVAL); | 2886 | return ERR_PTR(-EINVAL); |
@@ -2889,7 +2888,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2889 | if (shmem_acct_size(flags, size)) | 2888 | if (shmem_acct_size(flags, size)) |
2890 | return ERR_PTR(-ENOMEM); | 2889 | return ERR_PTR(-ENOMEM); |
2891 | 2890 | ||
2892 | error = -ENOMEM; | 2891 | res = ERR_PTR(-ENOMEM); |
2893 | this.name = name; | 2892 | this.name = name; |
2894 | this.len = strlen(name); | 2893 | this.len = strlen(name); |
2895 | this.hash = 0; /* will go */ | 2894 | this.hash = 0; /* will go */ |
@@ -2899,7 +2898,7 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2899 | goto put_memory; | 2898 | goto put_memory; |
2900 | path.mnt = mntget(shm_mnt); | 2899 | path.mnt = mntget(shm_mnt); |
2901 | 2900 | ||
2902 | error = -ENOSPC; | 2901 | res = ERR_PTR(-ENOSPC); |
2903 | inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); | 2902 | inode = shmem_get_inode(root->d_sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); |
2904 | if (!inode) | 2903 | if (!inode) |
2905 | goto put_dentry; | 2904 | goto put_dentry; |
@@ -2909,23 +2908,23 @@ struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags | |||
2909 | clear_nlink(inode); /* It is unlinked */ | 2908 | clear_nlink(inode); /* It is unlinked */ |
2910 | #ifndef CONFIG_MMU | 2909 | #ifndef CONFIG_MMU |
2911 | error = ramfs_nommu_expand_for_mapping(inode, size); | 2910 | error = ramfs_nommu_expand_for_mapping(inode, size); |
2911 | res = ERR_PTR(error); | ||
2912 | if (error) | 2912 | if (error) |
2913 | goto put_dentry; | 2913 | goto put_dentry; |
2914 | #endif | 2914 | #endif |
2915 | 2915 | ||
2916 | file = alloc_file(&path, FMODE_WRITE | FMODE_READ, | 2916 | res = alloc_file(&path, FMODE_WRITE | FMODE_READ, |
2917 | &shmem_file_operations); | 2917 | &shmem_file_operations); |
2918 | error = PTR_ERR(file); | 2918 | if (IS_ERR(res)) |
2919 | if (IS_ERR(file)) | ||
2920 | goto put_dentry; | 2919 | goto put_dentry; |
2921 | 2920 | ||
2922 | return file; | 2921 | return res; |
2923 | 2922 | ||
2924 | put_dentry: | 2923 | put_dentry: |
2925 | path_put(&path); | 2924 | path_put(&path); |
2926 | put_memory: | 2925 | put_memory: |
2927 | shmem_unacct_size(flags, size); | 2926 | shmem_unacct_size(flags, size); |
2928 | return ERR_PTR(error); | 2927 | return res; |
2929 | } | 2928 | } |
2930 | EXPORT_SYMBOL_GPL(shmem_file_setup); | 2929 | EXPORT_SYMBOL_GPL(shmem_file_setup); |
2931 | 2930 | ||