fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode)
PATCH 1/5 fs/anon_inodes.c: Remove unnecessary IS_ERR(anon_inode_inode)
anon_inode_inode is allocated by anon_inode_init(), which is fs_initcall and will panic if it couldn't be allocated.
--- fs/anon_inodes.c | 3 --- 1 file changed, 3 deletions(-)
fs/anon_inodes.c +0 -3
@@ -75,9 +75,6 @@ struct file *anon_inode_getfile(const char *name,struct path path;struct file *file; -if (IS_ERR (anon_inode_inode)) -return ERR_PTR (-ENODEV ); -if (fops->owner && !try_module_get (fops->owner))return ERR_PTR (-ENOENT );
Signature · 1 line
2.1.2
PATCH 2/5 fs/anon_inodes.c: Simplify control flow in anon_inode_getfd()
--- fs/anon_inodes.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
fs/anon_inodes.c +6 -12
@@ -136,26 +136,20 @@ EXPORT_SYMBOL_GPL(anon_inode_getfile);int anon_inode_getfd (const char *name,const struct file_operations *fops,void *priv,int flags) { -int error, fd; +int fd;struct file *file; - error =get_unused_fd_flags (flags); -if (error <0 ) -return error; - fd = error; + fd =get_unused_fd_flags (flags); +if (fd <0 ) +return fd; file =anon_inode_getfile (name, fops, priv, flags);if (IS_ERR (file)) { - error =PTR_ERR (file); - goto err_put_unused_fd; +put_unused_fd (fd); +return PTR_ERR (file); }fd_install (fd, file); -return fd; - -err_put_unused_fd: -put_unused_fd (fd); -return error; }EXPORT_SYMBOL_GPL (anon_inode_getfd);
Signature · 1 line
2.1.2
Al Viro
maintainerRe: [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd()
fs/anon_inodes.c EXPORT_SYMBOL_GPL(anon_inode_getfile); · line 151
Quoted 8 lines · Eric Biggers
fs/anon_inodes.c +2
-2file =anon_inode_getfile (name, fops, priv, flags);if (IS_ERR (file)) { - error =PTR_ERR (file); - goto err_put_unused_fd; +put_unused_fd (fd); +return PTR_ERR (file); }fd_install (fd, file);
at least slap unlikely() on that if (IS_ERR(...))...
Re: [PATCH 2/5] fs/anon_inodes.c: Simplify control flow in anon_inode_getfd()
Quoted 11 lines · Al Viro
fs/anon_inodes.c EXPORT_SYMBOL_GPL(anon_inode_getfile); · line 151
Quoted 8 lines · Eric Biggers
fs/anon_inodes.c +2
-2file =anon_inode_getfile (name, fops, priv, flags);if (IS_ERR (file)) { - error =PTR_ERR (file); - goto err_put_unused_fd; +put_unused_fd (fd); +return PTR_ERR (file); }fd_install (fd, file);at least slap
unlikely()on that if (IS_ERR(...))...
That shouldn't be necessary, as far as I can tell; linux/err.h has:
#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
...
static inline bool __must_check IS_ERR(__force const void *ptr)
{
return IS_ERR_VALUE((unsigned long)ptr);
}So unless GCC fails to propagate expected-value handling through static inline functions, you should never need to write unlikely(IS_ERR(...)).
- Josh Triplett
PATCH 3/5 fs/anon_inodes.c: Mark anon_inode_inode __read_mostly
In reply to Eric BiggersAt least, for consistency with anon_inode_mnt.
--- fs/anon_inodes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/anon_inodes.c +1 -1
@@ -23,7 +23,7 @@#include <asm/uaccess.h> static struct vfsmount *anon_inode_mnt__read_mostly ; -static struct inode *anon_inode_inode; +static struct inode *anon_inode_inode__read_mostly ;/* * anon_inodefs_dname() is called from d_path().
Signature · 1 line
2.1.2
PATCH 4/5 fs/anon_inodes.c: Remove unneeded #includes
In reply to Eric Biggers--- fs/anon_inodes.c | 5 ----- 1 file changed, 5 deletions(-)
fs/anon_inodes.c +0 -5
@@ -8,10 +8,7 @@* */ -#include <linux/cred.h> #include <linux/file.h> -#include <linux/poll.h> -#include <linux/sched.h> #include <linux/init.h> #include <linux/fs.h> #include <linux/mount.h>
@@ -20,8 +17,6 @@#include <linux/magic.h> #include <linux/anon_inodes.h> -#include <asm/uaccess.h> -static struct vfsmount *anon_inode_mnt__read_mostly ;static struct inode *anon_inode_inode__read_mostly ;
Signature · 1 line
2.1.2
PATCH 5/5 fs/anon_inodes.c: Remove incorrect information in comment
In reply to Eric BiggersDentries for the anonymous inode are *not* named based on the inode sequence number.
--- fs/anon_inodes.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
fs/anon_inodes.c +1 -4
@@ -73,10 +73,7 @@ struct file *anon_inode_getfile(const char *name,if (fops->owner && !try_module_get (fops->owner))return ERR_PTR (-ENOENT ); -/* -* Link the inode to a directory entry by creating a unique name -* using the inode sequence number. -*/ +/* Create a dentry for the new file. */ file =ERR_PTR (-ENOMEM ); this.name = name; this.len =strlen (name);
Signature · 1 line
2.1.2