lkml.org 
[lkml]   [2008]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 3/6] vfs: open_exec cleanup
Date
open_exec is needlessly indented, calls ERR_PTR with 0 argument
(which is not valid errno) and jumps into middle of function
just to return value.
So clean it up a bit.

Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
fs/exec.c | 44 ++++++++++++++++++++++----------------------
1 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index aeaa979..ca8b512 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -656,34 +656,34 @@ struct file *open_exec(const char *name)
struct nameidata nd;
int err;
struct file *file;
+ struct inode *inode;

err = path_lookup_open(AT_FDCWD, name, LOOKUP_FOLLOW, &nd, FMODE_READ|FMODE_EXEC);
- file = ERR_PTR(err);
-
- if (!err) {
- struct inode *inode = nd.path.dentry->d_inode;
- file = ERR_PTR(-EACCES);
- if (S_ISREG(inode->i_mode)) {
- int err = vfs_permission(&nd, MAY_EXEC);
- file = ERR_PTR(err);
- if (!err) {
- file = nameidata_to_filp(&nd,
- O_RDONLY|O_LARGEFILE);
- if (!IS_ERR(file)) {
- err = deny_write_access(file);
- if (err) {
- fput(file);
- file = ERR_PTR(err);
- }
+ if (err)
+ return ERR_PTR(err);
+
+ inode = nd.path.dentry->d_inode;
+ file = ERR_PTR(-EACCES);
+ if (S_ISREG(inode->i_mode)) {
+ int err = vfs_permission(&nd, MAY_EXEC);
+ if (!err) {
+ file = nameidata_to_filp(&nd, O_RDONLY|O_LARGEFILE);
+ if (!IS_ERR(file)) {
+ err = deny_write_access(file);
+ if (err) {
+ fput(file);
+ file = ERR_PTR(err);
}
-out:
- return file;
}
+ goto out;
}
- release_open_intent(&nd);
- path_put(&nd.path);
+ else
+ file = ERR_PTR(err);
}
- goto out;
+ release_open_intent(&nd);
+ path_put(&nd.path);
+out:
+ return file;
}

EXPORT_SYMBOL(open_exec);
--
1.5.4.5


\
 
 \ /
  Last update: 2008-05-19 00:05    [from the cache]
©2003-2011 Jasper Spaans