Web lists-archives.org

[PATCH 3/6] vfs: open_exec cleanup




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@xxxxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/